Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

a value too large for dtype('float64') [closed]

I'm using numpy for reading an arff file and I'm getting the following error:

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

I used np.isnan(X2.any()) and np.isfinite(X2.all())to check if it's a nan or infinite case. But it's none of these. This means it's the third case, which is infinity or a value too large for dtype('float64').

I would appreciate if someone could tell me how to take care of this error.

Thanks.

like image 792
user2151788 Avatar asked Mar 15 '15 13:03

user2151788


1 Answers

Ok I got it. After i used Imputer(missing_values='NaN', strategy='median', axis=1) imp.fit(X2). I also had to write :

X2 = imp.fit_transform(X2). The reason being sklearn.preprocessing.Imputer.fit_transform returns a new array, it doesn't alter the argument array

like image 181
user2151788 Avatar answered Nov 08 '22 20:11

user2151788