Skip to content

Instantly share code, notes, and snippets.

@marcosan93
Last active October 18, 2021 18:31
Show Gist options
  • Select an option

  • Save marcosan93/a75b0a9dae9f28228d6766dbf07275cd to your computer and use it in GitHub Desktop.

Select an option

Save marcosan93/a75b0a9dae9f28228d6766dbf07275cd to your computer and use it in GitHub Desktop.
# Making a comparison DF
compare = pd.DataFrame()
compare['actual'] = y_test[col_name].reset_index(
drop=True
)
compare['preds'] = preds
# Check to see if the predictions at least point in the correct direction
compare['same_direction'] = (
compare['actual'].apply(
lambda x: x>0
)==compare['preds'].apply(
lambda x: x>0
)
)
display(compare)
# How often did predictions land in the same direction as the actual values?
dir_df = compare['same_direction'].value_counts().to_frame()
# Visualizing results
fig = px.scatter(
compare,
x=compare.index,
y=['preds', 'actual'],
title='Actual vs Preds'
)
fig.show()
fig = px.pie(
dir_df,
names=dir_df.index,
values=dir_df['same_direction'],
title='How often did predictions land in the same direction as the actual values?'
)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment