Exemplo n.º 1
0
"""
Basic algorithm definitions as starting points.
"""

from lenskit.algorithms import item_knn, user_knn, als, funksvd
from lenskit.algorithms import basic

Bias = basic.Bias(damping=5)
Pop = basic.Popular()
II = item_knn.ItemItem(20, save_nbrs=2500)
UU = user_knn.UserUser(30)
ALS = als.BiasedMF(50)
IALS = als.ImplicitMF(50)
MFSGD = funksvd.FunkSVD(50)
Exemplo n.º 2
0
pruned_data_5.reset_index(inplace=True)

#pairs_user = list(partition_users(pruned_data_5, 5, xf.SampleN(1)))
pairs_user = list(sample_users(pruned_data_5, 5, 12000, xf.SampleN(1)))
pickle_out = open("sample_user.pickle", "wb")
pickle.dump(pairs_user, pickle_out)
pickle_out.close()

truth = pd.concat((p.test for p in pairs_user))
#truth.to_csv(r'results/steam/pruned_5.csv')


def algo_eval(path, algo, dataset):
    evaluation = batch.MultiEval(path=path, predict=False, recommend=100)
    evaluation.add_algorithms(algos=algo)
    evaluation.add_datasets(data=dataset)
    evaluation.run()


algo_ii = item_knn.ItemItem(20, center=False, aggregate='sum')
#algo_uu = user_knn.UserUser(30, center=False, aggregate='sum')
algo_pop = basic.Popular()
algo_mf = ImplicitMF(40)
algo_bpr = BPR()
algo_tf_idf = tf_idf()
algo_LDA = LDA()

algo_eval('results/steam/all_algo_sample_user',
          [algo_LDA, algo_tf_idf, algo_ii, algo_pop, algo_mf, algo_bpr],
          pairs_user)
Exemplo n.º 3
0
from lenskit.algorithms import basic, Recommender, als, item_knn, user_knn
from lenskit.algorithms import funksvd
from lenskit.algorithms.implicit import BPR
from lenskit.algorithms.hpf import HPF
from sklearn.model_selection import train_test_split

import pandas as pd
import matplotlib

NUM_OF_RECS = 10  # num of items to rec for each user

ml1m = ML1M('../datasets/ml-1m')
ratings = ml1m.ratings

random = basic.Random()
popular = basic.Popular()
item_to_item_100 = item_knn.ItemItem(100)
item_to_item_200 = item_knn.ItemItem(200)
item_to_item_500 = item_knn.ItemItem(500)
user_to_user_100 = user_knn.UserUser(100)
user_to_user_200 = user_knn.UserUser(200)
user_to_user_500 = user_knn.UserUser(500)
biased_mf_50 = als.BiasedMF(50)
biased_mf_100 = als.BiasedMF(100)
biased_mf_200 = als.BiasedMF(200)
implicit_mf_50 = als.ImplicitMF(50)
implicit_mf_100 = als.ImplicitMF(100)
implicit_mf_200 = als.ImplicitMF(200)
funk_svd_mf_50 = funksvd.FunkSVD(50)
funk_svd_mf_100 = funksvd.FunkSVD(100)
funk_svd_mf_200 = funksvd.FunkSVD(200)