lenskit.funksvd#

FunkSVD (biased MF).

Functions

make_params(niters, lrate, reg, range)

train(ctx, params, model, timer)

Classes

Context(*args, **kwargs)

FunkSVD(features[, iterations, lrate, reg, ...])

Algorithm class implementing FunkSVD matrix factorization.

Model(*args, **kwargs)

Internal model class for training SGD MF.

class lenskit.funksvd.Model(*args, **kwargs)#

Bases: Model

Internal model class for training SGD MF.

class lenskit.funksvd.FunkSVD(features, iterations=100, *, lrate=0.001, reg=0.015, damping=5, range=None, bias=True, random_state=None)#

Bases: MFPredictor[ndarray]

Algorithm class implementing FunkSVD matrix factorization. FunkSVD is a regularized biased matrix factorization technique trained with featurewise stochastic gradient descent.

See the base class MFPredictor for documentation on the estimated parameters you can extract from a trained model.

Parameters:
  • features (int) – the number of features to train

  • iterations (int) – the number of iterations to train each feature

  • lrate (float) – the learning rate

  • reg (float) – the regularization factor

  • damping (float | tuple[float, float]) – damping factor for the underlying mean

  • bias (Bias | None) – the underlying bias model to fit. If True, then a bias.Bias model is fit with damping.

  • range (tuple[float, float] | None) – the (min, max) rating values to clamp ratings, or None to leave predictions unclamped.

  • random_state – The random state for shuffling the data prior to training.

fit(data, **kwargs)#

Train a FunkSVD model.

Parameters:
  • ratings – the ratings data frame.

  • data (Dataset)

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:

pandas.Series