Keep getting the error 'Input contains NaN, infinity or a value too large for dtype('float32')' when trying to run a random forest regressor model. I've searched my data set and cant see any infinite values or NaN. Any suggestions?
[96] df.replace([np.inf, -np.inf], np.nan, inplace=True)
[98] df.fillna('mean', inplace=True)
[100] model = RandomForestRegressor()
model.fit(X_train, y_train)
Any suggestions would be greatly appreciated, please request more details if required.
Thanks
Have you checked this answer? https://datascience.stackexchange.com/questions/11928/valueerror-input-contains-nan-infinity-or-a-value-too-large-for-dtypefloat32
Alternatively, the error says the number might be too big for dtype('float32'), you could try converting them to dtype('float64') as this would allow larger numbers to be stored in memory.