AbdulmalikAdeyemo commited on
Commit
e4f7554
·
1 Parent(s): c961ef8

Upload 5 files

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. README.md +1 -12
  3. big_mart.py +114 -0
  4. big_mart_model.pkl +3 -0
  5. hero.jpg +3 -0
  6. requirements.txt +4 -0
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ hero.jpg filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,12 +1 @@
1
- ---
2
- title: Big Mart Sales
3
- emoji: 🐨
4
- colorFrom: gray
5
- colorTo: indigo
6
- sdk: streamlit
7
- sdk_version: 1.21.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # sales_prediction_deployment
 
 
 
 
 
 
 
 
 
 
 
big_mart.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ @author: Abdulmalik Adeyemo
3
+ """
4
+ import pandas as pd
5
+ from sklearn.preprocessing import StandardScaler, OrdinalEncoder, OneHotEncoder
6
+
7
+
8
+ import pickle
9
+ import streamlit as st
10
+ from streamlit_option_menu import option_menu
11
+
12
+
13
+ # loading the saved models
14
+ model = pickle.load(open('big_mart_model.pkl', 'rb'))
15
+
16
+
17
+ # sidebar for navigation
18
+ with st.sidebar:
19
+
20
+ selected = option_menu('Sales Prediction System', #Title of the OptionMenu
21
+
22
+ ['Big Mart Sales Prediction','Financial Inclusion'], #You can add more options to the sidebar
23
+ icons=['shop', 'cash'], #BootStrap Icons - Add more depending on the number of sidebar options you have.
24
+ default_index=0) #Default side bar selection
25
+
26
+
27
+ # Sales Prediction Page
28
+ if (selected == 'Big Mart Sales Prediction'):
29
+
30
+ # page title
31
+ st.title('Sales Prediction using ML')
32
+
33
+ #Image
34
+ st.image('hero.jpg')
35
+
36
+ # getting the input data from the user
37
+ col1, col2 = st.columns(2)
38
+
39
+ with col1:
40
+ Item_Visibility = st.number_input('Item Visibility', min_value=0.00, max_value=0.40, step=0.01)
41
+
42
+ with col1:
43
+ Item_MRP = st.number_input('Item MRP', min_value=30.00, max_value=270.00, step=1.00)
44
+
45
+ with col1:
46
+ Outlet_Size = st.selectbox('Outlet Size', ['Small', 'Medium', 'High'])
47
+
48
+ with col2:
49
+ Item_Fat_Content = st.selectbox('Item Fat Content', ['Low Fat', 'Regular'])
50
+
51
+ with col2:
52
+ Outlet_Location_Type = st.selectbox('Outlet Location Type', ['Tier 1', 'Tier 2', 'Tier 3'])
53
+
54
+ #Data Preprocessing
55
+
56
+ data = {
57
+ 'Item_Visibility': Item_Visibility,
58
+ 'Item_MRP' : Item_MRP,
59
+ 'Outlet_Size' : Outlet_Size,
60
+ 'Item_Fat_Content_Regular': Item_Fat_Content,
61
+ 'Outlet_Location_Type' : Outlet_Location_Type
62
+ }
63
+
64
+ oe = OrdinalEncoder(categories = [['Small','Medium','High']])
65
+ scaler = StandardScaler()
66
+
67
+ def make_prediction(data):
68
+ df = pd.DataFrame(data, index=[0])
69
+
70
+ if df['Item_Fat_Content_Regular'].values == 'Low Fat':
71
+ df['Item_Fat_Content_Regular'] = 0.0
72
+
73
+ if df['Item_Fat_Content_Regular'].values == 'Regular':
74
+ df['Item_Fat_Content_Regular'] = 1.0
75
+
76
+ if df['Outlet_Location_Type'].values == 'Tier 1':
77
+ df[['Outlet_Location_Type_Tier 1','Outlet_Location_Type_Tier 2', 'Outlet_Location_Type_Tier 3']] = [1.0, 0.0, 0.0]
78
+
79
+ if df['Outlet_Location_Type'].values == 'Tier 2':
80
+ df[['Outlet_Location_Type_Tier 1','Outlet_Location_Type_Tier 2', 'Outlet_Location_Type_Tier 3']] = [0.0, 1.0, 0.0]
81
+
82
+ if df['Outlet_Location_Type'].values == 'Tier 3':
83
+ df[['Outlet_Location_Type_Tier 1','Outlet_Location_Type_Tier 2', 'Outlet_Location_Type_Tier 3']] = [0.0, 0.0, 1.0]
84
+
85
+ df['Outlet_Size'] = oe.fit_transform(df[['Outlet_Size']])
86
+ df = df.drop(columns = ['Outlet_Location_Type'], axis = 1 )
87
+ df[['Item_Visibility', 'Item_MRP']] = StandardScaler().fit_transform(df[['Item_Visibility', 'Item_MRP']])
88
+
89
+ prediction = model.predict(df)
90
+
91
+ return round(float(prediction),2)
92
+
93
+
94
+
95
+ # code for Prediction
96
+ # sales_prediction_output = ""
97
+
98
+ # creating a button for Prediction
99
+
100
+ if st.button('Predict Sales'):
101
+ sales_prediction = make_prediction(data)
102
+ sales_prediction_output = f"The sales is predicted to be {sales_prediction}"
103
+
104
+
105
+ st.success(sales_prediction_output)
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
big_mart_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e1ae7dd1c756f785476360921a24f11d8a4a4d702ae72d9a2af5cf3fded7db3
3
+ size 148898
hero.jpg ADDED

Git LFS Details

  • SHA256: 59bd12b7e92e98649aa5551266529d86b4741288bf1bc230fb2da780a105c739
  • Pointer size: 132 Bytes
  • Size of remote file: 2.82 MB
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ scikit-learn
2
+ pandas
3
+ streamlit
4
+ streamlit-option-menu