im trying to displays forecasting timeseries using streamlit,but im stuck because i dont know what should i do first,bcs for timeseries im using jupyter notebook and i got confused how to displays it with streamlit(issue with stationary,etc).Can you guys give me reference or something? thank you! here is my code in spyder ( im just showing raw data and the graph and yeah got stuck with deploy my forecasting)
import streamlit as st
import pandas as pd
import numpy as np
import plotly.express as px
import matplotlib.pyplot as plt
from statsmodels.tsa.stattools import acf,pacf
from statsmodels.tsa.stattools import adfuller
from statsmodels.tsa.arima_model import ARIMA
import warnings # `do not disturbe` mode
warnings.filterwarnings('ignore')
st.title('Forecasting Harga KCL')
DATE_COLUMN = 'month'
@st.cache
def load_data(nrows):
data = pd.read_csv('kcl.csv', nrows=nrows)
lowercase = lambda x: str(x).lower()
data.rename(lowercase, axis='columns', inplace=True)
data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
data.set_index('month', inplace=True)
data =data['price']
return data
data_load_state = st.text('Loading data...')
data = load_data(300)
data_load_state.text("Done! (using st.cache)")
if st.checkbox('Show raw data'):
st.subheader('Raw data')
st.write(data)
st.subheader('Plot harga')
st.line_chart(data)
st.subheader('Harga Prediksi')
about this code below i dont know if its right because the timeseries doesnt pass the stationary test at all and the forecasting might go wrong
data = data [66:]
for a in range(1,30):
model = ARIMA (data, order = (1, 1, 1))
model_fit = model.fit(disp=False)
yhat = model_fit.predict(len(data), len(data), typ='levels')
data = data.append(yhat)
st.write(yhat)
# We display the prediction to see when it passes 0
if st.checkbox('Show hasil prediksi'):
st.subheader('data prediction')
st.write(yhat)
i hope you all can understand me with my lack of understanding and making question! thank you in advance