1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| # 手动载入数据集,指定文件所在位置 file_path = os.path.expanduser('~/.surprise_data/ml-100k/ml-100k/u.data')
reader = Reader(line_format='user item rating timestamp', sep='\t')
data = Dataset.load_from_file(file_path, reader)
data.split(n_folds=5)
algo = SVD()
pref = evaluate(algo, data, measures=['rmse', 'mae']) #输出结果 print_perf(pref) RMSE: 0.9335 MAE: 0.7383 ------------ Fold 2 RMSE: 0.9409 MAE: 0.7396 ------------ Fold 3 RMSE: 0.9331 MAE: 0.7339 ------------ Fold 4 RMSE: 0.9352 MAE: 0.7361 ------------ Fold 5 RMSE: 0.9416 MAE: 0.7422 ------------ ------------ Mean RMSE: 0.9369 Mean MAE : 0.7380 ------------
|