demand-forecast / prediction.py
bagus
first deploy
bcbc2e2
raw
history blame contribute delete
No virus
948 Bytes
import streamlit as st
import pandas as pd
import pickle
import json
# from statsmodels.tsa.holtwinters import ExponentialSmoothing
# Load All Files
with open('model_forecasting.pkl', 'rb') as file_1:
model = pickle.load(file_1)
def run():
# create Streamlit app
st.title('Demand Forecasting')
# display prediction
# st.write('Prediction:', prediction)
with st.form(key='form_forecasting_2022'):
start_date = st.date_input(
'Start date', value=pd.to_datetime('2023-04-16'))
end_date = st.date_input(
'End date', value=pd.to_datetime('2023-04-30'))
st.markdown('---')
submitted = st.form_submit_button('Predict')
if submitted:
prediction = model.predict(start=start_date, end=end_date)
st.write("Hasil prediksi pada tanggal ", start_date, ":", prediction)
# agar bisa di run sendiri, tanpa dari main
if __name__ == '__main__':
run()