Accuracy Metrics - API Reference¶
Auto-generated documentation for accuracy metric classes.
warprec.evaluation.metrics.accuracy.auc.AUC
¶
Bases: BaseMetric
Computes Area Under the ROC Curve (AUC)
Attributes:
| Name | Type | Description |
|---|---|---|
total_area |
Tensor
|
The accumulated area under the curve. |
total_positives |
Tensor
|
The accumulated number of positive samples. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_items
|
int
|
Number of items in the training set. |
required |
*args
|
Any
|
The argument list. |
()
|
dist_sync_on_step
|
bool
|
Torchmetrics parameter. |
False
|
**kwargs
|
Any
|
The keyword argument dictionary. |
{}
|
Source code in warprec/evaluation/metrics/accuracy/auc.py
warprec.evaluation.metrics.accuracy.f1.F1
¶
Bases: TopKMetric
The F1@k metric combines precision and recall at k, providing a harmonic mean between the two to evaluate the relevance of the top-k recommended items.
Attributes:
| Name | Type | Description |
|---|---|---|
metric_instance_1 |
BaseMetric
|
First metric to use inside F1-score computation. |
metric_instance_2 |
BaseMetric
|
Second metric to use inside F1-score computation. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
int
|
The number of top recommendations to consider (cutoff). |
required |
num_users
|
int
|
Number of users in the training set. |
required |
num_items
|
int
|
Number of items in the training set. |
required |
*args
|
Any
|
Additional arguments to pass to the parent class. |
()
|
beta
|
float
|
The weight of recall in the harmonic mean. Default is 1.0. |
1.0
|
dist_sync_on_step
|
bool
|
Torchmetrics parameter. |
False
|
metric_1
|
str
|
The name of the first metric. Defaults to Precision. |
'Precision'
|
metric_2
|
str
|
The name of the second metric. Defaults to Recall. |
'Recall'
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the parent class. |
{}
|
Source code in warprec/evaluation/metrics/accuracy/f1.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
name
property
¶
The name of the metric customized based on the metrics compared.
compute()
¶
Computes the F1 score using the two custom metrics.
Source code in warprec/evaluation/metrics/accuracy/f1.py
update(preds, user_indices, **kwargs)
¶
Updates the metric state with the new batch of predictions.
Source code in warprec/evaluation/metrics/accuracy/f1.py
warprec.evaluation.metrics.accuracy.gauc.GAUC
¶
Bases: UserAverageTopKMetric
Computes Group Area Under the ROC Curve (GAUC) using the following approach:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_items
|
int
|
Number of items in the training set. |
required |
num_users
|
int
|
Number of users in the training set. |
required |
*args
|
Any
|
The argument list. |
()
|
dist_sync_on_step
|
bool
|
Torchmetrics parameter. |
False
|
**kwargs
|
Any
|
The keyword argument dictionary. |
{}
|
Source code in warprec/evaluation/metrics/accuracy/gauc.py
warprec.evaluation.metrics.accuracy.hit_rate.HitRate
¶
Bases: UserAverageTopKMetric
The HitRate@k metric counts the number of users for which the model retrieved at least one item.
Source code in warprec/evaluation/metrics/accuracy/hit_rate.py
warprec.evaluation.metrics.accuracy.lauc.LAUC
¶
Bases: UserAverageTopKMetric
Computes Limited Under the ROC Curve (LAUC) using the following approach:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
int
|
The cutoff. |
required |
num_users
|
int
|
Number of users in the training set. |
required |
num_items
|
int
|
Number of items in the training set. |
required |
*args
|
Any
|
The argument list. |
()
|
dist_sync_on_step
|
bool
|
Torchmetrics parameter. |
False
|
**kwargs
|
Any
|
The keyword argument dictionary. |
{}
|
Source code in warprec/evaluation/metrics/accuracy/lauc.py
warprec.evaluation.metrics.accuracy.map.MAP
¶
Bases: UserAverageTopKMetric
Mean Average Precision (MAP) at K.
Source code in warprec/evaluation/metrics/accuracy/map.py
warprec.evaluation.metrics.accuracy.mar.MAR
¶
Bases: UserAverageTopKMetric
Mean Average Recall (MAR) at K.
Source code in warprec/evaluation/metrics/accuracy/mar.py
warprec.evaluation.metrics.accuracy.mrr.MRR
¶
Bases: UserAverageTopKMetric
Mean Reciprocal Rank (MRR) at K. MRR measures the position of the first relevant item in the recommendation list.
Source code in warprec/evaluation/metrics/accuracy/mrr.py
warprec.evaluation.metrics.accuracy.ndcg.nDCG
¶
Bases: UserAverageTopKMetric
The nDCG@k metric is defined as the rapport of the DCG@k and the IDCG@k.
The DCG@k represent the Discounted Cumulative Gain, which measures the gain of the items retrieved.
The IDCG@k represent the Ideal Discounted Cumulative Gain, which measures the maximum gain possible obtainable by a perfect model.
Source code in warprec/evaluation/metrics/accuracy/ndcg.py
warprec.evaluation.metrics.accuracy.ndcg.nDCGRendle2020
¶
Bases: UserAverageTopKMetric
Normalized Discounted Cumulative Gain (nDCG) metric for evaluating recommender systems.
It measures the ranking quality by considering the position of relevant items, giving higher scores to relevant items that appear earlier in the recommendation list. This implementation calculates nDCG@k using binary relevance (0 or 1).
Source code in warprec/evaluation/metrics/accuracy/ndcg.py
warprec.evaluation.metrics.accuracy.precision.Precision
¶
Bases: UserAverageTopKMetric
The Precision@k counts the number of item retrieved correctly, over the maximum number of possible retrieve items.
Source code in warprec/evaluation/metrics/accuracy/precision.py
warprec.evaluation.metrics.accuracy.recall.Recall
¶
Bases: UserAverageTopKMetric
The Recall@k counts the number of item retrieve correctly, over the total number of relevant item in the ground truth.