make_confusions
- rectools.metrics.classification.make_confusions(reco: DataFrame, interactions: DataFrame, k: int) DataFrame [source]
Calculate some intermediate metrics from raw data (it’s a helper function).
- For each user the following metrics are calculated:
LIKED - number of items the user has interacted (bought, liked) with;
TP - number of relevant recommendations among the first k items at the top 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
reco (pd.DataFrame) – Recommendations table with columns Columns.User, Columns.Item, Columns.Rank.
interactions (pd.DataFrame) – Interactions table with columns Columns.User, Columns.Item.
k (int) – Number of items at the top of recommendations list that will be used to calculate metric.
- Returns
Table with columns: Columns.User, LIKED, TP, FP, FN.
- Return type
pd.DataFrame