lenskit.sklearn.svd#
Singular value decomposition for explicit feedback.
This module contains a truncated SVD explicit-feedback scorer built on
sklearn.decomposition.TruncatedSVD.
Classes#
Mixin for configuring embedding sizes (# of latent dimensions). |
|
Biased matrix factorization for explicit feedback using SciKit-Learn's |
Module Contents#
- class lenskit.sklearn.svd.BiasedSVDConfig#
Bases:
lenskit.config.common.EmbeddingSizeMixin,pydantic.BaseModelMixin for configuring embedding sizes (# of latent dimensions).
Component configuration classes can extend this class to inherit a standardized definition of an embedding size, along with useful behavior like configuring with base-2 logs.
Example usage:
class SVDConfig(EmbeddingSizeMixin, BaseModel): pass cfg = SVDConfig(embedding_size=32)
- embedding_size: int#
The dimension of user and item embeddings (number of latent features to learn).
- damping: lenskit.basic.Damping = 5#
- algorithm: Literal['arpack', 'randomized'] = 'randomized'#
- class lenskit.sklearn.svd.BiasedSVDScorer(config=None, **kwargs)#
Bases:
lenskit.pipeline.Component[lenskit.data.ItemList],lenskit.training.TrainableBiased matrix factorization for explicit feedback using SciKit-Learn’s
TruncatedSVD. It operates by first computing the bias, then computing the SVD of the bias residuals.You’ll generally want one of the iterative SVD implementations such as
lenskit.als.BiasedMFScorer; this is here primarily as an example and for cases where you want to evaluate a pure SVD implementation.- Stability:
- Caller (see Stability Levels).
- Parameters:
config (object | None)
kwargs (Any)
- config: BiasedSVDConfig#
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.
- bias: lenskit.basic.BiasModel#
- factorization: sklearn.decomposition.TruncatedSVD#
- users: lenskit.data.Vocabulary#
- items: lenskit.data.Vocabulary#
- user_components: numpy.typing.NDArray[numpy.float64]#
- 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:
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.QueryInput)
items (lenskit.data.ItemList)
- Return type:
Exported Aliases#
- class lenskit.sklearn.svd.BiasModel#
Re-exported alias for
lenskit.basic.BiasModel.
- lenskit.sklearn.svd.Damping#
Re-exported alias for
lenskit.basic.Damping.
- class lenskit.sklearn.svd.EmbeddingSizeMixin#
Re-exported alias for
lenskit.config.common.EmbeddingSizeMixin.
- class lenskit.sklearn.svd.Dataset#
Re-exported alias for
lenskit.data.Dataset.
- class lenskit.sklearn.svd.ItemList#
Re-exported alias for
lenskit.data.ItemList.
- lenskit.sklearn.svd.QueryInput#
Re-exported alias for
lenskit.data.QueryInput.
- class lenskit.sklearn.svd.RecQuery#
Re-exported alias for
lenskit.data.RecQuery.
- class lenskit.sklearn.svd.Vocabulary#
Re-exported alias for
lenskit.data.Vocabulary.
- class lenskit.sklearn.svd.Stopwatch#
Re-exported alias for
lenskit.logging.Stopwatch.
- lenskit.sklearn.svd.get_logger()#
Re-exported alias for
lenskit.logging.get_logger().
- class lenskit.sklearn.svd.Component#
Re-exported alias for
lenskit.pipeline.Component.
- class lenskit.sklearn.svd.Trainable#
Re-exported alias for
lenskit.training.Trainable.
- class lenskit.sklearn.svd.TrainingOptions#
Re-exported alias for
lenskit.training.TrainingOptions.