def test_implicit_bpr_train_rec(): algo = BPR(25) ratings = lktu.ml_pandas.renamed.ratings algo.fit(ratings) recs = algo.recommend(100, n=20) assert len(recs) == 20
def test_implicit_bpr_train_rec(): algo = BPR(25) assert algo.factors == 25 ratings = lktu.ml_pandas.renamed.ratings algo.fit(ratings) recs = algo.recommend(100, n=20) assert len(recs) == 20 _log.info('serializing implicit model') mod = pickle.dumps(algo) _log.info('serialized to %d bytes') a2 = pickle.loads(mod) r2 = a2.recommend(100, n=20) assert len(r2) == 20 assert all(r2 == recs)
def test_implicit_bpr_train_rec(): algo = BPR(25, use_gpu=False) assert algo.factors == 25 ratings = lktu.ml_test.ratings algo.fit(ratings) recs = algo.recommend(100, n=20) assert len(recs) == 20 preds = algo.predict_for_user(100, [20, 30, 23148010]) assert all(preds.index == [20, 30, 23148010]) assert all(preds.isna() == [False, False, True]) _log.info('serializing implicit model') mod = pickle.dumps(algo) _log.info('serialized to %d bytes') a2 = pickle.loads(mod) r2 = a2.recommend(100, n=20) assert len(r2) == 20 assert all(r2 == recs)