MCC

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

Bases: ClassificationMetric

Matthew correlation coefficient calculates correlation between actual and predicted classification. Min value = -1 (negative correlation), Max value = 1 (positive correlation), zero means no correlation See more: https://en.wikipedia.org/wiki/Phi_coefficient

The MCC equals to (tp * tn - fp * fn) / sqrt((tp + fp)(tp + fn)(tn + fp)(tn + fn)) 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);

  • fp - number of non-relevant recommendations among the first k items of recommendation list;

  • fn - number of items the user has interacted with but that weren’t recommended (in top-k).

Parameters

k (int) – Number of items in 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