Recommendation Engine ALS

Author : Rajdeep Dua
Last Updated : Dec 2 2016


In this exercise we will create a simple recommendation engine based on Alternative Least Square Algorithm.

We will use the Pre-installed setup in our VM

MyRecommendation template has been downloaded to /home/ubuntu/work/0.10.0/incubator-predictionio/PredictionIO-0.10.0-incubating/MyRecommendation

Event Server

  1. Start the Event Server

    ./bin/pio eventserver &

    You can check status of the event server by going to the following url http://localhost:7070

  2. Create a new App by giving an access key. You can generate your own access key here

    cd MyRecommendation
    ../bin/pio app new MyApp1 --access-key ee7694ba-b3b9-11e6-80f5-76304dec7eb7
  3. Export the Access Key into an Environment Variable

    export ACCESS_KEY=ee7694ba-b3b9-11e6-80f5-76304dec7eb7
  4. Import Data into Event Server

    python data/ --access_key $ACCESS_KEY
  5. View the Events in the Browser at the url http://localhost:7070/events.json?accessKey=ee7694ba-b3b9-11e6-80f5-76304dec7eb7&limit=-1


Recommendation Engine

  1. Build the Engine

    ../bin/pio build --verbose
    [INFO] [Console$] Your engine is ready for training.
  2. Train the Engine

    ../bin/pio train

    Output will be similar to listing below

    [INFO] [Engine$] org.apache.spark.mllib.recommendation.
    ALSModel does not support data sanity check. Skipping check.
    [INFO] [Engine$] EngineWorkflow.train completed
    [INFO] [Engine] engineInstanceId=7cb0a26d-f2e6-4954-9831-67944a625ac6
    [INFO] [CoreWorkflow$] Inserting persistent model
    [INFO] [CoreWorkflow$] Updating engine instance
    [INFO] [CoreWorkflow$] Training completed successfully.
  3. Start the Engine

    ../bin/pio deploy

    Output will be similar to listing below. In our case engine is listening at

    INFO] [HttpListener] Bound to /
    [INFO] [MasterActor] Engine is deployed and running.
    Engine API is live at

Browse to the link to see the Engine output.


Find Recommendations

Query the Engine Rest Endpoint above

curl -H "Content-Type: application/json" \
 -d '{ "user": "1", "num": 4 }'