Commit
·
c2b54d0
0
Parent(s):
Duplicate from KwabenaMufasa/Grocery_Store_Time_Series_Forecasting
Browse filesCo-authored-by: Foster Nana Kwabena Abrefa <KwabenaMufasa@users.noreply.huggingface.co>
- .gitattributes +36 -0
- Dockerfile +21 -0
- Grocery.csv +3 -0
- README.md +11 -0
- app.py +108 -0
- image 2.jpg +0 -0
- images1.jpg +0 -0
- requirements.txt +9 -0
- toolkit_folder +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
Grocery.csv filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
WORKDIR /code
|
| 5 |
+
|
| 6 |
+
# Create a writable directory for the cache
|
| 7 |
+
RUN mkdir -p /.cache/huggingface/hub && chmod -R 777 /.cache
|
| 8 |
+
|
| 9 |
+
# Set the TRANSFORMERS_CACHE environment variable
|
| 10 |
+
ENV TRANSFORMERS_CACHE /.cache/huggingface/hub
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 14 |
+
|
| 15 |
+
RUN pip3 install --upgrade pip
|
| 16 |
+
|
| 17 |
+
RUN pip3 install -r requirements.txt
|
| 18 |
+
|
| 19 |
+
COPY . .
|
| 20 |
+
|
| 21 |
+
CMD ["streamlit","run","app.py", "--server.address", "0.0.0.0", "--server.port", "7860", "--browser.serverAddress", "kwasiasomani-Docker.hf.space", "--browser.serverAddress","0.0.0.0:7860"]
|
Grocery.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c2026ebae35dd7285f1ac84c4dd08c760f672e68aee2aefa128bab8ee0aedad8
|
| 3 |
+
size 162805137
|
README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Grocery Store Time Series Forecasting
|
| 3 |
+
emoji: 🔥
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
duplicated_from: KwabenaMufasa/Grocery_Store_Time_Series_Forecasting
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Loading key libraries
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import os
|
| 4 |
+
import pickle
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import re
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
from PIL import Image
|
| 10 |
+
import matplotlib.pyplot as plt
|
| 11 |
+
import seaborn as sns
|
| 12 |
+
import requests
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# set api endpoint
|
| 18 |
+
URL = 'https://bright1-sales-forecasting-api.hf.space'
|
| 19 |
+
API_ENDPOINT = '/predict'
|
| 20 |
+
|
| 21 |
+
# Setting the page configurations
|
| 22 |
+
st.set_page_config(page_title = "Prediction Forecasting", layout= "wide", initial_sidebar_state= "auto")
|
| 23 |
+
|
| 24 |
+
# Setting the page title
|
| 25 |
+
st.title("Grocery Store Forecasting Prediction")
|
| 26 |
+
|
| 27 |
+
# Load the saved data
|
| 28 |
+
df = pd.read_csv('Grocery.csv')
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
image1 = Image.open('images1.jpg')
|
| 32 |
+
image2 = Image.open('image 2.jpg')
|
| 33 |
+
|
| 34 |
+
def make_prediction(store_id, category_id, onpromotion, year,month, dayofmonth,
|
| 35 |
+
dayofweek, dayofyear,weekofyear, quarter, is_month_start, is_month_end,
|
| 36 |
+
is_quarter_start, is_quarter_end, is_year_start, is_year_end,
|
| 37 |
+
year_weekofyear,city, store_type, cluster):
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
parameters = {
|
| 41 |
+
'store_id':int(store_id),
|
| 42 |
+
'category_id':int(category_id),
|
| 43 |
+
'onpromotion' :int(onpromotion),
|
| 44 |
+
'year' : int(year),
|
| 45 |
+
'month' : int(month),
|
| 46 |
+
'dayofmonth' :int(dayofmonth),
|
| 47 |
+
'dayofweek' : int(dayofweek),
|
| 48 |
+
'dayofyear' : int(dayofyear),
|
| 49 |
+
'weekofyear' : int(weekofyear),
|
| 50 |
+
'quarter' : int(quarter),
|
| 51 |
+
'is_month_start' : int(is_month_start),
|
| 52 |
+
'is_month_end' : int(is_month_end),
|
| 53 |
+
'is_quarter_start' : int(is_quarter_start),
|
| 54 |
+
'is_quarter_end' : int(is_quarter_end),
|
| 55 |
+
'is_year_start' : int(is_year_start),
|
| 56 |
+
'is_year_end' : (is_year_end),
|
| 57 |
+
'year_weekofyear' : int(year_weekofyear),
|
| 58 |
+
'city' : city,
|
| 59 |
+
'store_type' : int(store_type),
|
| 60 |
+
'cluster': int(cluster),
|
| 61 |
+
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
response = requests.post(url=f'{URL}{API_ENDPOINT}', params=parameters)
|
| 66 |
+
sales_value = response.json()['sales']
|
| 67 |
+
sales_value = round(sales_value, 4)
|
| 68 |
+
return sales_value
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
st.image(image1, width = 700)
|
| 72 |
+
|
| 73 |
+
st.sidebar.markdown('User Input Details and Information')
|
| 74 |
+
|
| 75 |
+
store_id= st.sidebar.selectbox('store_id', options = sorted(list(df['store_id'].unique())))
|
| 76 |
+
category_id= st.sidebar.selectbox('categegory_id',options = sorted(list(df['category_id'].unique())))
|
| 77 |
+
onpromotion= st.sidebar.number_input('onpromotion', min_value= df["onpromotion"].min(), value= df["onpromotion"].min())
|
| 78 |
+
year = st.sidebar.selectbox('year', options = sorted(list(df['year'].unique())))
|
| 79 |
+
month = st.sidebar.selectbox('month', options = sorted(list(df['month'].unique())))
|
| 80 |
+
dayofmonth= st.sidebar.number_input('dayofmonth', min_value= df["dayofmonth"].min(), value= df["dayofmonth"].min())
|
| 81 |
+
dayofweek = st.sidebar.number_input('dayofweek', min_value= df["dayofweek"].min(), value= df["dayofweek"].min())
|
| 82 |
+
dayofyear = st.sidebar.number_input('dayofyear', min_value= df["dayofyear"].min(), value= df["dayofyear"].min())
|
| 83 |
+
weekofyear = st.sidebar.number_input('weekofyear', min_value= df["weekofyear"].min(), value= df["weekofyear"].min())
|
| 84 |
+
quarter = st.sidebar.number_input('quarter', min_value= df["quarter"].min(), value= df["quarter"].min())
|
| 85 |
+
is_month_start = st.sidebar.number_input('is_month_start', min_value= df["is_month_start"].min(), value= df["is_month_start"].min())
|
| 86 |
+
is_month_end = st.sidebar.number_input('is_month_end', min_value= df["is_month_end"].min(), value= df["is_month_end"].min())
|
| 87 |
+
is_quarter_start = st.sidebar.number_input('is_quarter_start', min_value= df["is_quarter_start"].min(), value= df["is_quarter_start"].min())
|
| 88 |
+
is_quarter_end = st.sidebar.number_input('is_quarter_end', min_value= df["is_quarter_end"].min(), value= df["is_quarter_end"].min())
|
| 89 |
+
is_year_start = st.sidebar.number_input('is_year_start', min_value= df["is_year_start"].min(), value= df["is_year_start"].min())
|
| 90 |
+
is_year_end = st.sidebar.number_input('is_year_end', min_value= df["is_year_end"].min(), value= df["is_year_end"].min())
|
| 91 |
+
year_weekofyear = st.sidebar.number_input('year_weekofyear', min_value= df["year_weekofyear"].min(), value= df["year_weekofyear"].min())
|
| 92 |
+
city = st.sidebar.selectbox("city:", options= sorted(set(df["city"])))
|
| 93 |
+
store_type= st.sidebar.number_input('type', min_value= df["type"].min(), value= df["type"].min())
|
| 94 |
+
cluster = st.sidebar.selectbox('cluster', options = sorted(list(df['cluster'].unique())))
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
# make prediction
|
| 99 |
+
sales_value = make_prediction(store_id, category_id, onpromotion, year,month, dayofmonth,
|
| 100 |
+
dayofweek, dayofyear,weekofyear, quarter, is_month_start, is_month_end,
|
| 101 |
+
is_quarter_start, is_quarter_end, is_year_start, is_year_end,
|
| 102 |
+
year_weekofyear,city, store_type, cluster)
|
| 103 |
+
|
| 104 |
+
# get predicted value
|
| 105 |
+
if st.button('Predict'):
|
| 106 |
+
st.success('The predicted target is ' + str(sales_value))
|
| 107 |
+
|
| 108 |
+
|
image 2.jpg
ADDED
|
images1.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
matplotlib==3.3.4
|
| 2 |
+
numpy==1.22.4
|
| 3 |
+
pandas==1.2.4
|
| 4 |
+
pmdarima==2.0.3
|
| 5 |
+
scipy==1.6.2
|
| 6 |
+
seaborn==0.11.1
|
| 7 |
+
scikit-learn==0.24.1
|
| 8 |
+
xgboost==1.7.3
|
| 9 |
+
streamlit==1.23.1
|
toolkit_folder
ADDED
|
Binary file (221 kB). View file
|
|
|