Skip to content

Instantly share code, notes, and snippets.

@katronai
Last active March 3, 2020 22:57
Show Gist options
  • Save katronai/10ee85cfc238d29f4c61326065778551 to your computer and use it in GitHub Desktop.
Save katronai/10ee85cfc238d29f4c61326065778551 to your computer and use it in GitHub Desktop.
Impute missing values
imputer = Imputer(missing_values='NaN', strategy='mean', axis=0)
# imputer = Imputer(missing_values='NaN', strategy='median', axis=0)
# imputer = Imputer(missing_values='NaN', strategy='most_frequent', axis=0)
# imputer = Imputer(missing_values=0, strategy='mean', axis=0)
X_train = imputer.fit_transform(X_train)
X_test = imputer.transform(X_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment