Accuracy

class rectools.metrics.classification.Accuracy(k: int)[source]

Bases: ClassificationMetric

Ratio of correctly recommended items among all items.

The accuracy@k equals to (tp + tn) / n_items where
  • tp is the number of relevant recommendations among the first k items in recommendation list;

  • tn is the number of items with which user has not interacted (bought, liked) with (in period after recommendations were given) and we do not recommend to him (in the top k items of recommendation list);

  • n_items - an overall number of items that could be used for recommendations.

Parameters

k (int) – Number of items at the top of recommendations list that will be used to calculate metric.

Inherited-members

Methods

calc(reco, interactions, catalog)

Calculate metric value.

calc_from_confusion_df(confusion_df, catalog)

Calculate metric value from prepared confusion matrix.

calc_per_user(reco, interactions, catalog)

Calculate metric values for all users.

calc_per_user_from_confusion_df(...)

Calculate metric values for all users from prepared confusion matrix.

Attributes