Hierarchical Poisson Factorization
This module provides a LensKit bridge to the hpfrec library implementing hierarchical Poisson factorization :cite:p:`Gopalan2013-ko`.
To install (after we have cut a release), run:
pip install lenskit-hpf
We do not provide a Conda package, because hpfrec is not packaged for Conda. You can
use pip
to install this package in your Anaconda environment after installing LensKit
itself with conda
.
- class lenskit_hpf.HPF(features, **kwargs)
Bases:
lenskit.algorithms.mf_common.MFPredictor
Hierarchical Poisson factorization, provided by hpfrec.
- Parameters
features (int) – the number of features
**kwargs – arguments passed to
hpfrec.HPF
.
- fit(ratings, **kwargs)
Train a model using the specified ratings (or similar) data.
- Parameters
ratings (pandas.DataFrame) – The ratings 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