冷启动推荐

冷启动

冷启动就需要user或者item的特征来配合了, 仅使用协同过滤的FM模型是无法做到冷启动的.

我们选择StackExchange dataset作为数据集, 这个数据集除了行为交互数据, 还有item feature, 因此可以做关于item的冷启动.

import numpy as np
from lightfm.datasets import fetch_stackexchange

data = fetch_stackexchange('crossvalidated',
                           test_set_fraction=0.1,
                           indicator_features=False,
                           tag_features=True)
data
{'train': <3221x72360 sparse matrix of type '<class 'numpy.float32'>'
     with 57830 stored elements in COOrdinate format>,
 'test': <3221x72360 sparse matrix of type '<class 'numpy.float32'>'
     with 4307 stored elements in COOrdinate format>,
 'item_features': <72360x1246 sparse matrix of type '<class 'numpy.float32'>'
     with 198963 stored elements in Compressed Sparse Row format>,
 'item_feature_labels': array(['bayesian', 'prior', 'elicitation', ..., 'events', 'mutlivariate',
        'sample-variance'], dtype='<U50')}

除了划分好的traintest, 还有一个shape为(72360, 1246)item_feature矩阵, 共72360个item, item对应着1246个特征.

统计得到共有33827个item是没有跟用户发生过交互行为的, 可以认为是新的物品上线, 为现有的用户进行推荐.

取其中一个没有发生过交互的物品计算出要被推荐的用户.

上面就是应该把这个新的item推荐给的用户列表.

特征Embedding空间

训练之后也得到了每个item feature对应的向量, 由于在同一个空间中, 就可以通过向量之间的各种距离, 衡量两个特征的近似性.

最后更新于

这有帮助吗?