Predicting missing values with scikit-learn's Imputer module

后端 未结 3 1616
情话喂你
情话喂你 2021-02-05 09:48

I am writing a very basic program to predict missing values in a dataset using scikit-learn\'s Imputer class.

I have made a NumPy array, created an Imp

3条回答
  •  野的像风
    2021-02-05 10:06

    Note: Due to the change in the sklearn library 'NaN' has to be replaced with np.nan as shown below.

     from sklearn.preprocessing import Imputer
     imputer = Imputer(missing_values= np.nan,strategy='mean',axis=0)  
     imputer = imputer.fit(X[:,1:3])
     X[:,1:3]= imputer.transform(X[:,1:3])
    

提交回复
热议问题