SufficientReco
- class rectools.metrics.dq.SufficientReco(k: int, deep: bool = False)[source]
Bases:
_RecoDQMetricAbsence of empty rows in recommendations table when k recommendations are required for each user. This metric helps to identify situations when recommendation lists are not fully filled. Specify deep=False to calculate share of users with sufficient recommendations at first k positions. Specify deep=True to calculate average share of filled rows for each user at first k positions.
- Parameters
k (int) – Number required recommendations for each user 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 with sufficient recommendations 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, 2, 3, 1, 2, 3, 4, 5], ... Columns.Rank: [1, 2, 1, 2, 3, 1, 2, 3, 4, 5], ... } ... ) >>> SufficientReco(k=1).calc_per_user(reco).values array([1, 1, 1]) >>> SufficientReco(k=4).calc_per_user(reco).values array([0, 0, 1]) >>> SufficientReco(k=4, deep=True).calc_per_user(reco).values array([0.5 , 0.75, 1. ])
- Inherited-members
- Parameters
k (int) –
deep (bool) –
Methods
calc(reco)Calculate metric value.
calc_per_user(reco)Calculate metric values for all users.
Attributes