Gyimah3 commited on
Commit
d252164
·
1 Parent(s): f597467

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -14
app.py CHANGED
@@ -85,12 +85,13 @@ def Load_ml_items(relative_path):
85
  return loaded_object
86
 
87
 
88
- loaded_object = Load_ml_items('ML_items')
 
89
 
90
 
91
  #return loaded_object
92
- Loaded_object = Load_ml_items('ML_items')
93
- model, encoder, train_data, stores, holidays_event = Loaded_object['model'], Loaded_object['encoder'], Loaded_object['train_data'], Loaded_object['stores'], Loaded_object['holidays_event']
94
 
95
  # Setting Function for extracting Calendar features
96
  @st.cache(allow_output_mutation=True)
@@ -208,20 +209,33 @@ if submitted:
208
  processed_data= getDateFeatures(df, 'date')
209
  processed_data= processed_data.drop(columns=['date'])
210
 
211
- # Encoding Categorical Variables
212
- encoder = preprocessing.LabelEncoder()
213
- cols = ['family', 'city', 'state', 'store_type', 'locale', 'locale_name', 'day_type']
214
- for col in cols:
215
- processed_data[col] = encoder.fit_transform(processed_data[col])
216
-
217
- # Making Predictions
218
- def predict(X, model= Loaded_object['model']):
219
- results = model.predict(X)
220
- return results
221
 
222
- prediction = predict(processed_data, model= Loaded_object['model'])
 
 
 
 
 
 
223
  df['Sales']= prediction
224
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  # Displaying prediction results
227
  st.markdown('''---''')
 
85
  return loaded_object
86
 
87
 
88
+ loaded_object = Load_ml_items('ml_items_1')
89
+
90
 
91
 
92
  #return loaded_object
93
+ Loaded_object = Load_ml_items('ml_items_1')
94
+ pipeline, stores, holidays_event = Loaded_object['pipeline'], Loaded_object['stores'], Loaded_object['holidays_event']
95
 
96
  # Setting Function for extracting Calendar features
97
  @st.cache(allow_output_mutation=True)
 
209
  processed_data= getDateFeatures(df, 'date')
210
  processed_data= processed_data.drop(columns=['date'])
211
 
212
+ # # Encoding Categorical Variables
213
+ # encoder = preprocessing.LabelEncoder()
214
+ # cols = ['family', 'city', 'state', 'store_type', 'locale', 'locale_name', 'day_type']
215
+ # for col in cols:
216
+ # processed_data[col] = encoder.fit_transform(processed_data[col])
 
 
 
 
 
217
 
218
+ # # Making Predictions
219
+ # def predict(X, model= Loaded_object['model']):
220
+ # results = model.predict(X)
221
+ # return results
222
+
223
+ #Making predictions
224
+ prediction = pipeline.predict(processed_data)
225
  df['Sales']= prediction
226
 
227
+ # # Displaying prediction results
228
+ # st.markdown('''---''')
229
+ # st.markdown("<h4 style='text-align: center;'> Prediction Results </h4> ", unsafe_allow_html=True)
230
+ # st.success(f"Predicted Sales: {prediction[-1]}")
231
+ # st.markdown('''---''')
232
+
233
+
234
+
235
+
236
+ # prediction = predict(processed_data, model= Loaded_object['model'])
237
+ # df['Sales']= prediction
238
+
239
 
240
  # Displaying prediction results
241
  st.markdown('''---''')