etlundquist / rankfm

Factorization Machines for Recommendation and Ranking Problems with Implicit Feedback Data
GNU General Public License v3.0
171 stars 37 forks source link

KeyError: 'the items in [item_features] do not match the items in [interactions]' #33

Open srinivascnu166 opened 3 years ago

srinivascnu166 commented 3 years ago

item_features_train = pd.get_dummies(train_interactions[['Items', 'moment']], columns=['moment'])

I am classifying my items into fast, medium, slow moving items. for this I am using the parameter "item_features".

It gives me this error: model.fit(train_user_item, user_features=None, item_features=item_features_train, sample_weight=sample_weight_train, epochs=epochs, verbose=verbose) File "/usr/local/lib/python3.7/dist-packages/rankfm/rankfm.py", line 265, in fit self.fit_partial(interactions, user_features, item_features, sample_weight, epochs, verbose) File "/usr/local/lib/python3.7/dist-packages/rankfm/rankfm.py", line 289, in fit_partial self._init_all(interactions, user_features, item_features, sample_weight) File "/usr/local/lib/python3.7/dist-packages/rankfm/rankfm.py", line 135, in _init_all self._init_features(user_features, item_features) File "/usr/local/lib/python3.7/dist-packages/rankfm/rankfm.py", line 214, in _init_features raise KeyError('the items in [item_features] do not match the items in [interactions]') KeyError: 'the items in [item_features] do not match the items in [interactions]' can someone help me with this? And I have also gone through the example notebooks. I noticed that you have constructed the item features but not used it in instacart example. It would be if those notebooks were updated.

KDKDKay commented 3 years ago

I am also facing this issue. Did you happen to fix it?

srinivascnu166 commented 3 years ago

No

srinivascnu166 commented 3 years ago

Did you find any way to fix the issue @KDKDKay ?

ErraticO commented 1 year ago
model.fit(
    train_data[['user_id', 'item_id']],
    user_features=user_features,
    item_features=item_features,
    epochs=epochs,
    verbose=verbose
)

The unique_item_id of train_data and item_features is different. You may have lost item_id in item_features.