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

    • 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 computed
        params - Quality measure's parameters
      • NDCG

        public NDCG​(Recommender recommender,
                    int numberOfRecommendations)
        Constructor
        Parameters:
        recommender - Recommender instance for which the nDCG are going to be computed
        numberOfRecommendations - 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 class QualityMeasure
        Parameters:
        testUser - TestUser for which the quality measure score is computed
        predictions - 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 used
        elements - Recomendations or ideal recommendations
        Returns:
        discounted cumulative gain