Predicting missing values with scikit-learn's Imputer module

我是研究僧i 提交于 2019-12-03 05:05:44

Per the documentation, sklearn.preprocessing.Imputer.fit_transform returns a new array, it doesn't alter the argument array. The minimal fix is therefore:

X = imp.fit_transform(X)
MD SAZID KHAN

As the new array is returned from the transform function, therefore, I have to store it in the same array (X) to alter the values

 from sklearn.preprocessing import Imputer
 imputer = Imputer(missing_values='NaN',strategy='mean',axis=0)  
 imputer = imputer.fit(X[:,1:3])
 X[:,1:3]= imputer.transform(X[:,1:3])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!