我正在研究基于隐式反馈的推荐引擎。我正在使用这个链接:http://insightdatascience.com/blog/explicit_matrix_factorization.html#movielens http://insightdatascience.com/blog/explicit_matrix_factorization.html#movielens
这使用 ALS(交替最小二乘法)来计算用户和项目向量。因为,我的数据集无法按时间分区。我随机从用户那里获取“x”个评分并将其放入测试集中。这是我的训练用户项目矩阵的可重现示例。
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col1 col12 col13
+---------------------------------------------------------------------------------------------------+
| 1 0 0 3 10 0 0 3 0 0 1 0 0 | |
| 0 0 0 5 0 0 1 8 0 0 1 0 0 | |
| 0 0 0 6 7 1 0 2 0 0 1 0 0 | |
+---------------------------------------------------------------------------------------------------+
I then create a test set using this piece of code
test_ratings = np.random.choice(counts[user,:].nonzero()[0],size=1,replace=True)
train[user,test_ratings] = 0
test[user,test_ratings] = counts[user,test_ratings]
assert(np.all((train * test) == 0))
这给了我:
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col1 col12 col13
+---------------------------------------------------------------------------------------------------+
| 0 0 0 0 0 0 0 3 0 0 0 0 0 | |
| 0 0 0 0 0 0 1 0 0 0 0 0 0 | |
| 0 0 0 6 0 0 0 0 0 0 0 0 0 | |
+---------------------------------------------------------------------------------------------------+
这里的行是用户,列是项目。
现在,我想知道这是否是我的测试集的正确表示。我选取了一个非零值并使所有值都为零。因此,我的算法应该将非零值排名为推荐项目。
这是正确的处理方式吗?
任何帮助将非常感激