lenskit.knn.association.AssociationScorer#
- class lenskit.knn.association.AssociationScorer(config=None, **kwargs)#
Bases:
lenskit.pipeline.Component[lenskit.data.ItemList],lenskit.training.TrainableItem scorer using association rules to compute item relatedness.
This scorer can compute item associations with three formulas:
Conditional probability (\(P[i|j]\)), by setting
methodto"probability".Lift (\(\frac{P[i,j]}{P[i]P[j]}\)), by setting
methodto"lift"anddampingto 0.Biased lift), by setting
methodto"lift"anddamping(\(\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:
data (lenskit.data.Dataset) – The training dataset.
options (lenskit.training.TrainingOptions) – The training options.
- __call__(query, items)#
Run the pipeline’s operation and produce a result. This is the key method for components to implement.
- Parameters:
query (lenskit.data.RecQuery)
items (lenskit.data.ItemList)