ImplicitALSWrapperModel

class rectools.models.implicit_als.ImplicitALSWrapperModel(model: Union[AlternatingLeastSquares, AlternatingLeastSquares], verbose: int = 0, fit_features_together: bool = False)[source]

Bases: VectorModel

Wrapper for implicit.als.AlternatingLeastSquares with possibility to use explicit features and GPU support.

See https://implicit.readthedocs.io/en/latest/als.html for details of base model.

Parameters
  • model (AnyAlternatingLeastSquares) – Base model that will be used.

  • verbose (int, default 0) – Degree of verbose output. If 0, no output will be provided.

  • fit_features_together (bool, default False) – Whether fit explicit features together with latent features or not. Used only if explicit features are present in dataset. See documentations linked above for details.

Inherited-members

Methods

fit(dataset, *args, **kwargs)

Fit model.

get_vectors()

Return user and item vector representations from fitted model.

recommend(users, dataset, k, filter_viewed)

Recommend items for users.

recommend_to_items(target_items, dataset, k)

Recommend items for target items.

Attributes

i2i_dist

n_threads

recommends_for_cold

recommends_for_warm

u2i_dist

get_vectors() Tuple[ndarray, ndarray][source]

Return user and item vector representations from fitted model.

Returns

User and item embeddings. Shapes are (n_users, n_factors) and (n_items, n_factors).

Return type

(np.ndarray, np.ndarray)