File size: 1,263 Bytes
a60fde7
 
 
 
752230c
 
a60fde7
 
 
 
 
 
 
5c48c60
e49692a
 
5c48c60
 
e49692a
 
a60fde7
 
3b4a01d
a60fde7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2c3bdcf
a60fde7
 
 
 
 
 
 
 
acd7143
a60fde7
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import streamlit as st
import numpy as np
import pandas as pd
import pickle
from statsmodels.tsa.arima.model import ARIMA
from datetime import datetime

st.set_page_config(
    page_title = 'Forecasting',
    layout = 'wide',
    initial_sidebar_state='expanded'
)


with open('mod_train.pkl', 'rb') as file_1:
  mod_train = pickle.load(file_1)



# bikin fungsi  
def run():

  with st.form(key='Forecasting'):
      year = st.selectbox('Year', (2023,2024), index=0)
      month = st.selectbox('Month', (1,2,3,4,5,6,7,8,9,10,11,12), index=3)
      st.markdown('---')

      submitted = st.form_submit_button('Predict')


  data_inf = {
    'year' : year,
    'month': month
  }

  data_inf = pd.DataFrame([data_inf])
  data_inf['date'] = data_inf.apply(lambda x: datetime(x[0], x[1], 1), axis=1)
  data_inf.drop(['year','month'], axis=1, inplace=True)
  data_inf=data_inf.set_index('date')
  #st.dataframe(data_inf)

  if submitted:
      
      #Predict Inference data
      y_pred_test=mod_train.predict(start=data_inf.index[0],end=data_inf.index[-1])
      y_pred_test=pd.DataFrame(y_pred_test)
      y_pred_test.columns=['quantity_predict']

      st.write('# Forcasted quantity for that month is : ', y_pred_test)
      
if __name__ == '__main__':
    run()