DataWizard9742 commited on
Commit
0ef6a73
·
verified ·
1 Parent(s): 108828b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -5,19 +5,16 @@ import pickle
5
 
6
  print("\n--- Creating Gradio Interface ---")
7
 
8
- # Load the saved assets
9
- try:
10
- with open('final_model.pkl', 'rb') as file:
11
- final_model = pickle.load(file)
12
- with open('scaler.pkl', 'rb') as file:
13
- scaler = pickle.load(file)
14
- with open('label_encoder.pkl', 'rb') as file:
15
- label_encoder = pickle.load(file)
16
- print("✓ Models, Scaler, and Label Encoder loaded successfully.")
17
- except Exception as e:
18
- print(f"✗ Error loading saved assets: {e}")
19
- print("Please ensure 'final_model.pkl', 'scaler.pkl', and 'label_encoder.pkl' are in the current directory.")
20
- exit()
21
 
22
  # Get original feature names from X (from previous execution, assuming it's available or re-derivable)
23
  # If X is not in kernel state, we'd need to load the original dataset and derive column names
 
5
 
6
  print("\n--- Creating Gradio Interface ---")
7
 
8
+ file = 'final_model.pkl'
9
+ final_model = pickle.load(file)
10
+
11
+ file = 'scaler.pkl'
12
+ scaler = pickle.load(file)
13
+
14
+ file = 'label_encoder.pkl'
15
+ label_encoder = pickle.load(file)
16
+
17
+ print("✓ Models, Scaler, and Label Encoder loaded successfully.")
 
 
 
18
 
19
  # Get original feature names from X (from previous execution, assuming it's available or re-derivable)
20
  # If X is not in kernel state, we'd need to load the original dataset and derive column names