當我嘗試在Python中執行此:值太大D型( 'float64')sklearn.preprocessing .StandardScaler()
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
我得到這個錯誤:
ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
我知道有些帖子的標題相同,但大多數情況下問題是因爲數據是NaN
,這不是我的情況,因爲我嘗試了下面的函數來判斷是否存在NaN
或無窮大數字:
numpy.isfinite(X_train.all())
其中X_train
是我的浮陣列
(https://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.isfinite.html)
下面是在X_train
數據的種類。也許這些數據的範圍從-15到4000左右的範圍太寬而無法進行縮放?
4068.725
4035.808
4067.000
4051.697
412761.343
101.905
4050.460
4067.000
-15.303
1.099
52.363
56.739
68.997
72.410
62.171
4052.077
4033.867
33.385
4050.690
4031.547
19.143
13.494
11.298
43.261
'numpy.isfinite(X_train).all()'? – Psidom