Spaces:
Runtime error
Runtime error
File size: 2,406 Bytes
87d6a85 a83ef18 87d6a85 a126029 a83ef18 87d6a85 a126029 a83ef18 a126029 87d6a85 a83ef18 a126029 87d6a85 a126029 87d6a85 2dd3b91 a83ef18 2dd3b91 87d6a85 a83ef18 87d6a85 a126029 a83ef18 a126029 a83ef18 a126029 a83ef18 a126029 a83ef18 a126029 a83ef18 a126029 f3dd5c4 a126029 a83ef18 f3dd5c4 a126029 87d6a85 |
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# Loading key libraries
import streamlit as st
import os
import numpy as np
import pandas as pd
from PIL import Image
import matplotlib.pyplot as plt
import seaborn as sns
import requests
import datetime
# set api endpoint
URL = 'https://bright1-sales-forecasting-ap1-2.hf.space'
API_ENDPOINT = '/predict'
# get list/choices for inputs
CITIES = ['Accra', 'Aflao', 'Akim Oda', 'Akwatia', 'Bekwai', 'Cape coast', 'Elmina,', 'Gbawe', 'Ho', 'Hohoe', 'intampo', 'Koforidua', 'Kumasi', 'Mampong', 'Obuasi', 'Prestea', 'Suhum', 'Tamale', 'Techiman', 'Tema', 'Teshie', 'Winneba']
CLUSTER = [ i for i in range(0, 17)]
STORE_ID = [ i for i in range(1, 55)]
CATEGORY_ID = [ i for i in range(0, 35)]
# Setting the page configurations
st.set_page_config(page_title = "Prediction Forecasting", layout= "wide", initial_sidebar_state= "auto")
# Setting the page title
st.title("Grocery Store Forecasting Prediction")
# src\app\images1.jpg
image1 = Image.open('images1.jpg')
def make_prediction(store_id, category_id, onpromotion, city, store_type, cluster, date):
parameters = {
'store_id':int(store_id),
'category_id':int(category_id),
'onpromotion' :int(onpromotion),
'city' : city,
'store_type' : int(store_type),
'cluster': int(cluster),
'date_': date,
}
# make a request to the api
response = requests.post(url=f'{URL}{API_ENDPOINT}', params=parameters)
sales_value = response.json()['sales']
sales_value = round(sales_value, 4)
return sales_value
st.image(image1, width = 700)
st.sidebar.markdown('User Input Details and Information')
# Create interface
date= st.sidebar.date_input("Enter the Date",datetime.date(2023, 6, 30))
store_id= st.sidebar.selectbox('Store id', options=STORE_ID)
category_id= st.sidebar.selectbox('categegory_id', options=CATEGORY_ID)
onpromotion= st.sidebar.number_input('onpromotion', step=1)
city = st.sidebar.selectbox("city:", options= CITIES)
store_type= st.sidebar.selectbox('type', options=[0, 1, 2, 3, 4])
cluster = st.sidebar.selectbox('cluster', options = CLUSTER )
# get predicted value
if st.sidebar.button('Predict', use_container_width=True, type='primary'):
# make prediction
sales_value = make_prediction(store_id, category_id, onpromotion,city, store_type, cluster, date)
st.success('The predicted target is ' + str(sales_value))
|