コード例 #1
0
def main_slim():
    URM = sps.csr_matrix(sps.load_npz("../../../Dataset/URM/data_all.npz"))
    URM_test = sps.csr_matrix(
        sps.load_npz("../../../Dataset/URM/data_test.npz"))
    users = utils.get_target_users("../../../Dataset/target_users.csv", seek=8)
    validator = validate(URM_test, [10])
    recommender = SLIM_BPR_Recommender(URM)
    recommender.fit()
    '''
コード例 #2
0
def main_sslim():
    URM = sps.csr_matrix(sps.load_npz("../../Dataset/URM/data_all.npz"))
    URM_test = sps.csr_matrix(sps.load_npz("../../Dataset/URM/data_test.npz"))

    URM_1 = sps.csr_matrix(sps.load_npz("../../Dataset/old/similarities/CB-Sim.npz"))
    URM_2 = sps.csr_matrix(sps.load_npz("../../Dataset/old/similarities/Col-Sim.npz"))
    URM_3 = sps.csr_matrix(sps.load_npz("../../Dataset/old/similarities/Slim-Sim.npz"))
    URM_4 = normalize(URM_3, min(min(URM_1.data), min(URM_2.data)), max(max(URM_1.data), max(URM_2.data)))
    mauri_recsys = ReccomenderSslim(URM)
    validator = validate(URM_test, [10])
    targetUsers = util.get_target_users("../../Dataset/target_users.csv", seek=8)
    #similarity_matrix = mauri.similarityMatrixTopK(0.31*URM_1 + 1.82*URM_2 + 0.76*URM_4, k=25)
    mauri_recsys.fit(train="-train")
コード例 #3
0
import scipy.sparse as sps
import utils_new as utils
import evaluator as evaluate
import random

from External_Libraries.Evaluation.Evaluator import EvaluatorHoldout as validate
from External_Libraries.MatrixFactorization.PyTorch.MF_MSE_PyTorch import MF_MSE_PyTorch

URM = sps.load_npz("../../Dataset/old/data_train.npz")
URM_test = sps.csr_matrix(sps.load_npz("../../Dataset/old/data_test.npz"))
users = utils.get_target_users("../../Dataset/target_users.csv", seek=8)
validator = validate(URM_test, [10])

recommender = MF_MSE_PyTorch(URM)

for ep in [30]:
    for batch in [16, 32, 64, 128, 256, 512, 1024, 2048, 4096]:
        for i in range(10, 1000, 100):
            for lr in [1e-6]:
                recommender.fit(ep,batch,i,lr)
                print("FACTOR:{0}, BATCH:{1}, LR:{2}, EPOCHS:{3}".format(
                    i, batch, lr, ep))
                print(evaluate.evaluate(users, recommender, URM_test, 10)["MAP"])
                #results = validator.evaluateRecommender(recommender)
                #print(results[0][10]["MAP"])
                print("\n")