Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from datetime import date
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import joblib
|
| 6 |
+
|
| 7 |
+
# web page
|
| 8 |
+
# tittle
|
| 9 |
+
st.title('Favorita Store Sales Prediction APP with Facebook Prophet')
|
| 10 |
+
st.markdown('this predict sales')
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# data loading
|
| 14 |
+
best_model= joblib.load('saved_ml.joblib')
|
| 15 |
+
|
| 16 |
+
# inputs
|
| 17 |
+
st.header('make a forecast here:')
|
| 18 |
+
ds= st.date_input(label='Please enter your forecast date')
|
| 19 |
+
transactions= st.number_input(label='Please enter your total expected number of transactions')
|
| 20 |
+
onpromotion= st.number_input(label='Please enter total number of items on promotion')
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# input dataframe
|
| 24 |
+
ok= st.button('forecast sales')
|
| 25 |
+
if ok:
|
| 26 |
+
input_data= [ds,onpromotion,transactions]
|
| 27 |
+
inputs= pd.DataFrame([input_data],columns=['ds','onpromotion','transactions'])
|
| 28 |
+
# making Prediction
|
| 29 |
+
forecast=model.predict(inputs)
|
| 30 |
+
output_values=forecast['yhat']
|
| 31 |
+
st.success (f'the estimated forecast sales ${output_values.values[0]:.2f}')
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|