编码: ascii, 置信度: 1.00
Training until validation scores don't improve for 20 rounds
[10] training's auc: 0.999999 valid_1's auc: 0.999999
[20] training's auc: 0.999999 valid_1's auc: 0.999999
Early stopping, best iteration is:
[1] training's auc: 0.999999 valid_1's auc: 0.999999
Validation AUC: 1.0000
---------------------------------------------------------------------------
InvalidIndexError Traceback (most recent call last)
Cell In[16], line 188
186 samples = prepare_samples(all_see, all_click, all_play)
187 model, features, auc_score = train_model(samples)
--> 188 result = predict_new_data(model, features, 'testA_did_show.csv')
Cell In[16], line 164, in predict_new_data(model, feature_columns, test_file)
161 user_click_rate = pd.read_csv('user_click_rate.csv', encoding='gbk').set_index('did')['user_click_rate']
162 video_popularity = pd.read_csv('video_popularity.csv', encoding='gbk').set_index('vid')['video_popularity']
--> 164 test_data['user_click_rate'] = test_data['did'].map(user_click_rate).fillna(0).astype(np.float32)
165 test_data['video_popularity'] = test_data['vid'].map(video_popularity).fillna(0).astype(np.int32)
167 test_data[feature_columns] = test_data[feature_columns].fillna(0)
File ~\ANA\Lib\site-packages\pandas\core\series.py:4544, in Series.map(self, arg, na_action)
4464 def map(
4465 self,
4466 arg: Callable | Mapping | Series,
4467 na_action: Literal["ignore"] | None = None,
4468 ) -> Series:
4469 """
4470 Map values of Series according to an input mapping or function.
4471
(...)
4542 dtype: object
4543 """
-> 4544 new_values = self._map_values(arg, na_action=na_action)
4545 return self._constructor(new_values, index=self.index, copy=False).__finalize__(
4546 self, method="map"
4547 )
File ~\ANA\Lib\site-packages\pandas\core\base.py:919, in IndexOpsMixin._map_values(self, mapper, na_action, convert)
916 arr = self._values
918 if isinstance(arr, ExtensionArray):
--> 919 return arr.map(mapper, na_action=na_action)
921 return algorithms.map_array(arr, mapper, na_action=na_action, convert=convert)
File ~\ANA\Lib\site-packages\pandas\core\arrays\categorical.py:1530, in Categorical.map(self, mapper, na_action)
1526 na_action = "ignore"
1528 assert callable(mapper) or is_dict_like(mapper)
-> 1530 new_categories = self.categories.map(mapper)
1532 has_nans = np.any(self._codes == -1)
1534 na_val = np.nan
File ~\ANA\Lib\site-packages\pandas\core\indexes\base.py:6419, in Index.map(self, mapper, na_action)
6383 """
6384 Map values using an input mapping or function.
6385
(...)
6415 Index(['A', 'B', 'C'], dtype='object')
6416 """
6417 from pandas.core.indexes.multi import MultiIndex
-> 6419 new_values = self._map_values(mapper, na_action=na_action)
6421 # we can return a MultiIndex
6422 if new_values.size and isinstance(new_values[0], tuple):
File ~\ANA\Lib\site-packages\pandas\core\base.py:921, in IndexOpsMixin._map_values(self, mapper, na_action, convert)
918 if isinstance(arr, ExtensionArray):
919 return arr.map(mapper, na_action=na_action)
--> 921 return algorithms.map_array(arr, mapper, na_action=na_action, convert=convert)
File ~\ANA\Lib\site-packages\pandas\core\algorithms.py:1803, in map_array(arr, mapper, na_action, convert)
1799 mapper = mapper[mapper.index.notna()]
1801 # Since values were input this means we came from either
1802 # a dict or a series and mapper should be an index
-> 1803 indexer = mapper.index.get_indexer(arr)
1804 new_values = take_nd(mapper._values, indexer)
1806 return new_values
File ~\ANA\Lib\site-packages\pandas\core\indexes\base.py:3875, in Index.get_indexer(self, target, method, limit, tolerance)
3872 self._check_indexing_method(method, limit, tolerance)
3874 if not self._index_as_unique:
-> 3875 raise InvalidIndexError(self._requires_unique_msg)
3877 if len(target) == 0:
3878 return np.array([], dtype=np.intp)
InvalidIndexError: Reindexing only valid with uniquely valued Index objects,请帮我定位并解决问题
最新发布