Last active
October 18, 2021 18:31
-
-
Save marcosan93/a75b0a9dae9f28228d6766dbf07275cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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