ImplicitALSWrapperModel
- class rectools.models.implicit_als.ImplicitALSWrapperModel(model: Union[AlternatingLeastSquares, AlternatingLeastSquares], fit_features_together: bool = False, recommend_n_threads: Optional[int] = None, recommend_use_gpu_ranking: Optional[bool] = None, verbose: int = 0)[source]
Bases:
VectorModel[ImplicitALSWrapperModelConfig]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.
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.
recommend_n_threads (Optional[int], default
None) – Number of threads to use for recommendation ranking on CPU. Specifying0means to default to the number of cores on the machine. IfNone, then number of threads will be set same as model.num_threads. If you want to change this parameter after model is initialized, you can manually assign new value to model recommend_n_threads attribute.recommend_use_gpu_ranking (Optional[bool], default
None) – Flag to use GPU for recommendation ranking. IfNone, then will be set same as model.use_gpu. implicit.gpu.HAS_CUDA will also be checked before inference. Please note that GPU and CPU ranking may provide different ordering of items with identical scores in recommendation table. If you want to change this parameter after model is initialized, you can manually assign new value to model recommend_use_gpu_ranking attribute.verbose (int, default 0) – Degree of verbose output. If 0, no output will be provided.
- Inherited-members
Methods
dumps()Serialize model to bytes.
fit(dataset, *args, **kwargs)Fit model.
fit_partial(dataset, *args, **kwargs)Fit model.
from_config(config)Create model from config.
get_config([mode, simple_types])Return model config.
get_params([simple_types, sep])Return model parameters.
Return user and item vector representations from fitted model.
load(f)Load model from file.
loads(data)Load model from bytes.
recommend(users, dataset, k, filter_viewed)Recommend items for users.
recommend_to_items(target_items, dataset, k)Recommend items for target items.
save(f)Save model to file.
Attributes
i2i_distrecommends_for_coldrecommends_for_warmu2i_dist- config_class
alias of
ImplicitALSWrapperModelConfig