lightfm
lightfm copied to clipboard
ValueError: item id not in item id mappings while making item features
ValueError Traceback (most recent call last)
2 frames /usr/local/lib/python3.6/dist-packages/lightfm/data.py in _process_features(self, datum) 90 raise ValueError( 91 "{entity_type} id {entity_id} not in {entity_type} id mappings.".format( ---> 92 entity_type=self._entity_type, entity_id=entity_id 93 ) 94 )
ValueError: item id 6Qg39Zo6sZk not in item id mappings.
The problem might occur due to the wrong input format of item_features
when initializing Dataset
.
I would agree that the documentation is slightly misleading, it would be nice to see the primer with passing multiple features.
I managed to pass the flatten version of the numpy
array dealing with the same issue but I'm not sure if it is the right way since I'm not passing an iterable.
dataset.fit(
df['user_id'].unique(),
df['item_id'].unique(),
item_features=df[item_features_list].values.flatten(),
user_features=df[user_features_list].values.flatten()
)
How can i solve this item id mapping value error in build_item_iteractions.
ValueError Traceback (most recent call last)
~/env/lib/python3.6/site-packages/lightfm/data.py in build_item_features(self, data, normalize) 399 ) 400 --> 401 return builder.build(data) 402 403 def model_dimensions(self):
115
116 for datum in data:
--> 117 for (entity_idx, feature_idx, weight) in self._process_features(datum): 118 features.append(entity_idx, feature_idx, weight) 119
90 raise ValueError(
91 "{entity_type} id {entity_id} not in {entity_type} id mappings.".format(
---> 92 entity_type=self._entity_type, entity_id=entity_id 93 ) 94 )
ValueError: item id 1738 not in item id mappings.