您应该遵循案例 1。使用整个交互数据训练模型。在进行预测时,您可以将 required(50) 项的索引作为参数传递给 model.predict。
从 lightfm 文档中,您可以看到 model.predict 将项目 ID 作为参数(在这种情况下,这将是您的 50 个项目的 ID)。
https://making.lyst.com/lightfm/docs/_modules/lightfm/lightfm.html#LightFM.predict
def predict(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.