Created
June 3, 2019 19:03
-
-
Save Diyago/70779ec1234bb2f5ffaddf1fc2b3edea 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 plot_anomalies(forecasted): | |
interval = alt.Chart(forecasted).mark_area(interpolate="basis", color = '#7FC97F').encode( | |
x=alt.X('ds:T', title ='date'), | |
y='yhat_upper', | |
y2='yhat_lower', | |
tooltip=['ds', 'fact', 'yhat_lower', 'yhat_upper'] | |
).interactive().properties( | |
title='Anomaly Detection' | |
) | |
fact = alt.Chart(forecasted[forecasted.anomaly==0]).mark_circle(size=15, opacity=0.7, color = 'Black').encode( | |
x='ds:T', | |
y=alt.Y('fact', title='sales'), | |
tooltip=['ds', 'fact', 'yhat_lower', 'yhat_upper'] | |
).interactive() | |
anomalies = alt.Chart(forecasted[forecasted.anomaly!=0]).mark_circle(size=30, color = 'Red').encode( | |
x='ds:T', | |
y=alt.Y('fact', title='sales'), | |
tooltip=['ds', 'fact', 'yhat_lower', 'yhat_upper'], | |
size = alt.Size( 'importance', legend=None) | |
).interactive() | |
return alt.layer(interval, fact, anomalies)\ | |
.properties(width=870, height=450)\ | |
.configure_title(fontSize=20) | |
plot_anomalies(pred) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, can you please give an alternative to alt, for some reason after updating my jupyter lab and multiple tries alt refuses to render.
Much thanks!