cognitive-decline-detector / predict_custom_sample.py
RobbieW0316X's picture
Upload 5 files
e48577d verified
Raw History Blame Contribute Delete
798 Bytes
import joblib
import pandas as pd
from extract_features import extract_features
# Load the trained model and feature list
model = joblib.load("final_model.pkl") # Make sure it's your trained model
expected_features = joblib.load("expected_features.pkl") # A list of 29 feature names used during training
# Set your test audio file here
file_path = "patient_1_healthy.wav" # or patient_2_cognitive_decline.wav
# Extract features from the file
features = extract_features(file_path)
# Align features to training feature set
X = pd.DataFrame([features])
X = X.reindex(columns=expected_features, fill_value=0)
# Predict
prediction = model.predict(X)[0]
prob = model.predict_proba(X).max()
print(f"🧠 Predicted Cognitive Status: {prediction} (Confidence: {prob:.2f})")