Spaces:
Runtime error
Runtime error
Commit
·
a6043ed
1
Parent(s):
a07de77
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,26 @@ import streamlit as st
|
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
uploaded_file = st.file_uploader("Choose a CSV file", accept_multiple_files=False)
|
| 7 |
if uploaded_file is not None:
|
| 8 |
-
# Can be used wherever a "file-like" object is accepted:
|
| 9 |
dataframe = pd.read_csv(uploaded_file)
|
| 10 |
st.write(dataframe)
|
| 11 |
series = st.text_input("Write the name of the variable you want to forecast")
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
st.plotly_chart(fig)
|
|
|
|
| 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 |
+
|
| 8 |
+
st.title('Forecasting time series')
|
| 9 |
|
| 10 |
uploaded_file = st.file_uploader("Choose a CSV file", accept_multiple_files=False)
|
| 11 |
if uploaded_file is not None:
|
|
|
|
| 12 |
dataframe = pd.read_csv(uploaded_file)
|
| 13 |
st.write(dataframe)
|
| 14 |
series = st.text_input("Write the name of the variable you want to forecast")
|
| 15 |
+
date = st.text_input("Write the first date")
|
| 16 |
+
freq = st.text_input("Write the frequency")
|
| 17 |
+
if series is not None:
|
| 18 |
+
series_train = pd.DataFrame(
|
| 19 |
+
{
|
| 20 |
+
'ds': pd.date_range(start=date, periods=dataframe.shape[0], freq=freq),
|
| 21 |
+
'y': dataframe[series]
|
| 22 |
+
},
|
| 23 |
+
index=pd.Index([0] * dataframe.shape[0], name='unique_id')
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
fig = px.line(series_train, x='ds', y='y', title=f'{series}')
|
| 27 |
st.plotly_chart(fig)
|