Skip to content

Instantly share code, notes, and snippets.

@aagnone3
Created October 30, 2020 00:20
Show Gist options
  • Save aagnone3/7754ec6bbb31dd760efa0d0d32f570e4 to your computer and use it in GitHub Desktop.
Save aagnone3/7754ec6bbb31dd760efa0d0d32f570e4 to your computer and use it in GitHub Desktop.
sf_crime_15.py
fig = make_subplots(
rows=1, cols=2,
subplot_titles=(
"Classwise Score Distributions",
"Train vs Validation Score Distributions"
)
)
# class-wise score distributions
fig_distplots = ff.create_distplot(
[y_pred[~mask_positive_class], y_pred[mask_positive_class]],
["Negative", "Positive"],
show_hist=False, show_rug=False,
)
for trace in fig_distplots.select_traces():
fig.add_trace(trace, row=1, col=1)
fig.update_xaxes(range=(0, 1), row=1, col=1)
fig['layout']['xaxis2']['title'] = dict(text='Score')
fig['layout']['yaxis2']['title'] = dict(text='P(Score)')
# train vs validation score distributions
fig_distplots = ff.create_distplot(
[y_train_pred, y_pred],
["Training", "Validation"],
show_hist=False, show_rug=False
)
for trace in fig_distplots.select_traces():
fig.add_trace(trace, row=1, col=2)
fig.update_xaxes(range=(0, 1), row=1, col=2)
fig['layout']['xaxis2']['title'] = dict(text='Score')
fig['layout']['yaxis2']['title'] = dict(text='P(Score)')
fig.update_layout(showlegend=False)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment