As stated in the error above, the data is mixed with non-NaN, inf or float64 types. I wrote a column containing a character string in pandas as follows, and even though I filled in Na, an error occurred.
df=df.drop(columns=df.select_dtypes(include='object').columns)
It seems that it is not possible to convert values other than float that are partly included in the column. So, after converting to ndarray so that it can be used with numpy, those with values other than float were converted to float type, those that could not be changed to float type were converted to Na, and then the missing values were converted.
X = df.iloc[:, 1:].values
y = df.iloc[:, 0].values
for i in range(X.shape[1]):
X[:,i]= pd.to_numeric(X[:,i], errors='coerce')
X1=np.nan_to_num(X)
I'm not sure if this is the correct process, but for the time being, the error when training the model is gone. Please comment if there is any good way.
Recommended Posts