HitRate

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

Bases: SimpleClassificationMetric

HitRate calculates the fraction of users for which the correct answer is included in the recommendation list.

The HitRate equals to 1 if tp > 0, otherwise 0 where
  • tp is the number of relevant recommendations among the first k items in recommendation list.

Parameters

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

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