lightfm icon indicating copy to clipboard operation
lightfm copied to clipboard

ValueError: item id not in item id mappings while making item features

Open edwinjosechittilappilly opened this issue 5 years ago • 2 comments


ValueError Traceback (most recent call last) in () ----> 1 item_features=dataset.build_item_features(itemFeatures)

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.

edwinjosechittilappilly avatar Dec 16 '19 08:12 edwinjosechittilappilly

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()
    )

zkid18 avatar Feb 20 '20 06:02 zkid18

How can i solve this item id mapping value error in build_item_iteractions.


ValueError Traceback (most recent call last) in ----> 1 question_features = dataset.build_item_features(jobdf['applied_features']) 2 professional_features = dataset.build_user_features(userdf['candidate_features']) 3

~/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.

milind29 avatar Oct 20 '20 07:10 milind29