lenskit.knn.association.AssociationScorer#

class lenskit.knn.association.AssociationScorer(config=None, **kwargs)#

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

Item scorer using association rules to compute item relatedness.

This scorer can compute item associations with three formulas:

  • Conditional probability (\(P[i|j]\)), by setting method to "probability".

  • Lift (\(\frac{P[i,j]}{P[i]P[j]}\)), by setting method to "lift" and damping to 0.

  • Biased lift), by setting method to "lift" and damping (\(\kappa\)) to a positive value.

An empty query will recommend no items.

Parameters:
  • config (object | None)

  • kwargs (Any)

config: AssociationConfig#

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#
assoc_scores: scipy.sparse.csr_array#

Sparse matrix of item association scores, with reference items on rows and target items on columns.

is_trained()#

Query if this component has already been trained.

train(data, options)#

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

Parameters:
__call__(query, items)#

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

Parameters: