RsUserCF#
- class libreco.algorithms.RsUserCF(task, data_info, k_sim=20, num_threads=1, min_common=1, mode='invert', seed=42, lower_upper_bound=None)[source]#
Bases:
RsCfBaseUser Collaborative Filtering algorithm implemented in Rust.
- Parameters:
task ({'rating', 'ranking'}) – Recommendation task. See Task.
data_info (
DataInfoobject) – Object that contains useful information for training and inference.k_sim (int, default: 20) – Number of similar items to use.
num_threads (int, default: 1) – Number of threads to use.
min_common (int, default: 1) – Number of minimum common users to consider when computing similarities.
mode ({'forward', 'invert'}, default: 'invert') – Whether to use forward index or invert index.
seed (int, default: 42) – Random seed.
lower_upper_bound (tuple or None, default: None) – Lower and upper score bound for rating task.
- fit(train_data, neg_sampling, verbose=1, eval_data=None, metrics=None, k=10, eval_batch_size=8192, eval_user_num=None)#
Fit model on the training data.
- Parameters:
train_data (
TransformedSetobject) – Data object used for training.neg_sampling (bool) – Whether to perform negative sampling for training or evaluating data.
- classmethod load(path, model_name, data_info, **kwargs)#
Load saved model for inference.
- Parameters:
- Returns:
model – Loaded model.
- Return type:
type(cls)
See also
- predict(user, item, cold_start='popular', inner_id=False)#
Predict score for given user and item.
- rebuild_model(path, model_name)#
Assign the saved model variables to the newly initialized model.
This method is used before retraining the new model, in order to avoid training from scratch every time we get some new data.
- recommend_user(user, n_rec, cold_start='popular', inner_id=False, filter_consumed=True, random_rec=False)#
Recommend a list of items for given user.
- Parameters:
- Returns:
recommendation – Recommendation result with user ids as keys and array_like recommended items as values.
- Return type: