F1Beta
- class rectools.metrics.classification.F1Beta(k: int, beta: float = 1.0)[source]
Bases:
SimpleClassificationMetric
Fbeta score for k first recommendations. See more: https://en.wikipedia.org/wiki/F-score
The f1_beta equals to
(1 + beta_sqr) * p@k * r@k / (beta_sqr * p@k + r@k)
wherebeta_sqr equals to beta ** 2
- p@k: precision@k equals to
tp / k
where - -
tp
is the number of relevant recommendations among first
k
items in the top of recommendation list.
- -
- p@k: precision@k equals to
- r@k: recall@k equals to
tp / liked
where tp
is the number of relevant recommendationsamong first
k
items in the top of recommendation list;
liked
is the number of items the user has interacted(bought, liked) with (in period after recommendations were given).
- r@k: recall@k equals to
- Parameters
k (int) – Number of items in top of recommendations list that will be used to calculate metric.
beta (float) – Weight of recall. Default value: beta = 1.0
- Inherited-members
Methods
calc
(reco, interactions)Calculate metric value.
calc_from_confusion_df
(confusion_df)Calculate metric value from prepared confusion matrix.
calc_per_user
(reco, interactions)Calculate metric values for all users.
calc_per_user_from_confusion_df
(confusion_df)Calculate metric values for all users from prepared confusion matrix.
Attributes
beta