nmf.py

class ucas_dm.prediction_algorithms.nmf.NMF(n_factors=15, n_epochs=80, random_state=0, reg_pu=0.05, reg_qi=0.05)[source]

Bases: ucas_dm.prediction_algorithms.surprise_base_algo.SurpriseBaseAlgo

A collaborative filtering algorithm based on Non-negative Matrix Factorization.

__init__(n_factors=15, n_epochs=80, random_state=0, reg_pu=0.05, reg_qi=0.05)[source]
Parameters:
  • n_factors – The number of factors. Default is 20.
  • n_epochs – The number of iteration of the SGD procedure. Default is 20.
  • random_state – random_state (int, RandomState instance from numpy, or None) – Determines the RNG that will be used for initialization. If int, random_state will be used as a seed for a new RNG. This is useful to get the same initialization over multiple calls to fit(). If RandomState instance, this same instance is used as RNG. If None, the current RNG from numpy is used. Default is 0.
  • reg_pu – The regularization term for users λu. Default is 0.05.
  • reg_qi – The regularization term for items λi. Default is 0.05.
_init_surprise_model()[source]

Sub-class should implement this method which return a prediction algorithm from package ‘Surprise’.

Returns:A surprise-based recommend model
to_dict()[source]

See BaseAlgo.to_dict for more details.