-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_model.py
34 lines (26 loc) · 1.03 KB
/
verify_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# verify_model.py
import pickle
import numpy as np
def verify_model():
"""Verify that the saved model can be loaded and used."""
try:
# Load the model
with open('rf_model_parkinson.pkl', 'rb') as file:
model = pickle.load(file)
print("Model loaded successfully!")
print("\nModel type:", type(model))
print("Feature names:", model.feature_names)
# Create a sample input
sample_input = np.zeros((1, len(model.feature_names)))
# Test prediction
prediction = model.predict(sample_input)
probability = model.predict_proba(sample_input)
print("\nTest prediction successful!")
print("Sample prediction:", prediction)
print("Sample probability:", probability)
except FileNotFoundError:
print("Error: Model file not found!")
except Exception as e:
print(f"An error occurred: {str(e)}")
if __name__ == "__main__":
verify_model()