Created
July 24, 2020 06:31
-
-
Save satkr7/45c3a49c007b33ba53b3c896c4309e21 to your computer and use it in GitHub Desktop.
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 pandas as pd | |
pip install datawig | |
import datawig | |
data = pd.read_csv("train.csv") | |
df_train, df_test = datawig.utils.random_split(data) | |
#Initialize a SimpleImputer model | |
imputer = datawig.SimpleImputer( | |
input_columns=['Pclass','SibSp','Parch'], # column(s) containing information about the column we want to impute | |
output_column= 'Age', # the column we'd like to impute values for | |
output_path = 'imputer_model' # stores model data and metrics | |
) | |
#Fit an imputer model on the train data | |
imputer.fit(train_df=df_train, num_epochs=50) | |
#Impute missing values and return original dataframe with predictions | |
imputed = imputer.predict(df_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment