Experiment#

Experiment#

class cornac.experiment.experiment.Experiment(eval_method, models, metrics, user_based=True, show_validation=True, verbose=False, save_dir=None)[source]#

Experiment Class

Parameters:
  • eval_method (<cornac.eval_methods.BaseMethod>, required) – The evaluation method (e.g., RatioSplit).

  • models (array of <cornac.models.Recommender>, required) – A collection of recommender models to evaluate, e.g., [C2PF, HPF, PMF].

  • metrics (array of :obj:{<cornac.metrics.RatingMetric>, <cornac.metrics.RankingMetric>}, required) – A collection of metrics to use to evaluate the recommender models, e.g., [NDCG, MRR, Recall].

  • user_based (bool, optional, default: True) – This parameter is only useful if you are considering rating metrics. When True, first the average performance for every user is computed, then the obtained values are averaged to return the final result. If False, results will be averaged over the number of ratings.

  • show_validation (bool, optional, default: True) – Whether to show the results on validation set (if exists).

  • verbose (bool, optional, default: False) – Output running log/progress during model training and evaluation. If verbose is True, it will overwrite verbosity setting of evaluation method and models.

  • save_dir (str, optional, default: None) – Path to a directory for storing trained models and logs. If None, models will NOT be stored and logs will be saved in the current working directory.

result#

This attribute contains the results per-model of your experiment on the test set, initially it is set to None.

Type:

array of <cornac.experiment.result.Result>, default: None

val_result#

This attribute contains the results per-model of your experiment on the validation set (if exists), initially it is set to None.

Type:

array of <cornac.experiment.result.Result>, default: None

run()[source]#

Run the Cornac experiment

Result#

class cornac.experiment.result.Result(model_name, metric_avg_results, metric_user_results)[source]#

Result Class for a single model

Parameters:
  • model_name (string, required) – The name of the recommender model.

  • metric_avg_results (OrderedDict, required) – A dictionary containing the average result per-metric.

  • metric_user_results (OrderedDict, required) – A dictionary containing the average result per-user across different metrics.

CVResult#

class cornac.experiment.result.CVResult(model_name)[source]#

Cross Validation Result Class for a single model. A list of cornac.experiment.Result.

Parameters:

model_name (string, required) – The name of the recommender model.

metric_mean#

A dictionary containing the mean of results across all folds per-metric.

Type:

OrderedDict

metric_std#

A dictionary containing the standard deviation of results across all folds per-metric.

Type:

OrderedDict

ExperimentResult#

class cornac.experiment.result.ExperimentResult(iterable=(), /)[source]#

Result Class for an Experiment. A list of cornac.experiment.Result.

CVExperimentResult#

class cornac.experiment.result.CVExperimentResult(iterable=(), /)[source]#

Result Class for a cross-validation Experiment.