Class NDCG
- java.lang.Object
-
- es.upm.etsisi.cf4j.qualityMeasure.QualityMeasure
-
- es.upm.etsisi.cf4j.qualityMeasure.recommendation.NDCG
-
public class NDCG extends QualityMeasure
This class calculates the Normalized Discounted Cumulative Gain (nDCG) of the recommendations performed by a Recommender. It is calculated as follows:NDCG = <DCG> / <IDCG>
-
-
Field Summary
-
Fields inherited from class es.upm.etsisi.cf4j.qualityMeasure.QualityMeasure
recommender
-
-
Constructor Summary
Constructors Constructor Description NDCG(Recommender recommender, int numberOfRecommendations)
ConstructorNDCG(Recommender recommender, Map<String,Object> params)
Constructor from a Map object with the quality measure parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
dataCalculation(TestUser testUser, int[] elements)
Function to process de data in the NDCG algorithm.protected double
getScore(TestUser testUser, double[] predictions)
Computes the quality measure score for a TestUser given the predictions for his/her test ratings-
Methods inherited from class es.upm.etsisi.cf4j.qualityMeasure.QualityMeasure
getScore, getScore
-
-
-
-
Constructor Detail
-
NDCG
public NDCG(Recommender recommender, Map<String,Object> params)
Constructor from a Map object with the quality measure parameters. Map object must contains the following keys:- numberOfRecommendations: int value with the number of items to be recommended.
- Parameters:
recommender
- Recommender instance for which the NDCG are going to be computedparams
- Quality measure's parameters
-
NDCG
public NDCG(Recommender recommender, int numberOfRecommendations)
Constructor- Parameters:
recommender
- Recommender instance for which the nDCG are going to be computednumberOfRecommendations
- Number of recommendations
-
-
Method Detail
-
getScore
protected double getScore(TestUser testUser, double[] predictions)
Description copied from class:QualityMeasure
Computes the quality measure score for a TestUser given the predictions for his/her test ratings- Specified by:
getScore
in classQualityMeasure
- Parameters:
testUser
- TestUser for which the quality measure score is computedpredictions
- Prediction value for the test items rated by the test user- Returns:
- Quality measure score
-
dataCalculation
protected double dataCalculation(TestUser testUser, int[] elements)
Function to process de data in the NDCG algorithm. Extracted in order to dont repeat code.- Parameters:
testUser
- Related usedelements
- Recomendations or ideal recommendations- Returns:
- discounted cumulative gain
-
-