Day 4: PredictionIO--How to Build A Blog Recommender – OpenShift Blog
PredictionIO is an open source machine learning server application written in Scala. It provides an easy to use REST API to build recommendation engines. It also provides client SDKs, which wraps the REST API. The Client SDKs are available in Java, Python, Ruby, and PHP programming languages. PredictionIO core is using Apache Mahout. Apache Mahout is a scalable machine learning library which provides various clustering, classification, filtering algorithms. Apache Mahout can run these algorithms on distributed Hapoop cluster.
The usecase that we are solving is to recommend blogs to user depending on the blog he has viewed. In the code shown below, we are getting all similar items to blog1 for userId “shekhar”.
import io.prediction.Client; import java.util.Arrays; public class BlogrRecommender { public static void main(String[] args) throws Exception { Client client = new Client("wwoTLn0FR7vH6k51Op8KbU1z4tqeFGZyvBpSgafOaSSe40WqdMf90lEncOA0SB13"); client.identify("shekhar"); String[] recommendedItems = client.getItemSimTopN("engine1", "blog1", 5); System.out.println(String.format("User %s is recommended %s", "shekhar", Arrays.toString(recommendedItems))); client.close(); } }
Run the Java program and you will see result as “blog4″,”blog5″,”blog6″ , and “blog7″.
Read full article from Day 4: PredictionIO--How to Build A Blog Recommender – OpenShift Blog
No comments:
Post a Comment