Diversity Metrics - API Reference¶
Auto-generated documentation for diversity metric classes.
warprec.evaluation.metrics.diversity.gini_index.Gini
¶
Bases: TopKMetric
The Gini index metric measures the inequality in the distribution of recommended items, computed on a per-user basis and averaged over users. This implementation accounts for items that were never recommended by applying an offset.
Attributes:
| Name | Type | Description |
|---|---|---|
item_counts |
Tensor
|
Tensor to store the recommendation counts for each item. |
free_norm |
Tensor
|
Total number of recommendations made (accumulated per user). |
num_items |
int
|
Total number of items in the catalog, inferred from the prediction tensor. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
int
|
The cutoff for recommendations. |
required |
num_items
|
int
|
Number of items in the training set. |
required |
dist_sync_on_step
|
bool
|
Torchmetrics parameter. |
False
|
**kwargs
|
Any
|
The keyword argument dictionary. |
{}
|
Source code in warprec/evaluation/metrics/diversity/gini_index.py
warprec.evaluation.metrics.diversity.shannon_entropy.ShannonEntropy
¶
Bases: TopKMetric
Shannon Entropy measures the diversity of recommendations by calculating the information entropy over item recommendation frequencies.
Attributes:
| Name | Type | Description |
|---|---|---|
item_counts |
Tensor
|
Cumulative count of each item's recommendations |
users |
Tensor
|
Total number of users evaluated |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
int
|
Recommendation list cutoff |
required |
num_items
|
int
|
Number of items in the training set. |
required |
dist_sync_on_step
|
bool
|
Torchmetrics parameter. |
False
|
**kwargs
|
Any
|
The keyword argument dictionary. |
{}
|
Source code in warprec/evaluation/metrics/diversity/shannon_entropy.py
warprec.evaluation.metrics.diversity.srecall.SRecall
¶
Bases: UserAverageTopKMetric
Subtopic Recall (SRecall) metric for evaluating recommender systems.
It measures the proportion of a user's relevant features (or subtopics) that are present among the top-k recommended items. A higher value indicates that the recommendations cover a wider variety of the user's interests (features/subtopics).
Attributes:
| Name | Type | Description |
|---|---|---|
feature_lookup |
Tensor
|
The item feature lookup tensor. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
int
|
The cutoff for recommendations. |
required |
num_users
|
int
|
Number of users in the training set. |
required |
feature_lookup
|
Tensor
|
A tensor containing the features associated with each item. Tensor shape is expected to be [num_items, num_features]. |
required |
dist_sync_on_step
|
bool
|
Torchmetrics parameter for distributed synchronization. Defaults to |
False
|
**kwargs
|
Any
|
Additional keyword arguments dictionary. |
{}
|
Source code in warprec/evaluation/metrics/diversity/srecall.py
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 | |