Recommendation Service

Recommendation engine which provides recommendation based on customer id, item id and the preference of the customer for a particular Item. Recommendations can be fetched based on User Similarity i.e. It 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(Double userId, int howMany) it uses PearsonCorrelationSimilarity. In the method ItemBasedBySimilarity(String similarity,Double 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 preferenceFilePath) in csv format. This preference file has to be uploaded once which can be a batch process.

The Customer Id and Item id can be any alphanumeric 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.

Initialize

In order to use various the functions available in a specific API, a developer has to initialize with App42API by passing the apiKey and secretKey which will be created after the app creation from AppHQ dashboard.

Required Parameters

apiKey - The Application key given when the application was created.
secretKey - The secret key corresponding to the application key given when the application was created.

Build Service

After initialization, developer needs to call the buildXXXService method on App42API to get the instance of the particular API that you wish to build. For example, To build an instance of Recommender Service, buildRecommenderService() method needs to be called.

Load Prefrence File

Uploads preference file on the cloud. The preference file should be in CSV format. This preference 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 alphanumeric 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.

Load Prefrence File With Inputstream

Uploads preference file on the cloud. The preference file should be in CSV format. This preference 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 alphanumeric 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.

User Based Neighbourhood By Similarity

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.

Required 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.

User Based Neighbourhood By Similarity For All

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

Required 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.

User Based Threshold

User based neighborhood 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.

Required 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.

User Based Threshold For All

User based neighborhood 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.

Required Parameters

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

User Based Threshold By Similarity

User based neighborhood 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.

Required 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.

User Based Threshold By Similarity For All

User based neighborhood 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.

Required 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.

Item Based By Similarity

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.

Required 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.

Exception Handling

The functions available under Recommendation API can throw some exceptions in abnormal conditions. Example of the same has been given below.
E.g. If App developer is uploading the Preference File which does not have any data, the loadPreferenceFile function will throw the App42Exception (as shown below) with message as “Bad Request” and the appErrorCode as “2805” and the details as “Preference Data is not valid.”