text_plain_output_2.png text_plain_output_1.png
from surprise import KNNBasic, KNNWithMeans, KNNWithZScore

from surprise import accuracy

algoritmo = KNNBasic(k=50, sim_options={'name': 'pearson', 'user_based': True, 'verbose': True})

algoritmo.fit(trainset)

uid = str(49)

iid = str(2058)

pred = algoritmo.predict(uid, iid, r_ui=4, verbose=True)

test_pred = algoritmo.test(testset)

accuracy.rmse(test_pred, verbose=True)

print('Analisys MAE: ')
accuracy.mae(test_pred, verbose=True)