com.shephertz.app42.paas.sdk.jme.recommend
Class RecommenderService

java.lang.Object
  extended by com.shephertz.app42.paas.sdk.jme.recommend.RecommenderService

public class RecommenderService
extends java.lang.Object

Recommendation engine which provides reommendation based on customer id, item id and the preference of the customer for a particular Item. Recommendations can be fetched based on User Similarity which finds similarity based on Users and Item Similarity which finds similarity based on Items. The Recommendation Engine currently supports two types of Similarity Algorithms i.e. EuclideanDistanceSimilarity and PearsonCorrelationSimilarity. By default when similarity is not specified PearsonCorrelationSimilarity is used e.g. in the method itemBased(String preferenceFileName, long userId, int howMany), it uses PearsonCorrelationSimilarity. In the method itemBasedBySimilarity(String similarity, String preferenceFileName, long userId, int howMany) one can specify which similarity algorithm has to be used e.g. Recommender.EUCLIDEAN_DISTANCE or Recommender.PEARSON_CORRELATION. Preference file can be loaded using the method loadPreferenceFile(String fileName, String preferenceFilePath, String description) in csv format. This prefernce file has to be uploaded once which can be a batch process The csv format for the file is given below. customerId, itemId, preference e.g. 1,101,5.0 1,102,3.0 1,103,2.5 2,101,2.0 2,102,2.5 2,103,5.0 2,104,2.0 3,101,2.5 3,104,4.0 3,105,4.5 3,107,5.0 4,101,5.0 4,103,3.0 4,104,4.5 4,106,4.0 5,101,4.0 5,102,3.0 5,103,2.0 5,104,4.0 5,105,3.5 5,106,4.0 The customer Id and item id can be any alphanumaric character(s) and preference values can be in any range. If app developers have used the Review Service. The Recommendation Engine can be used in conjunction with Review. In this case a CSV preference file need not be uploaded. The customerId, itemId and preference will be taken from Review where customerId is mapped with userName, itemId is mapped with itemId and preference with rating. The methods for recommendations based on Reviews are part of the Review service

See Also:
ReviewService

Constructor Summary
RecommenderService(java.lang.String apiKey, java.lang.String secretKey, java.lang.String baseURL)
          The costructor for the Service
 
Method Summary
 App42Response addOrUpdatePreference(java.util.Vector preferenceDataList)
          Add or Update preference list on the cloud.
 App42Response deleteAllPreferences()
          Delete existing preference file.
 Recommender itemBased(long userId, int howMany)
          Item based recommendations.
 Recommender itemBasedBySimilarity(java.lang.String recommenderSimilarity, long userId, int howMany)
          Item based recommendations.
 Recommender itemBasedBySimilarityForAll(java.lang.String recommenderSimilarity, int howMany)
          Item based recommendations for all Users.
 Recommender itemBasedForAll(int howMany)
          Item based recommendations for all Users.
 App42Response loadPreferenceFile(java.io.InputStream preferenceFileIS)
          Uploads peference file on the cloud via Stream.
 Recommender slopeOne(long userId, int howMany)
          Recommendations based on SlopeOne Algorithm
 Recommender slopeOneForAll(int howMany)
          Recommendations based on SlopeOne Algorithm for all Users
 Recommender userBasedNeighborhood(long userId, int size, int howMany)
          User based recommendations based on Neighborhood.
 Recommender userBasedNeighborhoodBySimilarity(java.lang.String recommenderSimilarity, long userId, int size, int howMany)
          User based recommendations based on Neighborhood and Similarity.
 Recommender userBasedNeighborhoodBySimilarityForAll(java.lang.String recommenderSimilarity, int size, int howMany)
          User based recommendations based on Neighborhood and Similarity for all Users.
 Recommender userBasedNeighborhoodForAll(int size, int howMany)
          User based recommendations based on Neighborhood for All Users.
 Recommender userBasedThreshold(long userId, double threshold, int howMany)
          User based neighborhood recommendations based on Threshold.
 Recommender userBasedThresholdBySimilarity(java.lang.String recommenderSimilarity, long userId, double threshold, int howMany)
          User based neighbourhood recommendations based on Threshold.
 Recommender userBasedThresholdBySimilarityForAll(java.lang.String recommenderSimilarity, double threshold, int howMany)
          User based neighbourhood recommendations based on Threshold for All.
 Recommender userBasedThresholdForAll(double threshold, int howMany)
          User based neighbourhood recommendations based on Threshold for all Users.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecommenderService

public RecommenderService(java.lang.String apiKey,
                          java.lang.String secretKey,
                          java.lang.String baseURL)
The costructor for the Service

Parameters:
apiKey -
secretKey -
baseURL -
Method Detail

addOrUpdatePreference

public App42Response addOrUpdatePreference(java.util.Vector preferenceDataList)
                                    throws App42Exception
Add or Update preference list on the cloud.

Parameters:
preferenceDataList - - List of PreferenceData which contains customerId, itemId, preference
Returns:
App42Response object
Throws:
App42Exception

deleteAllPreferences

public App42Response deleteAllPreferences()
                                   throws App42Exception
Delete existing preference file.

Throws:
App42Exception

itemBased

public Recommender itemBased(long userId,
                             int howMany)
                      throws App42Exception
Item based recommendations. Recommendations and found based item similarity of the given user. The size of the neighborhood can be found.

Parameters:
userId - - The user Id for whom recommendations have to be found
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

itemBasedBySimilarity

public Recommender itemBasedBySimilarity(java.lang.String recommenderSimilarity,
                                         long userId,
                                         int howMany)
                                  throws App42Exception
Item based recommendations. Recommendations and found based one item similarity. Similarity algorithm can be specified. of the given user. The size of the neighborhood can be found.

Parameters:
recommenderSimilarity - - Similarity algorithm e.g. Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION
userId - - The user Id for whom recommendations have to be found
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

itemBasedBySimilarityForAll

public Recommender itemBasedBySimilarityForAll(java.lang.String recommenderSimilarity,
                                               int howMany)
                                        throws App42Exception
Item based recommendations for all Users. Recommendations and found based one item similarity. Similarity algorithm can be specified. of the given user. The size of the neighborhood can be found.

Parameters:
recommenderSimilarity - - Similarity algorithm e.g. Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

itemBasedForAll

public Recommender itemBasedForAll(int howMany)
                            throws App42Exception
Item based recommendations for all Users. Recommendations and found based item similarity of the given user. The size of the neighborhood can be found.

Parameters:
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

loadPreferenceFile

public App42Response loadPreferenceFile(java.io.InputStream preferenceFileIS)
                                 throws App42Exception
Uploads peference file on the cloud via Stream. The preference file should be in CSV format. This prefernce file has to be uploaded once which can be a batch process. New versions of preference file either can be uploaded in a different name or the older one has to be removed and the uploaded in the same name. The csv format for the file is given below. customerId, itemId, preference e.g. 1,101,5.0 1,102,3.0 1,103,2.5 2,101,2.0 2,102,2.5 2,103,5.0 2,104,2.0 3,101,2.5 3,104,4.0 3,105,4.5 3,107,5.0 4,101,5.0 4,103,3.0 4,104,4.5 4,106,4.0 5,101,4.0 5,102,3.0 5,103,2.0 5,104,4.0 5,105,3.5 5,106,4.0 The customer Id and item id can be any alphanumaric character(s) and preference values can be in any range. If the recommendations have to be done based on Reviews then this file need not be uploaded.

Parameters:
inputStream - - InputStream of the file to load.
Returns:
App42Response object.
Throws:
App42Exception

slopeOne

public Recommender slopeOne(long userId,
                            int howMany)
                     throws App42Exception
Recommendations based on SlopeOne Algorithm

Parameters:
userId - - The user Id for whom recommendations have to be found
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

slopeOneForAll

public Recommender slopeOneForAll(int howMany)
                           throws App42Exception
Recommendations based on SlopeOne Algorithm for all Users

Parameters:
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedNeighborhood

public Recommender userBasedNeighborhood(long userId,
                                         int size,
                                         int howMany)
                                  throws App42Exception
User based recommendations based on Neighborhood. Recommendations are found based on similar users in the Neighborhood of the given user. The size of the neighborhood can be found.

Parameters:
userId - - The user Id for whom recommendations have to be found
size - - Size of the Neighborhood
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedNeighborhoodBySimilarity

public Recommender userBasedNeighborhoodBySimilarity(java.lang.String recommenderSimilarity,
                                                     long userId,
                                                     int size,
                                                     int howMany)
                                              throws App42Exception
User based recommendations based on Neighborhood and Similarity. Recommendations and found based on the similar users in the Neighborhood with the specified Similarity Algorithm. Algorithm can be specified using the constants Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION

Parameters:
recommenderSimilarity - - Similarity algorithm e.g. Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION
userId - - The user Id for whom recommendations have to be found
size - - Size of the Neighborhood
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedNeighborhoodBySimilarityForAll

public Recommender userBasedNeighborhoodBySimilarityForAll(java.lang.String recommenderSimilarity,
                                                           int size,
                                                           int howMany)
                                                    throws App42Exception
User based recommendations based on Neighborhood and Similarity for all Users. Recommendations and found based similar users in the Neighborhood with the specified Similarity Algorithm. Algorithm can be specified using the constants Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION

Parameters:
recommenderSimilarity - - Similarity algorithm e.g. Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION
size - - Size of the Neighborhood
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedNeighborhoodForAll

public Recommender userBasedNeighborhoodForAll(int size,
                                               int howMany)
                                        throws App42Exception
User based recommendations based on Neighborhood for All Users. Recommendations and found based similar users in the Neighborhood of the given user. The size of the neighborhood can be found.

Parameters:
size - - Size of the Neighborhood
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedThreshold

public Recommender userBasedThreshold(long userId,
                                      double threshold,
                                      int howMany)
                               throws App42Exception
User based neighborhood recommendations based on Threshold. Recommendations are found based on Threshold where thereshold represents similarity threshold where user are atleast that similar. Threshold values can vary from -1 to 1

Parameters:
userId - - The user Id for whom recommendations have to be found
threshold - - Threshold size. Values can vary from -1 to 1
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedThresholdBySimilarity

public Recommender userBasedThresholdBySimilarity(java.lang.String recommenderSimilarity,
                                                  long userId,
                                                  double threshold,
                                                  int howMany)
                                           throws App42Exception
User based neighbourhood recommendations based on Threshold. Recommendations are found based on Threshold where threshold represents similarity threshold where user are at least that similar. Threshold values can vary from -1 to 1

Parameters:
recommenderSimilarity - - Similarity algorithm e.g. Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION
userId - - The user Id for whom recommendations have to be found
threshold - - Threshold size. Values can vary from -1 to 1
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedThresholdBySimilarityForAll

public Recommender userBasedThresholdBySimilarityForAll(java.lang.String recommenderSimilarity,
                                                        double threshold,
                                                        int howMany)
                                                 throws App42Exception
User based neighbourhood recommendations based on Threshold for All. Recommendations are found based on Threshold where threshold represents similarity threshold where user are at least that similar. Threshold values can vary from -1 to 1

Parameters:
recommenderSimilarity - - Similarity algorithm e.g. Recommender.EUCLIDEAN_DISTANCE and Recommender.PEARSON_CORRELATION
threshold - - Threshold size. Values can vary from -1 to 1
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception

userBasedThresholdForAll

public Recommender userBasedThresholdForAll(double threshold,
                                            int howMany)
                                     throws App42Exception
User based neighbourhood recommendations based on Threshold for all Users. Recommendations are found based on Threshold where threshold represents similarity threshold where user are at least that similar. Threshold values can vary from -1 to 1

Parameters:
threshold - - Threshold size. Values can vary from -1 to 1
howMany - - Specifies that how many recommendations have to be found
Throws:
App42Exception