Harsh12 commited on
Commit
aec1c93
·
1 Parent(s): 6d9324d

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -137
app.py DELETED
@@ -1,137 +0,0 @@
1
- import streamlit as st
2
- import joblib
3
- import pickle
4
- import pandas as pd
5
-
6
- # Load the model from disk
7
- model = joblib.load('rf.sav')
8
- # Load the model from disk
9
- with open('scaler.pkl', 'rb') as file:
10
- scaler = pickle.load(file)
11
-
12
- st.title('Rossman Sales Prediction App')
13
-
14
- st.write('This app takes in the several input parameters and predict the sales for a particular day of a 1115 rossman stores.')
15
-
16
-
17
- store = int(st.number_input('Store Number (select between 1-1115)', step=1, min_value=1, max_value=1115))
18
- # st.write('Store Number is', store)
19
-
20
- week_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
21
- week_days_mapping = {'Monday':1, 'Tuesday':2, 'Wednesday':3, 'Thursday':4, 'Friday':5, 'Saturday':6, 'Sunday':7}
22
-
23
- week_days_input = st.selectbox('Select the day of the week', week_days)
24
-
25
- # st.write(week_days_input)
26
-
27
- col1, col2 = st.columns(2)
28
-
29
-
30
- with col1:
31
- promo = ['yes', 'no']
32
- promo_map = {'yes':1, 'no':0}
33
-
34
- promo_or_not = st.selectbox('Promotion was opted or not?', promo)
35
-
36
- with col2:
37
- school_holiday = ['yes', 'no']
38
- school_map = {'yes':1, 'no':0}
39
-
40
- school_holiday_or_not = st.selectbox('Is there a School Holiday?', school_holiday)
41
-
42
-
43
- col3, col4 = st.columns(2)
44
-
45
- with col3:
46
- year = st.number_input('Enter the year:',step=1, min_value=1973, max_value=2025)
47
-
48
-
49
- with col4:
50
- months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
51
-
52
- month_map = {'January': 1, 'February': 2, 'March': 3, 'April': 4, 'May': 5, 'June': 6,
53
- 'July': 7, 'August': 8, 'September': 9, 'October': 10, 'November': 11, 'December': 12}
54
-
55
-
56
- select_month = st.selectbox('Select the month', months)
57
-
58
-
59
- days = st.number_input('Enter the day number for which you want to predict:', step=1, min_value=1, max_value=31)
60
-
61
-
62
- stores_type = ['a', 'b', 'c', 'd']
63
- stores_type_input = st.selectbox('Select the type of store', stores_type)
64
-
65
- assortment_type = ['basic', 'extra', 'extended']
66
- assortment_type_map = {'basic':'a', 'extra':'b', 'extended':'c'}
67
- assortment_type_input = st.selectbox('Select the assortment type (variations in the product)', assortment_type)
68
-
69
- customers = st.number_input('Enter the expected number of customers', step=5, min_value=5, max_value=7500)
70
- comp_distance = st.number_input('Enter the distance in meters to the nearest competitor store', step=1)
71
- comp_open_since_month = float(st.number_input('The month is which the nearest competitor store was opened (1-12)', step=1, min_value=1, max_value=12))
72
- comp_open_since_year = float(st.number_input('The year in which the nearest competitor store was opened', step=1, min_value=1973, max_value=2025))
73
-
74
-
75
- competition_open = (12* (year-comp_open_since_year)) + (month_map[select_month] - (comp_open_since_month))
76
-
77
- if stores_type_input == 'a':
78
- store_type_value_b = 0
79
- store_type_value_c = 0
80
- store_type_value_d = 0
81
-
82
- if stores_type_input == 'b':
83
- store_type_value_b = 1
84
- store_type_value_c = 0
85
- store_type_value_d = 0
86
-
87
- if stores_type_input == 'c':
88
- store_type_value_b = 0
89
- store_type_value_c = 1
90
- store_type_value_d = 0
91
-
92
- if stores_type_input == 'd':
93
- store_type_value_b = 0
94
- store_type_value_c = 0
95
- store_type_value_d = 1
96
-
97
- if assortment_type_input == 'basic':
98
- assortment_b = 0
99
- assortment_c = 0
100
-
101
- if assortment_type_input == 'extra':
102
- assortment_b = 1
103
- assortment_c = 0
104
-
105
- if assortment_type_input == 'extended':
106
- assortment_b = 0
107
- assortment_c = 1
108
-
109
-
110
-
111
-
112
-
113
- if st.button('Predict Sales'):
114
-
115
- try:
116
- final_dict = {'Store':store, 'day_of_week':week_days_mapping[week_days_input],
117
- 'promotion':promo_map[promo_or_not], 'school holiday':school_map[school_holiday_or_not],
118
- 'year':year, 'month':month_map[select_month], 'day':days, 'store b':store_type_value_b,
119
- 'store c':store_type_value_c, 'store d':store_type_value_d, 'assortment b':assortment_b,
120
- 'assortment c':assortment_c, 'customers':customers, 'Comp Dist':comp_distance,
121
- 'Comp_open': competition_open}
122
-
123
-
124
- final_df = pd.DataFrame([final_dict])
125
- final_df_scaled = scaler.transform(final_df)
126
- # st.write(final_df_scaled)
127
- # st.write(final_df)
128
-
129
- sales = model.predict(final_df_scaled)
130
- st.write('The sales for this particular day of the store you selected is:', sales[0])
131
-
132
- except Exception as e:
133
- st.error('There is something wrong, please enter the correct inputs', e)
134
-
135
-
136
-
137
-