当我在其他项目/产品上有额外的隐式数据的情况下,向lightfm模型提供数据时,什么是设置数据的正确方法。例如,我有100 k用户x200项交互数据,但是在实际应用中,我希望模型只提供来自200个条目中的50个的建议。那么如何设置数据呢?我正在考虑两个案例,但我不确定哪一个是正确的方法:
案例1:将整个矩阵(100 k用户x200项)直接作为lightfm中的interactions参数提供。这样,就可以更多地进行协作学习。
案例2:只向interactions参数提供提要(100 k用户x50项),并使用(100 kx150项)矩阵作为user_features。这样,它更多的是以内容为基础的学习。
哪一个是对的?另外,对于案例1,模型评估的实用函数(精确性、召回等)是否有方法仅推荐选定的项目,例如,顶部k个推荐项目只应从50项中提取,而不推荐其他项目,并从这些项中计算精度、召回等。
发布于 2020-06-02 11:37:36
您应该遵循案例1,使用整个交互数据来训练模型。在进行预测时,可以将所需(50)项的索引作为参数传递给model.predict。
从lightfm文档中可以看到,model.predict将项ids作为参数(在本例中为50个项的ids )。
https://making.lyst.com/lightfm/docs/_modules/lightfm/lightfm.html#LightFM.predict
def预测(self,user_ids,item_ids,item_features=None,user_features=None,num_threads=1):“”计算用户-项目对的推荐分数。
Arguments
---------
user_ids: integer or np.int32 array of shape [n_pairs,]
single user id or an array containing the user ids for the
user-item pairs for which a prediction is to be computed
item_ids: np.int32 array of shape [n_pairs,]
an array containing the item ids for the user-item pairs for which
a prediction is to be computed
user_features: np.float32 csr_matrix of shape [n_users, n_user_features], optional
Each row contains that user's weights over features
item_features: np.float32 csr_matrix of shape [n_items, n_item_features], optional
Each row contains that item's weights over features
num_threads: int, optional
Number of parallel computation threads to use. Should
not be higher than the number of physical cores.https://stackoverflow.com/questions/61855502
复制相似问题