lenskit.basic.popularity#

Classes

PopScorer([score_method])

Score items by their popularity.

TimeBoundedPopScore(cutoff[, score_method])

Score items by their time-bounded popularity, i.e., the popularity in the most recent time_window period.

class lenskit.basic.popularity.PopScorer(score_method='quantile')#

Bases: Component, Trainable

Score items by their popularity. Use with TopN to get a most-popular-items recommender.

Parameters:
  • score_type

    The method for computing popularity scores. Can be one of the following:

    • 'quantile' (the default)

    • 'rank'

    • 'count'

  • score_method (str)

item_pop_#

Item popularity scores.

property is_trained: bool#

Check if this model has already been trained.

train(data)#

Train the pipeline component to learn its parameters from a training dataset.

Parameters:
  • data (Dataset) – The training dataset.

  • retrain – If True, retrain the model even if it has already been trained.

class lenskit.basic.popularity.TimeBoundedPopScore(cutoff, score_method='quantile')#

Bases: PopScorer

Score items by their time-bounded popularity, i.e., the popularity in the most recent time_window period. Use with TopN to get a most-popular-recent-items recommender.

Parameters:
  • time_window (datetime.timedelta) – The time window for computing popularity scores.

  • score_type (str) –

    The method for computing popularity scores. Can be one of the following:

    • 'quantile' (the default)

    • 'rank'

    • 'count'

  • cutoff (datetime)

  • score_method (str)

item_scores_#

Time-bounded item popularity scores.

Type:

pandas.Series

train(data, **kwargs)#

Train the pipeline component to learn its parameters from a training dataset.

Parameters:
  • data (Dataset) – The training dataset.

  • retrain – If True, retrain the model even if it has already been trained.