def test_most_popular(): mpop = pyreclab.MostPopular(dataset='dataset/u1.base', dlmchar=b'\t', header=False, usercol=0, itemcol=1, ratingcol=2) mpop.train(5) ranking = mpop.recommend('457', 5, includeRated=False) assert ranking == expected_ranking
import time import pyreclab if __name__ == '__main__': model = pyreclab.MostPopular(dataset='dataset/u1.base', dlmchar=b'\t', header=False, usercol=0, itemcol=1, ratingcol=2) print('-> training model') start = time.clock() model.train(5, progress=True) end = time.clock() print('training time: ' + str(end - start)) print('-> individual test') ranking = model.recommend('457', 5, includeRated=False) print('user 457, recommended items ' + str(ranking)) print('-> recommendation test') start = time.clock() recommendList, maprec, ndcg = model.testrec(input_file='dataset/u1.test', dlmchar=b'\t', header=False, usercol=0, itemcol=1, ratingcol=2, topn=10,