Created
September 23, 2021 18:48
-
-
Save marcosan93/17d172490586d07d63047f633891d428 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
def visFBP(df, forecast): | |
""" | |
Given two dataframes: before training df and a forecast df, returns | |
a visual chart of the predicted values and actual values. | |
""" | |
# Visual DF | |
vis_df = df[['ds','Open']].append(forecast).rename( | |
columns={'yhat': 'Prediction', | |
'yhat_upper': "Predicted High", | |
'yhat_lower': "Predicted Low"} | |
) | |
# Visualizing results | |
fig = px.line( | |
vis_df, | |
x='ds', | |
y=['Open', 'Prediction', 'Predicted High', 'Predicted Low'], | |
title='Crypto Forecast', | |
labels={'value':'Price', | |
'ds': 'Date'} | |
) | |
# Adding a slider | |
fig.update_xaxes( | |
rangeselector=dict( | |
buttons=list([ | |
dict(count=1, label="1m", step="month", stepmode="backward"), | |
dict(count=3, label="3m", step="month", stepmode="backward"), | |
dict(count=6, label="6m", step="month", stepmode="backward"), | |
dict(count=1, label="YTD", step="year", stepmode="todate"), | |
dict(count=1, label="1y", step="year", stepmode="backward"), | |
dict(step="all") | |
]) | |
) | |
) | |
return fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment