App42 Cloud API

C# 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(Int64 userId, int howMany) it uses PearsonCorrelationSimilarity. In the method ItemBasedBySimilarity(String similarity, Int64 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 methods available under a particular API will return the domain object (like LoadPreference in this case) as a response which will 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.

String preferenceFilePath = "Local file path";

App42Response response = recommenderService.LoadPreferenceFile(preferenceFilePath);  /* returns the App42Response  object. */ 
Boolean  success = response.IsResponseSuccess();  
String jsonResponse = response.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."

preferenceFilePath = "Local file path";

try
{
	Recommender recommender = recommenderService.LoadPreferenceFile(preferenceFilePath);
} 
catch(App42Exception ex) 
{
	int appErrorCode = ex.GetAppErrorCode();
	int httpErrorCode = ex.GetHttpErrorCode();
	if(appErrorCode == 2805)
    {
    // Handle here for Bad Request (Preference Data is not valid.)
    }
    else if(appErrorCode == 1401)
	{
    // handle here for Client is not authorized
    }
    else if(appErrorCode == 1500)
	{
    // handle here for Internal Server Error
    }
	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 App42Response LoadPreferenceFile(String name, String preferenceFilePath, String description)

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:

preferenceFilePath - Path of the preference file to be loaded

Returns:

The uploaded preference file details.

Response: App42Response Object

Exception:

The method throws the following exception with the error code.
/* 
2805 - BAD REQUEST - Preference Data is not valid.
*/ 	       
For more details click Exception
String preferenceFilePath = "Local file path";

App42Response response = recommenderService.LoadPreferenceFile(preferenceFilePath);  /* returns the App42Response  object. */ 
Boolean  success = response.IsResponseSuccess();  
String jsonResponse = response.ToString() /* returns the response in JSON format. */  	 
{
    "app42": {
        "response": {
            "success": true
        }
    }
} 
public App42Response LoadPreferenceFile(Stream stream)

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 - InputStream of the file to be load.

Returns:

The uploaded preference file details.

Response: App42Response Object

Exception:

The method throws the following exception with the error code.
/* 
2805 - BAD REQUEST - Preference Data is not valid.
*/ 	       
For more details click Exception
String preferenceFilePath = "Local file path";
Stream stream = new FileStream(preferenceFilePath,FileMode.Open);

App42Response response = recommenderService.LoadPreferenceFile(stream);  /* returns the App42Response  object. */ 
Boolean  success = response.isResponseSuccess();  
String jsonResponse = response.ToString() /* returns the response in JSON format. (as shown below)*/   
{
    "app42": {
        "response": {
            "success": true
        }
    }
} 
public Recommender UserBasedNeighborhood( Int64 userId, int size, int howMany)

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

Returns:

Recommendations

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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
Int64 userId = 3;
int size = 4567788 ;
int howMany = 2;

Recommender recommender = recommenderService.UserBasedNeighborhood(userId, size, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender UserBasedThreshold(Int64 userId, Double threshold, int howMany)

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:

peferenceFileName - Name of the Preference File based on which recommendations have to be found
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

Returns:

Recommendations

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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
Int64 userId = 1;
Double threshold = 0.5;
int howMany = 2;	

Recommender recommender = recommenderService.UserBasedThreshold(userId, threshold, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender UserBasedNeighborhoodBySimilarity(String recommenderSimilarity, Int64 userId, int size, int howMany)

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

Returns:

Recommendations

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;		
Int64 userId = 1;
int size = 2;
int howMany = 2;		

Recommender recommender = recommenderService.UserBasedNeighborhoodBySimilarity(recommenderSimilarity, userId, size, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
    Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender UserBasedThresholdBySimilarity(String recommenderSimilarity, String preferenceFileName, Int64 userId, Double threshold, int howMany)

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

Returns:

Recommendations

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;
Int64 userId = 1;
Double threshold = 0.5;
int howMany = 1;

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

Item based recommendations. Recommendations and found based item similarity of the given user. The size of the neighborhood can be found.

Parameters:

peferenceFileName - Name of the Preference File based on which recommendations have to be found
userId - The user Id for whom recommendations have to be found
howMany - Specifies that how many recommendations have to be found

Returns:

Recommendations

Response: Recommender Object

Exception:

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

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

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

Returns:

Recommendations

Response: Recommender Object

Exception:

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

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

Recommendations based on SlopeOne Algorithm.

Parameters:

peferenceFileName - Name of the Preference File based on which recommendations have to be found
userId - The user Id for whom recommendations have to be found
howMany - Specifies that how many recommendations have to be found

Returns:

Recommendations

Response: Recommender Object

Exception:

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

Recommender recommender = recommenderService.SlopeOne(userId, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.ToString(); /* returns the response in JSON format. (as shown below)*/   
{
    "app42": {
        "response": {
            "success": true,
            "recommender": {
                "recommended": {
                    "item": 105,
                    "value": 5.75
                }
            }
        }
    }
}
public Recommender UserBasedNeighborhoodForAll(int size, int howMany)

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

Returns:

Recommender Object for all users

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;		
						
Recommender recommender = recommenderService.UserBasedNeighborhoodForAll(size, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("userId is " + recommendedItemList[0].GetUserId());
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender UserBasedThresholdForAll(Double threshold, int howMany)

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

Returns:

Recommendations for all Users

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/*
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;
						
Recommender recommender = recommenderService.UserBasedThresholdForAll(threshold, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("userId is " + recommendedItemList[0].GetUserId());
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender UserBasedNeighborhoodBySimilarityForAll(String recommenderSimilarity, int size, int howMany)

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

Returns:

Recommendations for all Users

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;		
				
Recommender recommender = recommenderService.UserBasedNeighborhoodBySimilarityForAll(recommenderSimilarity, size, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("userId is " + recommendedItemList[0].GetUserId());
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender UserBasedThresholdBySimilarityForAll(String recommenderSimilarity, Double threshold, int howMany)

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

Returns:

Recommendations for All

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;

Recommender recommender = recommenderService.UserBasedThresholdBySimilarityForAll(recommenderSimilarity, threshold, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("userId is " + recommendedItemList[0].GetUserId());
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender ItemBasedForAll(int howMany)

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

Returns:

Recommendations for all Users

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;					
String recommenderSimilarity = RecommenderSimilarity.EUCLIDEAN_DISTANCE;
int howMany = 5;

Recommender recommender = recommenderService.ItemBasedForAll(howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("userId is " + recommendedItemList[0].GetUserId());
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
} 
String jsonResponse = recommender.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 Recommender ItemBasedBySimilarityForAll(String recommenderSimilarity,int howMany)

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

Returns:

Recommendations for all Users

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;

Recommender recommender = recommenderService.ItemBasedBySimilarityForAll(recommenderSimilarity, howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("userId is " + recommendedItemList[0].GetUserId());
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 Recommender SlopeOneForAll(int howMany)

Recommendations based on SlopeOne Algorithm for all Users.

Parameters:

howMany - Specifies that how many recommendations have to be found

Returns:

Recommendations for all Users

Response: Recommender Object

Exception:

The method throws the following exception with the error code.
/* 
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;

Recommender recommender = recommenderService.SlopeOneForAll(howMany);  /* returns the Recommender object. */ 
IList<Recommender.RecommendedItem> recommendedItemList =  recommender.GetRecommendedItemList(); 
for(int i = 0; i < recommendedItemList.Count; i++)
{
	Console.WriteLine("userId is " + recommendedItemList[0].GetUserId());
	Console.WriteLine("item is " + recommendedItemList[0].GetItem());
	Console.WriteLine("value is " + recommendedItemList[0].GetValue());
}
String jsonResponse = recommender.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 App42Response DeleteAllPreferences(String name)

Delete existing preference file.

Parameters:

N/A

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

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