fendy07 commited on
Commit
ac4b61b
·
1 Parent(s): 944103f

update .gitignore, requirements.txt, and predict

Browse files
Files changed (3) hide show
  1. .gitignore +5 -5
  2. requirements.txt +2 -1
  3. src/pages/predict.py +5 -5
.gitignore CHANGED
@@ -6,11 +6,11 @@ __pycache__/
6
  # Jupyter Notebook checkpoints
7
  .ipynb_checkpoints/
8
  # Model files
9
- model/*.pkl
10
- model/*.h5
11
- model/*.joblib
12
- model/*.sav
13
- model/*.onnx
14
  # Logs
15
  logs/
16
  *.log
 
6
  # Jupyter Notebook checkpoints
7
  .ipynb_checkpoints/
8
  # Model files
9
+ *.pkl
10
+ *.h5
11
+ *.joblib
12
+ *.sav
13
+ *.onnx
14
  # Logs
15
  logs/
16
  *.log
requirements.txt CHANGED
@@ -12,4 +12,5 @@ joblib
12
  onnx
13
  skl2onnx
14
  onnxruntime
15
- seaborn
 
 
12
  onnx
13
  skl2onnx
14
  onnxruntime
15
+ seaborn
16
+ matplotlib
src/pages/predict.py CHANGED
@@ -25,7 +25,7 @@ with open('src/static/styles.css') as f:
25
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
26
 
27
  # Load Dataset
28
- retail = pd.read_csv('data/customer_shopping_data.csv')
29
 
30
  X = retail.loc[:, ['age', 'gender', 'price', 'payment_method', 'shopping_mall']]
31
  y = retail[['category']]
@@ -173,7 +173,7 @@ if train_button:
173
  'n_features': n_features
174
  }
175
 
176
- with open('model/best_model_rf.pkl', 'wb') as f:
177
  pickle.dump(model_package, f)
178
 
179
  # Convert and Save as ONNX
@@ -199,7 +199,7 @@ if train_button:
199
  'feature_names': ['age', 'gender', 'price', 'payment_method', 'shopping_mall']
200
  }
201
 
202
- with open('model/model_metadata.pkl', 'wb') as f:
203
  pickle.dump(metadata, f)
204
 
205
  st.success(f"✅ Model trained and saved successfully!")
@@ -235,7 +235,7 @@ elif model_loaded and use_onnx:
235
  onnx_session = ort.InferenceSession('model/best_model_rf.onnx')
236
 
237
  # Load metadata
238
- with open('model/model_metadata.pkl', 'rb') as f:
239
  metadata = pickle.load(f)
240
 
241
  scaler = metadata['scaler']
@@ -273,7 +273,7 @@ elif model_loaded and use_onnx:
273
 
274
  elif model_loaded and not use_onnx:
275
  # Load Pickle Model
276
- with open('model/best_model_rf.pkl', 'rb') as f:
277
  model_data = pickle.load(f)
278
 
279
  if isinstance(model_data, dict):
 
25
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
26
 
27
  # Load Dataset
28
+ retail = pd.read_csv('src/data/customer_shopping_data.csv')
29
 
30
  X = retail.loc[:, ['age', 'gender', 'price', 'payment_method', 'shopping_mall']]
31
  y = retail[['category']]
 
173
  'n_features': n_features
174
  }
175
 
176
+ with open('src/model/best_model_rf.pkl', 'wb') as f:
177
  pickle.dump(model_package, f)
178
 
179
  # Convert and Save as ONNX
 
199
  'feature_names': ['age', 'gender', 'price', 'payment_method', 'shopping_mall']
200
  }
201
 
202
+ with open('src/model/model_metadata.pkl', 'wb') as f:
203
  pickle.dump(metadata, f)
204
 
205
  st.success(f"✅ Model trained and saved successfully!")
 
235
  onnx_session = ort.InferenceSession('model/best_model_rf.onnx')
236
 
237
  # Load metadata
238
+ with open('src/model/model_metadata.pkl', 'rb') as f:
239
  metadata = pickle.load(f)
240
 
241
  scaler = metadata['scaler']
 
273
 
274
  elif model_loaded and not use_onnx:
275
  # Load Pickle Model
276
+ with open('src/model/best_model_rf.pkl', 'rb') as f:
277
  model_data = pickle.load(f)
278
 
279
  if isinstance(model_data, dict):