''' Run cross-validation experiment on the MovieLens 100K dataset, with the row-average baseline. ''' import sys, os project_location = os.path.dirname(__file__) + "/../../../../" sys.path.append(project_location) from BMF_Priors.code.models.baseline_average_row import RowAverage from BMF_Priors.code.cross_validation.matrix_single_cross_validation import MatrixSingleCrossValidation from BMF_Priors.data.movielens.load_data import load_processed_movielens_100K ''' Settings BMF model. ''' method = RowAverage R, M = load_processed_movielens_100K() hyperparameters = {} train_config = {'iterations': 0, 'init': ''} predict_config = {'burn_in': 0, 'thinning': 0} parameters = {'K': 0, 'hyperparameters': hyperparameters} ''' Settings nested cross-validation. ''' no_folds = 5 folder_results = './results/baseline_average_row/' output_file = folder_results + 'results.txt' ''' Run the cross-validation framework. ''' crossval = MatrixSingleCrossValidation( method=method, R=R, M=M, K=no_folds, parameters=parameters, train_config=train_config,
Measure convergence on the MovieLens 100K dataset, with the Gaussian + Laplace + IG model. ''' import sys, os project_location = os.path.dirname(__file__)+"/../../../../" sys.path.append(project_location) from BMF_Priors.code.models.bmf_gaussian_laplace_inversegaussian import BMF_Gaussian_Laplace_IG from BMF_Priors.data.movielens.load_data import load_processed_movielens_100K from BMF_Priors.experiments.convergence.convergence_experiment import measure_convergence_time import matplotlib.pyplot as plt ''' Run the experiment. ''' R, M = load_processed_movielens_100K() model_class = BMF_Gaussian_Laplace_IG settings = { 'R': R, 'M': M, 'K': 20, 'hyperparameters': { 'alpha':1., 'beta':1. }, 'init': 'random', 'iterations': 200, } fout_performances = './results/performances_gaussian_laplace_ig.txt' fout_times = './results/times_gaussian_laplace_ig.txt' repeats = 10 performances, times = measure_convergence_time( repeats, model_class, settings, fout_performances, fout_times)