Spaces:
Runtime error
Runtime error
File size: 798 Bytes
e48577d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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})")
|