lenskit.algorithms.mf_common#
Common utilities & implementations for matrix factorization.
Module Attributes
Type of matrix factorization parameter data. |
Classes
Common predictor for matrix factorization. |
- class lenskit.algorithms.mf_common.M#
Type of matrix factorization parameter data. Can be either
Tensor
orndarray
.alias of TypeVar(‘M’, ~torch.Tensor, ~numpy.ndarray)
- class lenskit.algorithms.mf_common.MFPredictor#
-
Common predictor for matrix factorization.
- users_: Vocabulary#
Users in the model (length=:math:m).
- items_: Vocabulary#
Items in the model (length=:math:n).
- user_features_: M#
The \(m \times k\) user-feature matrix.
- item_features_: M#
The \(m \times k\) user-feature matrix.
- property n_features#
The number of features.
- property n_users#
The number of users.
- property n_items#
The number of items.
- lookup_user(user)#
Look up the index for a user.
- Parameters:
user – the user ID to look up
- Returns:
the user index.
- Return type:
- lookup_items(items)#
Look up the indices for a set of items.
- Parameters:
items (array-like) – the item IDs to look up.
- Returns:
the item indices. Unknown items will have negative indices.
- Return type:
- score(user, items, u_features=None)#
Score a set of items for a user. User and item parameters must be indices into the matrices.
- Parameters:
- Returns:
the scores for the items.
- Return type: