UnrepeatedReco
- class rectools.metrics.dq.UnrepeatedReco(k: int, deep: bool = False)[source]
Bases:
_RecoDQMetricUnrepeated items recommended to the same user in recommendations table. This metrics help to identify situations when recommendation lists have duplicated items for same users. Specify deep=False to calculate share of user without any duplicated itemd at first k positions. Specify deep=True to calculate average share of unrepeated items for each user at first k positions.
- Parameters
k (int) – Number of items at the top of recommendations list that will be used to calculate metric.
deep (bool, default False) – Whether to calculated detailed value of the metric for each user. Otherwise just the share of users without identified problem will be returned (this is the default behaviour).
Examples
>>> reco = pd.DataFrame( ... { ... Columns.User: [1, 1, 2, 2, 2, 3, 3, 3, 3, 3], ... Columns.Item: [1, 2, 1, 1, 3, 1, 2, 2, 1, 5], ... Columns.Rank: [1, 2, 1, 2, 3, 1, 2, 3, 4, 5], ... } ... ) >>> UnrepeatedReco(k=1).calc_per_user(reco).values array([1, 1, 1]) >>> UnrepeatedReco(k=4).calc_per_user(reco).values array([1, 0, 0]) >>> UnrepeatedReco(k=4, deep=True).calc_per_user(reco).values array([1. , 0.66666667, 0.5 ])
- Inherited-members
- Parameters
k (int) –
deep (bool) –
Methods
calc(reco)Calculate metric value.
calc_per_user(reco)Calculate metric values for all users.
Attributes