Created
July 6, 2020 12:35
-
-
Save finlytics-hub/8b58546d2fc5333b6fbaad79f4919540 to your computer and use it in GitHub Desktop.
Practical demonstration of SimpleImputer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import the required library | |
from sklearn.impute import SimpleImputer | |
# define imputer | |
imputer = SimpleImputer(strategy='mean') # other options include: median, most_frequent, constant | |
# fit on the training dataset | |
imputer.fit(X_train) | |
# transform the training dataset (don't forget to transform the test dataset as well) | |
X_train_clean = pd.DataFrame(imputer.transform(X_train), columns = X_train.columns, index = X_train.index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment