python unpack infinity_fit_转换出错:输入包含NaN、infinity或对dtype(“float64”)太大的值...
我有一個形狀的數(shù)據(jù)幀(144072564)。嘗試使用低方差函數(shù)刪除低方差。但是,當(dāng)我調(diào)用fit_transform時,我得到以下錯誤:
ValueError:輸入包含NaN、infinity或?qū)type(“float64”)太大的值。在
在使用VarianceThreshold之前,我使用以下代碼替換df中所有丟失的值:df.replace('null',np.NaN, inplace=True)
df.replace(r'^\s*$', np.NaN, regex=True, inplace=True)
df.fillna(value=df.median(), inplace=True)
之后,我使用以下方法檢查了數(shù)據(jù)幀中的任何空/無限值:
^{pr2}$
我得到了一個空序列作為輸出,這意味著我所有的列都沒有丟失的值。結(jié)果是:========= COLUMNS WITH NULL VALUES =================
Series([], dtype: bool)
========= COLUMNS WITH INFINITE VALUES =================
Series([], dtype: bool)
完整錯誤跟蹤:Traceback (most recent call last):
File "/home/users/MyUsername/MyProject/src/main/python/Main.py", line 222, in
main()
File "/home/users/MyUsername/MyProject/src/main/python/Main.py", line 218, in main
getAllData()
File "/home/users/MyUsername/MyProject/src/main/python/Main.py", line 95, in getAllData
predictors, labels, dropped_features = fselector.process(variance=True, corr=True, bestf=True, bestfk=200)
File "/home/users/MyUsername/MyProject/src/main/python/classes/featureselector.py", line 54, in process
self.getVariance(threshold=(.95 * (1 - .95)))
File "/home/users/MyUsername/MyProject/src/main/python/classes/featureselector.py", line 136, in getVariance
self.removeLowVarianceColumns(df=self.X, thresh=threshold)
File "/home/users/MyUsername/MyProject/src/main/python/classes/featureselector.py", line 213, in removeLowVarianceColumns
selector.fit_transform(df)
File "/usr/lib64/python2.7/site-packages/sklearn/base.py", line 494, in fit_transform
return self.fit(X, **fit_params).transform(X)
File "/usr/lib64/python2.7/site-packages/sklearn/feature_selection/variance_threshold.py", line 64, in fit
X = check_array(X, ('csr', 'csc'), dtype=np.float64)
File "/usr/lib64/python2.7/site-packages/sklearn/utils/validation.py", line 407, in check_array
_assert_all_finite(array)
File "/usr/lib64/python2.7/site-packages/sklearn/utils/validation.py", line 58, in _assert_all_finite
" or a value too large for %r." % X.dtype)
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
所以,我不確定要檢查什么,這似乎不是缺少值的問題,但我也無法獲得導(dǎo)致問題的列/值。在
我在這里看到了幾個線程都以缺少值結(jié)尾,但這似乎不是問題所在。在
總結(jié)
以上是生活随笔為你收集整理的python unpack infinity_fit_转换出错:输入包含NaN、infinity或对dtype(“float64”)太大的值...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深度解析 H.265 视频解决方案
- 下一篇: 在Linux下编写Daemon