Skip to content

Instantly share code, notes, and snippets.

@emredjan
Created April 23, 2018 17:19
Show Gist options
  • Save emredjan/b598bbebafa5c49465e4b60dcdf5f6a3 to your computer and use it in GitHub Desktop.
Save emredjan/b598bbebafa5c49465e4b60dcdf5f6a3 to your computer and use it in GitHub Desktop.
plot_lm_1 = plt.figure(1)
plot_lm_1.set_figheight(8)
plot_lm_1.set_figwidth(12)
plot_lm_1.axes[0] = sns.residplot(model_fitted_y, 'mpg', data=auto,
lowess=True,
scatter_kws={'alpha': 0.5},
line_kws={'color': 'red', 'lw': 1, 'alpha': 0.8})
plot_lm_1.axes[0].set_title('Residuals vs Fitted')
plot_lm_1.axes[0].set_xlabel('Fitted values')
plot_lm_1.axes[0].set_ylabel('Residuals')
# annotations
abs_resid = model_abs_resid.sort_values(ascending=False)
abs_resid_top_3 = abs_resid[:3]
for i in abs_resid_top_3.index:
plot_lm_1.axes[0].annotate(i,
xy=(model_fitted_y[i],
model_residuals[i]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment