implicit_model_trainer module

class openrec.legacy.implicit_model_trainer.ImplicitModelTrainer(batch_size, test_batch_size, train_dataset, model, sampler, item_serving_size=None, eval_save_prefix=None)

Bases: object

The ImplicitModelTrainer class implements logics for basic recommender training and evaluation using users’ implicit feedback.

  • batch_size (int) – Training batch size.
  • test_batch_size (int) – Test/Evaluation batch size (number of users per testing batch).
  • train_dataset (Dataset) – Dataset for model training.
  • model (Recommender) – The target recommender.
  • sampler (Sampler) – The sampler for model training.
  • item_serving_size (int, optional) – Test/Evaluation batch size (number of items per testing batch).


The function train should be called for model training and evaluation.

train(num_itr, display_itr, eval_datasets=[], evaluators=[], num_negatives=None, seed=10)

Train and evaluate a recommender.

  • num_itr (int) – total number of training iterations.
  • display_itr (int) – Evaluation/testing period.
  • eval_datasets (list of Dataset) – A list of datasets for evaluation/testing.
  • evaluators (list of Evaluator) – A list of evaluators for evaluation/testing.
  • num_negatives (int, optional) – If specified, a given number of items NOT interacted with each user will be sampled (as negative items) for evaluations.