Skip to content

Instantly share code, notes, and snippets.

@vikramsoni2
Last active March 2, 2022 15:25
Show Gist options
  • Save vikramsoni2/ef332fa59caf3229affbd64c54856a22 to your computer and use it in GitHub Desktop.
Save vikramsoni2/ef332fa59caf3229affbd64c54856a22 to your computer and use it in GitHub Desktop.
regression residual plot bokeh
def residual_plot(y_true, y_pred, **kwargs):
line_end = np.max([df['O_target'].max(), df['prediction'].max()])
p = figure(plot_width=900, plot_height=500, title="Residual Plot",
x_axis_label='Actual', y_axis_label='Predicted', **kwargs )
data = { 'Actual': y_true, 'Predicted': y_pred }
p.circle(x='Actual', y='Predicted', source=data, fill_color='red', alpha=0.8, line_width=0.2, line_color='black')
p.line(x=[-500,line_end], y=[-500,line_end], line_width=1, line_color='gray', line_alpha=0.5)
for i in range(len(y_true)):
p.line(x=[y_true[i],y_true[i]], y=[y_true[i],y_pred[i]], line_width=1, line_color='#6ca2cc')
show(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment