我有一个数据集,经过它之后我似乎没有找到任何NaN
值,但不幸的是,TypeError: ufunc 'isnan' not supported
当我运行代码时得到了。
import pandas as pd
import numpy as np
dfData = pd.read_csv('datasets/disambiguate_spam_sms.csv', encoding="latin-1")
from sklearn.model_selection import train_test_split
training_indices, validation_indices = training_indices, testing_indices = train_test_split(sms_label,
stratify = sms_label,
train_size=0.75, test_size=0.25)
training_indices.size, validation_indices.size
from tpot import TPOTClassifier
from tpot import TPOTRegressor
tpot = TPOTClassifier(generations=5, verbosity=2)
tpot.fit(sms_data.drop('label',axis=1).loc[training_indices].values,
sms_data.loc[training_indices,'label'].values)
下面的代码是我的错误代码,它一直指向sms_data.loc[training_indices,'label'].values)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-102-3df5d5a2120f> in <module>()
5
6 tpot.fit(sms_data.drop('label',axis=1).loc[training_indices].values,
----> 7 sms_data.loc[training_indices,'label'].values)
/home/emma/.local/lib/python3.6/site-packages/tpot/base.py in fit(self, features, target, sample_weight, groups)
658 """
659 self._fit_init()
--> 660 features, target = self._check_dataset(features, target, sample_weight)
661
662
/home/emma/.local/lib/python3.6/site-packages/tpot/base.py in _check_dataset(self, features, target, sample_weight)
1175 else:
1176 if isinstance(features, np.ndarray):
-> 1177 if np.any(np.isnan(features)):
1178 self._imputed = True
1179 elif isinstance(features, DataFrame):
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''