Update app.py
Browse files84 unmodified lines858687888990919293949596111 unmodified lines20820921021121221321421521621721821922022122222322422522622784 unmodified linesreturn loaded_objectloaded_object = Load_ml_items('ML_items')#return loaded_objectLoaded_object = Load_ml_items('ML_items')model, encoder, train_data, stores, holidays_event = Loaded_object['model'], Loaded_object['encoder'], Loaded_object['train_data'], Loaded_object['stores'], Loaded_object['holidays_event']# Setting Function for extracting Calendar features@st.cache(allow_output_mutation=True)111 unmodified linesprocessed_data= getDateFeatures(df, 'date')processed_data= processed_data.drop(columns=['date'])# Encoding Categorical Variablesencoder = preprocessing.LabelEncoder()cols = ['family', 'city', 'state', 'store_type', 'locale', 'locale_name', 'day_type']for col in cols:processed_data[col] = encoder.fit_transform(processed_data[col])# Making Predictionsdef predict(X, model= Loaded_object['model']):results = model.predict(X)return resultsprediction = predict(processed_data, model= Loaded_object['model'])df['Sales']= prediction# Displaying prediction resultsst.markdown('''---''')84 unmodified lines85868788899091929394959697111 unmodified lines20921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024184 unmodified linesreturn loaded_objectloaded_object = Load_ml_items('ml_items_1')#return loaded_objectLoaded_object = Load_ml_items('ml_items_1')pipeline, stores, holidays_event = Loaded_object['pipeline'], Loaded_object['stores'], Loaded_object['holidays_event']# Setting Function for extracting Calendar features@st.cache(allow_output_mutation=True)111 unmodified linesprocessed_data= getDateFeatures(df, 'date')processed_data= processed_data.drop(columns=['date'])# # Encoding Categorical Variables# encoder = preprocessing.LabelEncoder()# cols = ['family', 'city', 'state', 'store_type', 'locale', 'locale_name', 'day_type']# for col in cols:# processed_data[col] = encoder.fit_transform(processed_data[col])# # Making Predictions# def predict(X, model= Loaded_object['model']):# results = model.predict(X)# return results#Making predictionsprediction = pipeline.predict(processed_data)df['Sales']= prediction# # Displaying prediction results# st.markdown('''---''')# st.markdown("<h4 style='text-align: center;'> Prediction Results </h4> ", unsafe_allow_html=True)# st.success(f"Predicted Sales: {prediction[-1]}")# st.markdown('''---''')# prediction = predict(processed_data, model= Loaded_object['model'])# df['Sales']= prediction# Displaying prediction resultsst.markdown('''---''')
app.py+28-14