Skip to content

Instantly share code, notes, and snippets.

@groverpr
Created December 8, 2017 04:35
Show Gist options
  • Select an option

  • Save groverpr/763708ee0c93636110e031b23361c83e to your computer and use it in GitHub Desktop.

Select an option

Save groverpr/763708ee0c93636110e031b23361c83e to your computer and use it in GitHub Desktop.
plotting prediction and residuals
# plotting after prediction
xa = np.array(x.x) # column name of x is x
order = np.argsort(xa)
xs = np.array(xa)[order]
ys = np.array(predf)[order]
#epreds = np.array(epred[:,None])[order]
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize = (13,2.5))
ax1.plot(x,y, 'o')
ax1.plot(xs, ys, 'r')
ax1.set_title(f'Prediction (Iteration {i+1})')
ax1.set_xlabel('x')
ax1.set_ylabel('y / y_pred')
ax2.plot(x, ei, 'go')
ax2.set_title(f'Residuals vs. x (Iteration {i+1})')
ax2.set_xlabel('x')
ax2.set_ylabel('Residuals')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment