Filling missing data using scikit

from sklearn.impute import SimpleImputer
We are importing the simple imputer from scikit library.
imputer = SimpleImputer(missing_values=np.nan, strategy=’mean’)
The strategy used is mean, where the missing data is replaced by average of the values.[:, 1:3])
The number of columns on which the above function is used is 2 i.e between 1 and 3.
X[:, 1:3] = imputer.transform(X[:, 1:3])
The new column is again assigned to the 2 columns.

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *