rasmodev commited on
Commit
d825269
·
verified ·
1 Parent(s): 54a0a42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import pandas as pd
2
  import streamlit as st
3
- import numpy as np
4
  import pickle
5
  from sklearn.preprocessing import MinMaxScaler
6
 
@@ -12,6 +11,7 @@ with open('model_and_scaler.pkl', 'rb') as file:
12
  scaler = model_and_scaler['scaler']
13
  rf_model = model_and_scaler['model']
14
 
 
15
  st.image("https://pbs.twimg.com/media/DywhyJiXgAIUZej?format=jpg&name=medium")
16
  st.title("Store Sales Prediction App")
17
  st.caption("This app predicts sales patterns in different stores based on the inputs.")
@@ -27,7 +27,7 @@ st.sidebar.markdown("**Day**: Day the product was purchased.")
27
  st.sidebar.markdown("**Month**: Month the product was purchased.")
28
  st.sidebar.markdown("**Year**: Year the product was purchased.")
29
 
30
- # Create the input fields
31
  input_data = {}
32
  col1, col2 = st.columns(2)
33
  with col1:
@@ -38,8 +38,8 @@ with col1:
38
 
39
  with col2:
40
  input_data['day'] = st.slider("Day", 1, 31)
41
- input_data['month'] = st.slider("Month", 1, 12)
42
- input_data['year'] = st.number_input("Year", 2018, 2020)
43
 
44
  # Create a button to make a prediction
45
  if st.button("Predict"):
@@ -50,13 +50,6 @@ if st.button("Predict"):
50
  input_df_scaled = scaler.fit_transform(input_df[numerical_cols])
51
  input_df_scaled = pd.DataFrame(input_df_scaled, columns=numerical_cols)
52
 
53
- # Load the scaler and model
54
- with open('model_and_scaler.pkl', 'rb') as file:
55
- model_and_scaler = pickle.load(file)
56
-
57
- # Extract the model
58
- rf_model = model_and_scaler['model']
59
-
60
  # Make predictions using the trained model
61
  predictions = rf_model.predict(input_df_scaled)
62
 
 
1
  import pandas as pd
2
  import streamlit as st
 
3
  import pickle
4
  from sklearn.preprocessing import MinMaxScaler
5
 
 
11
  scaler = model_and_scaler['scaler']
12
  rf_model = model_and_scaler['model']
13
 
14
+ # Define app title and description
15
  st.image("https://pbs.twimg.com/media/DywhyJiXgAIUZej?format=jpg&name=medium")
16
  st.title("Store Sales Prediction App")
17
  st.caption("This app predicts sales patterns in different stores based on the inputs.")
 
27
  st.sidebar.markdown("**Month**: Month the product was purchased.")
28
  st.sidebar.markdown("**Year**: Year the product was purchased.")
29
 
30
+ # Create the input fields
31
  input_data = {}
32
  col1, col2 = st.columns(2)
33
  with col1:
 
38
 
39
  with col2:
40
  input_data['day'] = st.slider("Day", 1, 31)
41
+ input_data['month'] = st.slider("Month", 1, 12, value=6)
42
+ input_data['year'] = st.number_input("Year", 2018, 2020, value=2020)
43
 
44
  # Create a button to make a prediction
45
  if st.button("Predict"):
 
50
  input_df_scaled = scaler.fit_transform(input_df[numerical_cols])
51
  input_df_scaled = pd.DataFrame(input_df_scaled, columns=numerical_cols)
52
 
 
 
 
 
 
 
 
53
  # Make predictions using the trained model
54
  predictions = rf_model.predict(input_df_scaled)
55