user17637519
user17637519

Reputation: 31

ValueError: Input contains NaN, infinity or a value too large for dtype('float64') when using randomizedSearch

I am trying to use RandomizedSearchCV from sklearn on an MLPRegressor model, and I have scaled the data using standardScaler. The code for the model is presented below. When I try to run the code I get this error from the ann_random.fit(x_train,y_train.flatten()):

ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). 

I have checked if the dataset contains any nan or infinite values, but there seems like there is none. I have also tried to run the code with an MLPRegressor model with the given hyperparametes:

model = MLPRegressor(activation='relu', solver='adam', hidden_layer_sizes=(150,100,50), max_iter=500)

and the code works fine when I run the MLPRegressor model without the randomizedsearch.

What can be the cause of this error?

enter image description here

Upvotes: -1

Views: 861

Answers (1)

abolfazlmalekahmadi
abolfazlmalekahmadi

Reputation: 278

before tarin model first take look at your data : first find missing value with thid code :

df.isnall().sum()

if in your data have missing value remove them or fill them

df = df.dropna()

second: normalize your data between 0 and 1 i hope my solution help you

Upvotes: 0

Related Questions