0

我正在使用 LightFM 对推荐系统进行建模,并尝试在 Steam 数据上构建数据集。我最初的部分代码如下:

 dataset = Dataset()
 dataset.fit(users = users_data['userID'], items = games_data['id'])
 num_users, num_items = dataset.interactions_shape()
 print('Num users: {}, num_items {}.'.format(num_users, num_items))

 fea_cols = [x for x in games_data.columns[15:24]]
 fea_cols  #these are my games feature cols:['app_name','price','early_access','release_year','release_month','genre_list','specs_list','total_positive_recommendation','total_negative_recommendation']
 dataset.fit_partial(items = games_data['id'],
                item_features = fea_cols)

 user_cols = [x for x in users_data[["items_count", "playtime_forever", "playtime_2weeks"]]]
 dataset.fit_partial(users = users_data['id'],
                user_features = user_cols)

 (interactions, weights) = dataset.build_interactions(((row['userID'], row['id'])
                                                  for id,row in   users_data.iterrows()))

 item_features = dataset.build_item_features(((row['id'], 
                                          [row['app_name'], row['early_access'], row['price'], 
                                           row["release_year"], row["release_month"],
                                           [row['genres'].split(',')],
                                           [row['specs'].split(',')]])
                                          for id,row in games_data.iterrows()))

当我运行 dataset.builf_item_features 时,我收到以下错误,即 app_name 不适合数据集,即使我之前在该功能上调用了 fit_partial。

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-54-591ba85acbe4> in <module>()
      4                                                [row['genres'].split(',')],
      5                                                [row['specs'].split(',')]])
----> 6                                               for id,row in  games_data.iterrows()))
      7 print(repr(item_features))

2 frames
/usr/local/lib/python3.7/dist-packages/lightfm/data.py in _process_features(self, datum)
    101                 raise ValueError(
    102                     "Feature {} not in feature mapping. "
--> 103                     "Call fit first.".format(feature)
    104                 )
    105 

ValueError: Feature Lost Summoner Kitty not in feature mapping. Call fit first.

有人可以帮我吗?

4

0 回答 0