elliot.evaluation.metrics.accuracy.ndcg package¶
Submodules¶
elliot.evaluation.metrics.accuracy.ndcg.ndcg module¶
This is the implementation of the normalized Discounted Cumulative Gain metric. It proceeds from a user-wise computation, and average the values over the users.
-
class
elliot.evaluation.metrics.accuracy.ndcg.ndcg.
nDCG
(recommendations, config, params, eval_objects)[source]¶ Bases:
elliot.evaluation.metrics.base_metric.BaseMetric
normalized Discounted Cumulative Gain
This class represents the implementation of the nDCG recommendation metric.
For further details, please refer to the link
\[\begin{split}\begin{gather} \mathrm {DCG@K}=\sum_{i=1}^{K} \frac{2^{rel_i}-1}{\log_{2}{(i+1)}}\\ \mathrm {IDCG@K}=\sum_{i=1}^{K}\frac{1}{\log_{2}{(i+1)}}\\ \mathrm {NDCG_u@K}=\frac{DCG_u@K}{IDCG_u@K}\\ \mathrm {NDCG@K}=\frac{\sum \nolimits_{u \in u^{te}NDCG_u@K}}{|u^{te}|} \end{gather}\end{split}\]\(K\) stands for recommending \(K\) items.
And the \(rel_i\) is the relevance of the item in position \(i\) in the recommendation list.
\(2^{rel_i}\) equals to 1 if the item hits otherwise 0.
\(U^{te}\) is for all users in the test set.
To compute the metric, add it to the config file adopting the following pattern:
simple_metrics: [nDCG]
-
compute_idcg
(user, cutoff: int) → float[source]¶ Method to compute Ideal Discounted Cumulative Gain :param gain_map: :param cutoff: :return:
-
compute_user_ndcg
(user_recommendations: List, user, cutoff: int) → float[source]¶ Method to compute normalized Discounted Cumulative Gain :param sorted_item_predictions: :param gain_map: :param cutoff: :return:
-
Module contents¶
This is the nDCG metric module.
This module contains and expose the recommendation metric.
elliot.evaluation.metrics.accuracy.ndcg.ndcg_rendle2020 module¶
This is the implementation of the normalized Discounted Cumulative Gain metric. It proceeds from a user-wise computation, and average the values over the users.
-
class
elliot.evaluation.metrics.accuracy.ndcg.ndcg_rendle2020.
nDCGRendle2020
(recommendations, config, params, eval_objects)[source]¶ Bases:
elliot.evaluation.metrics.base_metric.BaseMetric
normalized Discounted Cumulative Gain
This class represents the implementation of the nDCG recommendation metric.
For further details, please refer to the link
\[\begin{split}\begin{gather} \mathrm {DCG@K}=\sum_{i=1}^{K} \frac{2^{rel_i}-1}{\log_{2}{(i+1)}}\\ \mathrm {IDCG@K}=\sum_{i=1}^{K}\frac{1}{\log_{2}{(i+1)}}\\ \mathrm {NDCG_u@K}=\frac{DCG_u@K}{IDCG_u@K}\\ \mathrm {NDCG@K}=\frac{\sum \nolimits_{u \in u^{te}NDCG_u@K}}{|u^{te}|} \end{gather}\end{split}\]\(K\) stands for recommending \(K\) items.
And the \(rel_i\) is the relevance of the item in position \(i\) in the recommendation list.
\(2^{rel_i}\) equals to 1 if the item hits otherwise 0.
\(U^{te}\) is for all users in the test set.
To compute the metric, add it to the config file adopting the following pattern:
simple_metrics: [nDCG]
Module contents¶
This is the implementation of the normalized Discounted Cumulative Gain metric. It proceeds from a user-wise computation, and average the values over the users.
-
class
elliot.evaluation.metrics.accuracy.ndcg.ndcg_rendle2020.
nDCGRendle2020
(recommendations, config, params, eval_objects)[source]¶ Bases:
elliot.evaluation.metrics.base_metric.BaseMetric
normalized Discounted Cumulative Gain
This class represents the implementation of the nDCG recommendation metric.
For further details, please refer to the link
\[\begin{split}\begin{gather} \mathrm {DCG@K}=\sum_{i=1}^{K} \frac{2^{rel_i}-1}{\log_{2}{(i+1)}}\\ \mathrm {IDCG@K}=\sum_{i=1}^{K}\frac{1}{\log_{2}{(i+1)}}\\ \mathrm {NDCG_u@K}=\frac{DCG_u@K}{IDCG_u@K}\\ \mathrm {NDCG@K}=\frac{\sum \nolimits_{u \in u^{te}NDCG_u@K}}{|u^{te}|} \end{gather}\end{split}\]\(K\) stands for recommending \(K\) items.
And the \(rel_i\) is the relevance of the item in position \(i\) in the recommendation list.
\(2^{rel_i}\) equals to 1 if the item hits otherwise 0.
\(U^{te}\) is for all users in the test set.
To compute the metric, add it to the config file adopting the following pattern:
simple_metrics: [nDCG]