lenskit.implicit#
Classes
|
LensKit interface to |
|
LensKit interface to |
|
Base class for Implicit-backed recommenders. |
- class lenskit.implicit.BaseRec(delegate)#
Bases:
Recommender
,Predictor
Base class for Implicit-backed recommenders.
- Parameters:
delegate (implicit.RecommenderBase) – The delegate algorithm.
- delegate#
The
implicit
delegate algorithm.- Type:
implicit.RecommenderBase
- matrix_#
The user-item rating matrix.
- Type:
- user_index_#
The user index.
- Type:
- item_index_#
The item index.
- Type:
- matrix_: csr_matrix#
The user-item rating matrix from training.
- users_: Vocabulary#
The user ID mapping from training.
- items_: Vocabulary#
The item ID mapping from training.
- delegate: RecommenderBase#
The delegate algorithm from
implicit
.
- 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.
- recommend(user, n=None, candidates=None, ratings=None)#
Compute recommendations for a user.
- Parameters:
user – the user ID
n (int) – the number of recommendations to produce (
None
for unlimited)candidates (array-like) – The set of valid candidate items; if
None
, a default set will be used. For many algorithms, this is theirCandidateSelector
.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:
a frame with an
item
column; if the recommender also produces scores, they will be in ascore
column.- Return type:
- 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: