I am writing a very basic program for predicting missing values ββin a dataset using the scikit-learn Imputer class .
I created a NumPy array, created an Imputer object with the strategy = 'mean' and executed fit_transform () on the NumPy array.
When I print an array after doing fit_transform (), "Nan stays and I don't get any prediction."
What am I doing wrong here? How can I predict missing values?
import numpy as np from sklearn.preprocessing import Imputer X = np.array([[23.56],[53.45],['NaN'],[44.44],[77.78],['NaN'],[234.44],[11.33],[79.87]]) print X imp = Imputer(missing_values='NaN', strategy='mean', axis=0) imp.fit_transform(X) print X
python numpy scikit-learn prediction
xennygrimmato
source share