PureSVDModel

class rectools.models.pure_svd.PureSVDModel(factors: int = 10, tol: float = 0, maxiter: Optional[int] = None, random_state: Optional[int] = None, verbose: int = 0, recommend_n_threads: int = 0, recommend_use_gpu_ranking: bool = True)[source]

Bases: VectorModel[PureSVDModelConfig]

PureSVD matrix factorization model.

See https://dl.acm.org/doi/10.1145/1864708.1864721

Parameters
  • factors (int, default 10) – The number of latent factors to compute.

  • tol (float, default 0) – Tolerance for singular values. Zero means machine precision.

  • maxiter (int, optional, default None) – Maximum number of iterations.

  • random_state (int, optional, default None) – Pseudorandom number generator state used to generate resamples.

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

  • recommend_n_threads (int, default 0) – Number of threads to use for recommendation ranking on CPU. Specifying 0 means to default to the number of cores on the machine. 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 (bool, default True) – Flag to use GPU for recommendation ranking. Please note that GPU and CPU ranking may provide different ordering of items with identical scores in recommendation table. If True, implicit.gpu.HAS_CUDA will also be checked before ranking. If you want to change this parameter after model is initialized, you can manually assign new value to model recommend_use_gpu_ranking attribute.

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.

get_vectors()

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_dist

recommends_for_cold

recommends_for_warm

u2i_dist

config_class

alias of PureSVDModelConfig

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)