Spaces:
Runtime error
Runtime error
Commit
·
09e0298
1
Parent(s):
3a3ce5b
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
|
|
|
| 5 |
from statsforecast import StatsForecast
|
| 6 |
from statsforecast.models import seasonal_naive, auto_arima
|
| 7 |
from utils import calc_seasonality
|
|
@@ -39,16 +40,51 @@ if uploaded_file is not None:
|
|
| 39 |
)
|
| 40 |
forecasts = fcst.forecast(horizons, level=(80, 95))
|
| 41 |
st.write(forecasts)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
st.plotly_chart(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
| 5 |
+
import plotly.graph_objs as go
|
| 6 |
from statsforecast import StatsForecast
|
| 7 |
from statsforecast.models import seasonal_naive, auto_arima
|
| 8 |
from utils import calc_seasonality
|
|
|
|
| 40 |
)
|
| 41 |
forecasts = fcst.forecast(horizons, level=(80, 95))
|
| 42 |
st.write(forecasts)
|
| 43 |
+
|
| 44 |
+
fig_forecast = go.Figure([
|
| 45 |
+
go.Scatter(
|
| 46 |
+
name=series,
|
| 47 |
+
x=series_train['ds'],
|
| 48 |
+
y=series_train['y'],
|
| 49 |
+
mode='line',
|
| 50 |
+
line=dict(color='blue', width=1),
|
| 51 |
+
showlegend=True
|
| 52 |
+
),
|
| 53 |
+
go.Scatter(
|
| 54 |
+
name=f'auto_arima_season_length-{seasonality}_mean',
|
| 55 |
+
x=forecasts['ds'],
|
| 56 |
+
y=forecasts[f'auto_arima_season_length-{seasonality}_mean'],
|
| 57 |
+
mode='lines',
|
| 58 |
+
line=dict(color='green', width=1),
|
| 59 |
+
showlegend=True
|
| 60 |
+
),
|
| 61 |
+
go.Scatter(
|
| 62 |
+
name=f'seasonal_naive_season_length-{seasonality}',
|
| 63 |
+
x=forecasts['Time'],
|
| 64 |
+
y=forecasts[f'seasonal_naive_season_length-{seasonality}'],
|
| 65 |
+
line=dict(color='red', width=1),
|
| 66 |
+
mode='lines',
|
| 67 |
+
fillcolor='rgba(68, 68, 68, 0.3)',
|
| 68 |
+
fill='tonexty',
|
| 69 |
+
showlegend=True
|
| 70 |
+
)
|
| 71 |
+
])
|
| 72 |
+
fig.update_layout(
|
| 73 |
+
yaxis_title=series,
|
| 74 |
+
title=f'Forecasting {series}'
|
| 75 |
+
)
|
| 76 |
st.plotly_chart(fig)
|
| 77 |
+
|
| 78 |
+
# fig.add_scatter(x=forecasts['ds'], y=forecasts[f'auto_arima_season_length-{seasonality}_mean'], mode='lines')
|
| 79 |
+
# fig.update_traces(
|
| 80 |
+
# name=f'auto_arima_season_length-{seasonality}_mean',
|
| 81 |
+
# line=dict(color='green', width=1),
|
| 82 |
+
# showlegend=True
|
| 83 |
+
# )
|
| 84 |
+
# fig.add_scatter(x=forecasts['ds'], y=forecasts[f'seasonal_naive_season_length-{seasonality}'], mode='lines')
|
| 85 |
+
# fig.update_traces(
|
| 86 |
+
# name=f'seasonal_naive_season_length-{seasonality}',
|
| 87 |
+
# line=dict(color='red', width=1),
|
| 88 |
+
# showlegend=True
|
| 89 |
+
# )
|
| 90 |
+
# st.plotly_chart(fig)
|