a value too large for dtype('float64')
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
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.