Predict products You need a Recommendation Engine Predict products that a customer will like – and show it. Predictive model Algorithm - Predictive model - based on users’ behaviors
= sc.textFile("trainingData.txt").map(_.split(',') match { …. }) // Build a predictive model with an algorithm val model = ALS.train(trainingData, 10, 20, 0.01) // Make prediction allUsers.foreach { user => model.recommendProducts(user, 5) } } A Classic Recommender Example prototyping…
dynamic prediction query? • How do you persist the predictive model, in a distributed environment? • How to make HBase, Spark and algorithms talking to each other? • How should I prepare, or transform, the data for model training? • How to update the model with new data without downtime? • Where should I add some business logics? • How to make the code configurable, re-usable and maintainable? • How do I build all these with a separate of concerns (SoC)? Beyond Prototyping
$ curl -H "Content-Type: application/json" -d '{ "user": "1", "num": 4 }' http://localhost:8000/queries.json case class Query( val user: String, val num: Int ) extends Serializable
{“itemScores”:[{"item":"22","score":4.072304374729956}, {"item":"62","score":4.058482414005789}, {"item":"75","score":4.046063009943821}]} case class PredictedResult( val itemScores: Array[ItemScore] ) extends Serializable case class ItemScore( item: String, score: Double ) extends Serializable
-s http://install.prediction.io/install.sh)" • Start the Event Server $ pio eventserver • Deploy an Engine $ pio build; pio train; pio deploy • Update Engine Model with New Data $ pio train; pio deploy