App42 Cloud API

Windows Phone Cloud SDK

Recommendation

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

In order to use the various functions available under a particular API, a developer will have to create an instance of ServiceAPI by passing the apiKey and the secretKey which has been received while creating an app.

ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>");          

After initialization, developer needs to call the BuildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of RecommenderService, BuildRecomenderService() method needs to be called.

RecommenderService recommenderSevice = api.BuildRecommenderService();

Once the API instance has been retrieved, You are ready to use the functions available for that particular API.

The Windows Phone API's work in an asynchronous mode that means the response will not be available immediately and all the API methods would not return any value and have return type as void. The response will be returned in callback methods which the caller will provide to the calling method.
As mentioned above that the response will be returned in callback methods, every API method is taking instance of App42Callback (as the last parameter) which will have the implementation of 2 methods: OnSuccess & OnException.(as shown below)

public class CallBack : App42Callback
{
public override void OnSuccess(Object obj)
{
Recommender recommender = (Recommender) obj;
//Do whatever you want with the user object
}
public override void OnException(App42Exception e)
{
//Do whatever you want with the exception
}
}

The callback methods will return the response in the form of Object which will have to be type cast to the object domain object (e.g. App42Response / Recommender in this case) The Domain object have the accessor / mutator to access the available properties for that object. You can get the response in the form of JSON as well. We have provided the JSON response with every function detail which can be retrieved by calling the ToString() on the returned object.

public override void OnSuccess(Object obj)
{		
Recommender recommender = (Recommender) obj; 
String recommendedItemList =  recommender.GetRecommendedItemList(); 
String jsonResponse = recommender.ToString(); /* returns the response in JSON format. */
}

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

public override void OnException(App42Exception ex)
{
int appErrorCode = ex.GetAppErrorCode();
int httpErrorCode = ex.GetHttpErrorCode();
String jsonText = ex.GetMessage(); /* returns the Exception text in JSON format. (as shown below)*/	
} 
	{
		"app42Fault": {
			"httpErrorCode": 404,
			"appErrorCode": 2805,
			"message": "Bad Request",
			"details": "Preference Data is not valid"
		}
	}							

Below are the HTTP Error Codes and their description, the function under the Recommendation API can throw.

/*
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again
*/							

Below are the Application Error Codes and their description, the function under the Recommendation API can throw.

/*
2800 - NOT FOUND - Preferences does not exist. 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: '<e.getMessage()>'.
2803 - NOT FOUND - There are no recommendations for optimize values for 'threshold' and 'howMany'.	
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId '<e.getMessage()>'.
2805 - BAD REQUEST - Preference Data is not valid.
*/					

Various functions available under Recommendation API has been explained below.

public void LoadPreferenceFile(Stream stream , App42Callback requestCallback)

Uploads peference file on the cloud. 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:

stream - Sequence of bytes of the preference file to be loaded
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

The uploaded preference file details.

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2805 - BAD REQUEST - Preference Data is not valid.
*/ 	       
For more details click Exception
Stream stream = "file stream";
						
recommenderService.LoadPreferenceFile(stream,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
String jsonResponse = recommender.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true
        }
    }
}  
 
public void UserBasedNeighborhood(Double userId, int size, int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/ 	 	        
For more details click Exception
long userId = 3;
int size = 4567788 ;
int howMany = 2;

recommenderService.UserBasedNeighborhood(userId, size, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj)
{
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "item": 106,
                        "value": 4
                    },
                    {
                        "item": 103,
                        "value": 2.5905366
                    }
                ]
            }
        }
    }
}
public void UserBasedThreshold(Double userId, Double threshold, int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2803 - NOT FOUND - There are no recommendations for optimize values for 'threshold' and 'howMany'.	
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/  		        
For more details click Exception
long userId = 1;
double threshold = 0.5;
int howMany = 2;	

recommenderService.UserBasedThreshold(userId, threshold, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "item": 104,
                        "value": 4.257081
                    },
                    {
                        "item": 106,
                        "value": 4
                    }
                ]
            }
        }
    }
}
public void UserBasedNeighborhoodBySimilarity(String recommenderSimilarity, Double userId, int size, int howMany, App42Callback requestCallback)

User based recommendations based on Neighborhood and Similarity. Recommendations and found based on the similar users in the Neighborhood with the specified Similarity Algorithm. Algorithim 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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/		        
For more details click Exception
String recommenderSimilarity = RecommenderSimilarity.EUCLIDEAN_DISTANCE;		
long userId = 1;
int size = 2;
int howMany = 2;	

recommenderService.UserBasedNeighborhoodBySimilarity(recommenderSimilarity,userId, size, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "item": 104,
                        "value": 4.25
                    },
                    {
                        "item": 106,
                        "value": 4
                    }
                ]
            }
        }
    }
}
public void UserBasedThresholdBySimilarity(String recommenderSimilarity, Double userId, Double threshold, int howMany, App42Callback requestCallback)

User based neighborood 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:

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2803 - NOT FOUND - There are no recommendations for optimize values for 'threshold' and 'howMany'.	
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/
For more details click Exception
String recommenderSimilarity = RecommenderSimilarity.EUCLIDEAN_DISTANCE;
long userId = 1;
double threshold = 0.5;
int howMany = 1;

recommenderService.UserBasedThresholdBySimilarity(recommenderSimilarity, userId, threshold, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
	for(int i = 0; i < recommendedItemList.Count; i++)
	{
		Console.WriteLine("item is " + recommendedItemList[i].GetItem());
		Console.WriteLine("value is " + recommendedItemList[i].GetValue());
	}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": {
                    "item": 106,
                    "value": 4
                }
            }
        }
    }
}
public void ItemBased(Double userId, int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/ 		       
For more details click Exception
long userId = 1;
int howMany = 1;

recommenderService.ItemBased(preferenceFileName, userId, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj)
{
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": {
                    "item": 104,
                    "value": 5
                }
            }
        }
    }
}
public void ItemBasedBySimilarity(RecommenderSimilarity recommenderSimilarity,long userId, int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/ 		       
For more details click Exception
String recommenderSimilarity = RecommenderSimilarity.EUCLIDEAN_DISTANCE;
long userId = 1;
int howMany = 1;

recommenderService.ItemBasedBySimilarity(recommenderSimilarity, userId, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": {
                    "item": 107,
                    "value": 5
                }
            }
        }
    }
}
public void ItemBasedBySimilarityForAll(RecommenderSimilarity recommenderSimilarity,int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object for all users

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/ 			        
For more details click Exception
String recommenderSimilarity = RecommenderSimilarity.EUCLIDEAN_DISTANCE;
int howMany = 5;

recommenderService.ItemBasedBySimilarityForAll(recommenderSimilarity,howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
	for(int i = 0; i < recommendedItemList.Count; i++)
	{
		Console.WriteLine("user Id is " + recommendedItemList[i].GetUserId());
		Console.WriteLine("item is " + recommendedItemList[i].GetItem());
		Console.WriteLine("value is " + recommendedItemList[i].GetValue());
	}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "userId": 1,
                        "item": 107,
                        "value": 5
                    },
                    {
                        "userId": 2,
                        "item": 106,
                        "value": 2.6748168
                    },
                    {
                        "userId": 3,
                        "item": 102,
                        "value": 3.5901134
                    },
                    {
                        "userId": 4,
                        "item": 107,
                        "value": 4.681818
                    },
                    {
                        "userId": 5,
                        "item": 107,
                        "value": 3.7704918
                    }
                ]
            }
        }
    }
}
public void SlopeOne(long userId, int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'  
2803 - BAD REQUEST - There are no recommendations for optimize values for 'threshold' and 'howMany'. 
*/ 		        
For more details click Exception
long userId = 1;
int howMany = 1;
						
recommenderService.SlopeOne(userId, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
} 
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": {
                    "item": 105,
                    "value": 5.75
                }
            }
        }
    }
}
public void UserBasedNeighborhoodForAll( int size, int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object for all users

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/	        
For more details click Exception
int size = 1;
int howMany = 1;

recommenderService.UserBasedNeighborhoodForAll(size, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Objcet obj){
Recommender recommender = (Recommender) obj;
App42Response response = (App42Response) recommender;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "userId": 1,
                        "item": 104,
                        "value": 4.257081
                    },
                    {
                        "userId": 3,
                        "item": 106,
                        "value": 4
                    },
                    {
                        "userId": 4,
                        "item": 102,
                        "value": 3
                    }
                ]
            }
        }
    }
}
public void UserBasedThresholdForAll( Double threshold, int howMany, App42Callback requestCallback)

User based neighborood recommendations based on Threshold for all Users. 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:

threshold - Threshold size. Values can vary from -1 to 1
howMany - Specifies that how many recommendations have to be found
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object for all users

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/		        
For more details click Exception
double threshold = 1;
int howMany = 3;

recommenderService.UserBasedThresholdForAll(threshold, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Objcet obj){
Recommender recommender = (Recommender) obj;
App42Response response = (App42Response) recommender;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "userId": 1,
                        "item": 104,
                        "value": 4.257081
                    },
                    {
                        "userId": 3,
                        "item": 106,
                        "value": 4
                    },
                    {
                        "userId": 4,
                        "item": 102,
                        "value": 3
                    }
                ]
            }
        }
    }
}
public void UserBasedNeighborhoodBySimilarityForAll(String recommenderSimilarity, int size, int howMany, App42Callback requestCallback)

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. Algorithim 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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object for all users

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/ 	        
For more details click Exception
String recommenderSimilarity = RecommenderSimilarity.EUCLIDEAN_DISTANCE;
int size = 2;
int howMany = 3;

recommenderService.UserBasedNeighborhoodBySimilarityForAll(recommenderSimilarity, size, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("user Id is " + recommendedItemList[i].GetUserId());
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "userId": 1,
                        "item": 104,
                        "value": 4.257081
                    },
                    {
                        "userId": 3,
                        "item": 106,
                        "value": 4
                    },
                    {
                        "userId": 4,
                        "item": 102,
                        "value": 3
                    }
                ]
            }
        }
    }
}
public void UserBasedThresholdBySimilarityForAll(String recommenderSimilarity, Double threshold, int howMany, App42Callback requestCallback)

User based neighborood recommendations based on Threshold for All. 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:

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object for all

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/		        
For more details click Exception
String recommenderSimilarity = RecommenderSimilarity.EUCLIDEAN_DISTANCE;
double threshold = 0.5;
int howMany = 4;

recommenderService.UserBasedThresholdBySimilarityForAll(recommenderSimilarity, threshold, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("user Id is " + recommendedItemList[i].GetUserId());
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "userId": 1,
                        "item": 106,
                        "value": 4
                    },
                    {
                        "userId": 2,
                        "item": 106,
                        "value": 4
                    },
                    {
                        "userId": 3,
                        "item": 106,
                        "value": 4
                    },
                    {
                        "userId": 4,
                        "item": 105,
                        "value": 3.860392
                    }
                ]
            }
        }
    }
}
public void ItemBasedForAll(int howMany, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommender Object for all users

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/ 		        
For more details click Exception
int howMany = 3;
						
recommenderService.ItemBasedForAll(howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("user Id is " + recommendedItemList[i].GetUserId());
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "userId": 1,
                        "item": 104,
                        "value": 5
                    },
                    {
                        "userId": 3,
                        "item": 103,
                        "value": 3.2766466
                    },
                    {
                        "userId": 4,
                        "item": 102,
                        "value": 5
                    }
                ]
            }
        }
    }
}
public void SlopeOneForAll(int howMany, App42Callback requestCallback)

Recommendations based on SlopeOne Algorithm for all Users.

Parameters:

howMany - Specifies that how many recommendations have to be found
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Recommendations for all Users

Response: Recommender Object

Exception:

This method throws following exception.
/* 
2801 - NOT FOUND - There are no recommendations for optimize values for 'size' and 'howMany'. 
2802 - BAD REQUEST - InvalidArgumentException: <e.getMessage()>.
2804 - BAD REQUEST - InvalidArgumentException: NoSuchUserException : UserId <e.getMessage()>.
*/		        
For more details click Exception
int howMany = 4;
						
recommenderService.SlopeOneForAll(preferenceFileName, howMany,requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Object obj){
Recommender recommender = (Recommender) obj;
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
Console.WriteLine("item is " + recommendedItemList[i].GetItem());
Console.WriteLine("value is " + recommendedItemList[i].GetValue());
}
String jsonResponse = recommendedItemList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": [
                    {
                        "userId": 1,
                        "item": 105,
                        "value": 5.75
                    },
                    {
                        "userId": 2,
                        "item": 106,
                        "value": 3.1298585
                    },
                    {
                        "userId": 3,
                        "item": 106,
                        "value": 2.976076
                    },
                    {
                        "userId": 4,
                        "item": 105,
                        "value": 4.976859
                    }
                ]
            }
        }
    }
}
public void deleteAllPreferences(App42Callback requestCallback)

Delete existing preference file.

Parameters:

requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

This method throws following exception.
/* 
2800 - NOT FOUND - Preferences does not exist.
*/		        
For more details click Exception
recommenderService.deleteAllPreferences(requestCallback);  /* returns the Recommender object. */ 
OnSuccess(Objcet obj)
{
Recommender recommender = (Recommender) obj;
App42Response response = (App42Response) recommender;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
 {
   "app42": {
       "response": {
           "success": true
       }
   }
}