mukhlishr commited on
Commit
a60fde7
1 Parent(s): ce57d38

Deployment final project

Browse files
Files changed (5) hide show
  1. app.py +4 -0
  2. mod_train.pkl +3 -0
  3. prediction.py +70 -0
  4. requirements.txt +10 -0
  5. ts.jpg +0 -0
app.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import streamlit as st
2
+ import prediction
3
+
4
+ prediction.run()
mod_train.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c39fe538b89d73af8b564dbd868bd81b562f127445d3b2bcdd1b8ed01cbfa6d
3
+ size 140087
prediction.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pandas as pd
4
+ import matplotlib.pyplot as plt
5
+ from PIL import Image
6
+ import pickle
7
+
8
+
9
+ st.set_page_config(
10
+ page_title = 'Forecasting',
11
+ layout = 'wide',
12
+ initial_sidebar_state='expanded'
13
+ )
14
+
15
+ def run():
16
+
17
+ # Membuat file
18
+ st.title( 'Time Series Forecasting')
19
+
20
+ # Membuat sub header
21
+ st.subheader('Best seller product')
22
+
23
+ # Menambahkan gambar
24
+ image = Image.open('ts.jpg')
25
+ st.image(image, caption='Time Series Analysis')
26
+
27
+ if __name__ == '__main__':
28
+ run()
29
+
30
+
31
+ # Load All Files
32
+
33
+ with open('mod_train.pkl', 'rb') as file_1:
34
+ mod_train = pickle.load(file_1)
35
+
36
+
37
+
38
+ # bikin fungsi
39
+ def run():
40
+
41
+ with st.form(key='forecast quantity'):
42
+ year = st.selectbox('Year', (2023,2024), index=0)
43
+ month = st.selectbox('Month', (1,2,3,4,5,6,7,8,9,10,11,12), index=3)
44
+ st.markdown('---')
45
+
46
+ submitted = st.form_submit_button('Predict')
47
+
48
+
49
+ data_inf = {
50
+ 'year' : year,
51
+ 'month': month
52
+ }
53
+
54
+ data_inf = pd.DataFrame([data_inf])
55
+ data_inf['date'] = data_inf.apply(lambda x: datetime(x[0], x[1], 1), axis=1)
56
+ data_inf.drop(['year','month'], axis=1, inplace=True)
57
+ data_inf=data_inf.set_index('date')
58
+ st.dataframe(data_inf)
59
+
60
+ if submitted:
61
+
62
+ #Predict Inference data
63
+ y_pred_test=mod_train.predict(start=data_inf.index[0],end=data_inf.index[-1])
64
+ y_pred_test=pd.DataFrame(y_pred_test)
65
+ y_pred_test.columns=['quantity_predict']
66
+
67
+ st.write('# Forcasted quantity for that month is : ', str(int(y_pred_test)))
68
+
69
+ if __name__ == '__main__':
70
+ run()
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # daftar library yang dibutuhkan semua
2
+ streamlit
3
+ pandas
4
+ seaborn
5
+ matplotlib
6
+ numpy
7
+ scikit-learn==1.2.1
8
+ datetime
9
+ statsmodels
10
+ plotly
ts.jpg ADDED