Python Surprise 包为使用潜在因素的预测方法与手动计算提供了不同的预测

问题描述

我正在使用惊喜包进行矩阵分解。下面是教程的代码:

from surprise import SVD
from surprise import Dataset
from surprise import accuracy
from surprise.model_selection import train_test_split

# Load the movielens-100k dataset (download it if needed),data = Dataset.load_builtin('ml-100k')
trainset = data.build_full_trainset()

algo = SVD()
algo.fit(trainset)

algo.predict(str(196),str(302))

Out:
Prediction(uid='196',iid='301',r_ui=4,est=3.0740854315737174,details={'was_impossible': False})

但是,当我使用其 documentationsource code 中的 SVD 方程手动计算 r_hat(r 预测)时:

algo.trainset.global_mean + algo.bi[301] + algo.bu[196] + np.dot(algo.qi[301],algo.pu[196]) 

Out:
2.817335384596893

预测根本不匹配。我做错了什么或遗漏了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)