我有一个用户“首选项”表的数据集,该表的一个实例如下所示:
print(user_normalized[1].reshape(1, -1).shape)
print(user_normalized[1].reshape(1, -1))
___________________________________________________________________
(1, 20)
[[0. 0.00239107 0.00131709 0. 0.00355872 0.00212352
0.00300639 0.00044287 0.001469 0.00358637 0.01520913 0.
0. 0. 0.00174978 0.00237691 0.0026616 0.00241604
0. 0. ]]
这给了我第一个用户的偏好向量。
我有电影内容表的数据集:
print(movie_content.shape)
print(movie_content)
___________________________________________________________________
(27278, 20)
[[1 0 0 ... 0 0 0]
[1 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
...
[0 0 0 ... 0 0 0]
[0 0 1 ... 0 0 0]
[1 0 0 ... 0 0 0]]
我正在尝试获取用户偏好向量和电影内容表的点积,以便找到最优惠的电影(余弦相似度):
distances = np.dot(user_normalized[1], movie_content)
但这给了我以下错误:
ValueError: shapes (1,20) and (27278,20) not aligned: 20 (dim 1) != 27278 (dim 0)
为了找到最优惠的电影,找到距离度量的正确方法是正确的吗?
如果是代码有什么问题?
偶然的你
DIEA
相关分类