lenskit.algorithms.svd#
Classes
|
Biased matrix factorization for implicit feedback using SciKit-Learn's SVD solver ( |
- class lenskit.algorithms.svd.BiasedSVD(features, *, damping=5, bias=True, algorithm='randomized')#
Bases:
Predictor
Biased matrix factorization for implicit feedback using SciKit-Learn’s SVD solver (
sklearn.decomposition.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
lennskit.algorithms.als.BiasedMF
; this is here primarily as an example and for cases where you want to evaluate a pure SVD implementation.- Parameters:
bias (Bias)
algorithm (Literal['arpack', 'randomized'])
- fit(data, **kwargs)#
Train a model using the specified ratings (or similar) data.
- Parameters:
data (Dataset) – The training data.
kwargs – Additional training data the algorithm may require. Algorithms should avoid using the same keyword arguments for different purposes, so that they can be more easily hybridized.
- Returns:
The algorithm object.
- predict_for_user(user, items, ratings=None)#
Compute predictions for a user and items.
- Parameters:
user – the user ID
items (array-like) – the items to predict
ratings (pandas.Series) – the user’s ratings (indexed by item id); if provided, they may be used to override or augment the model’s notion of a user’s preferences.
- Returns:
scores for the items, indexed by item id.
- Return type:
- get_params(deep=True)#
Get the parameters for this algorithm (as in scikit-learn). Algorithm parameters should match constructor argument names.
The default implementation returns all attributes that match a constructor parameter name. It should be compatible with
sklearn.base.BaseEstimator.get_params()
method so that LensKit alogrithms can be cloned withsklearn.base.clone()
as well aslenskit.util.clone()
.- Returns:
the algorithm parameters.
- Return type: