1nox commited on
Commit
1ecf5ee
·
verified ·
1 Parent(s): 43e48ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -96,23 +96,17 @@ def load_models():
96
  'SubCategoryEncoded', 'Quantity'
97
  ]
98
 
99
- # Store them in session_state
100
- st.session_state['model'] = model
101
- st.session_state['scaler'] = scaler
102
- st.session_state['encoders'] = encoders
103
- st.session_state['model_features'] = model_features # Store the model's feature names
104
-
105
  return model, scaler, encoders, model_features
106
 
107
 
108
  # Main App
109
  def main():
110
  # Ensure models are loaded into session_state
111
- if 'model' not in st.session_state or 'scaler' not in st.session_state or 'encoders' not in st.session_state or 'model_features' not in st.session_state:
112
- model, scaler, encoders, model_features = load_models() # This will initialize the models in session_state
113
-
114
- # Get model features from session state
115
- model_features = st.session_state['model_features']
116
 
117
  st.markdown(f"<h1 style='color: {HEADER_COLOR}; text-align: center;'>🔹 Filter's Price Prediction App 🔹</h1>", unsafe_allow_html=True)
118
  st.markdown(f"<p style='color: {TEXT_COLOR}; font-size: 18px;'>This app uses a trained machine learning model to predict filter's prices based on input data.</p>", unsafe_allow_html=True)
 
96
  'SubCategoryEncoded', 'Quantity'
97
  ]
98
 
 
 
 
 
 
 
99
  return model, scaler, encoders, model_features
100
 
101
 
102
  # Main App
103
  def main():
104
  # Ensure models are loaded into session_state
105
+ model, scaler, encoders, model_features = load_models()
106
+ st.session_state['model'] = model
107
+ st.session_state['scaler'] = scaler
108
+ st.session_state['encoders'] = encoders
109
+ st.session_state['model_features'] = model_features
110
 
111
  st.markdown(f"<h1 style='color: {HEADER_COLOR}; text-align: center;'>🔹 Filter's Price Prediction App 🔹</h1>", unsafe_allow_html=True)
112
  st.markdown(f"<p style='color: {TEXT_COLOR}; font-size: 18px;'>This app uses a trained machine learning model to predict filter's prices based on input data.</p>", unsafe_allow_html=True)