lenskit.basic.popularity#

Classes#

PopConfig

Configuration for popularity scoring.

PopScorer

Score items by their popularity. Use with TopN to get a

TimeBoundedPopConfig

Configuration for popularity scoring.

TimeBoundedPopScore

Score items by their time-bounded popularity, i.e., the popularity in the

Module Contents#

class lenskit.basic.popularity.PopConfig#

Bases: pydantic.BaseModel

Configuration for popularity scoring.

score: Literal['quantile', 'rank', 'count'] = 'quantile'#

The method for computing popularity scores. For all methods, higher scores represent more popular items.

class lenskit.basic.popularity.PopScorer(config=None, **kwargs)#

Bases: lenskit.pipeline.Component[lenskit.data.ItemList], lenskit.training.Trainable

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

Stability:
Caller (see Stability Levels).
Parameters:
  • config (object | None)

  • kwargs (Any)

config: PopConfig#

The component configuration object. Component classes that support configuration must redefine this attribute with their specific configuration class type, which can be a Python dataclass or a Pydantic model class.

items: lenskit.data.Vocabulary#

Vocabulary of known items at training time.

item_scores: numpy.ndarray[tuple[int], numpy.dtype[numpy.float32]]#

Array of per-item popularity scores.

is_trained()#

Query if this component has already been trained.

train(data, options=TrainingOptions())#

Train the model to learn its parameters from a training dataset.

Parameters:
__call__(items)#

Run the pipeline’s operation and produce a result. This is the key method for components to implement.

Parameters:

items (lenskit.data.ItemList)

Return type:

lenskit.data.ItemList

class lenskit.basic.popularity.TimeBoundedPopConfig#

Bases: PopConfig

Configuration for popularity scoring.

cutoff: datetime.datetime#

Time window for computing popularity scores.

class lenskit.basic.popularity.TimeBoundedPopScore(config=None, **kwargs)#

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:
  • config (object | None)

  • kwargs (Any)

item_scores_#

Time-bounded item popularity scores.

Type:

pandas.Series

config: TimeBoundedPopConfig#

The component configuration object. Component classes that support configuration must redefine this attribute with their specific configuration class type, which can be a Python dataclass or a Pydantic model class.

train(data, options=TrainingOptions())#

Train the model to learn its parameters from a training dataset.

Parameters:

Exported Aliases#

class lenskit.basic.popularity.Dataset#

Re-exported alias for lenskit.data.Dataset.

class lenskit.basic.popularity.ItemList#

Re-exported alias for lenskit.data.ItemList.

class lenskit.basic.popularity.Vocabulary#

Re-exported alias for lenskit.data.Vocabulary.

lenskit.basic.popularity.get_logger()#

Re-exported alias for lenskit.logging.get_logger().

class lenskit.basic.popularity.Component#

Re-exported alias for lenskit.pipeline.Component.

class lenskit.basic.popularity.Trainable#

Re-exported alias for lenskit.training.Trainable.

class lenskit.basic.popularity.TrainingOptions#

Re-exported alias for lenskit.training.TrainingOptions.