PopularModel
- class rectools.models.popular.PopularModel(popularity: str = 'n_users', period: Optional[timedelta] = None, begin_from: Optional[datetime] = None, add_cold: bool = False, inverse: bool = False, verbose: int = 0)[source]
Bases:
FixedColdRecoModelMixin
,ModelBase
Model generating recommendations based on popularity of items.
- Parameters
popularity ({“n_users”, “n_interactions”, “mean_weight”, “sum_weight”}, default “n_users”) – Method of calculating item popularity. To evaluate popularity score the following methods are available: - n_users - number of unique users that interacted with item; - n_interactions - number of interactions with item; - mean_weight - mean item interactions weight; - sum_weight - total item interactions weight.
period (timedelta, optional, default
None
) – Period before last interaction to consider interactions for popularity calculation. Either period or begin_from can be set at once. If both areNone
all interactions will be used.begin_from (datetime, optional, default
None
) – Exact datetime to consider interactions from for popularity calculation. Either period or begin_from can be set at once. If both areNone
all interactions will be used.add_cold (bool, default
False
) – IfTrue
cold items will be added to the end of popularity list and can be recommended. Item is cold if it’s not present in interactions at all (but present in id map) or not present in last interactions defined by either period or begin_from arguments. Order of cold items is unpredictable. Cold items score will be equal to0
.inverse (bool, default
False
) – IfTrue
least popular items will be selected.verbose (int, default
0
) – Degree of verbose output. If0
, no output will be provided.
- Inherited-members
Methods
fit
(dataset, *args, **kwargs)Fit model.
recommend
(users, dataset, k, filter_viewed)Recommend items for users.
recommend_to_items
(target_items, dataset, k)Recommend items for target items.
Attributes
recommends_for_cold
recommends_for_warm