Skip to content

Instantly share code, notes, and snippets.

@betterdatascience
Created November 4, 2020 11:34
Show Gist options
  • Save betterdatascience/678bbd2ec1e069270f4fa1ca68bff34d to your computer and use it in GitHub Desktop.
Save betterdatascience/678bbd2ec1e069270f4fa1ca68bff34d to your computer and use it in GitHub Desktop.
004_missforest
# Add imputed values as columns to the untouched dataset
iris_orig['MF_sepal_length'] = X_imputed[:, 0]
iris_orig['MF_petal_width'] = X_imputed[:, -1]
comparison_df = iris_orig[['sepal_length', 'MF_sepal_length', 'petal_width', 'MF_petal_width']]
# Calculate absolute errors
comparison_df['ABS_ERROR_sepal_length'] = np.abs(compaison_df['sepal_length'] - comparison_df['MF_sepal_length'])
comparison_df['ABS_ERROR_petal_width'] = np.abs(compaison_df['petal_width'] - comparison_df['MF_petal_width'])
# Show only rows where imputation was performed
comparison_df.iloc[sorted([*inds1, *inds2])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment