Downloads · 30 days
20
35% of all-time downloads
abdalla732/heart_failure_prediction
heart_failure_prediction is a tabular classification model from abdalla732. Use it for the tabular classification task on the model card, and read the license before you ship it in a product. It is set up for keras. The card lists the license as mit.
A Keras / TensorFlow neural network that predicts the presence of heart disease in patients using 11 clinical and demographic features.
Downloads · 30 days
20
35% of all-time downloads
All-time downloads
57
Public
Repo size
20.1 MB
Likes
1
Public
Click a slice to open those files.
.keras20.1 MB · 100%
From the Hugging Face model README
A Keras / TensorFlow neural network that predicts the presence of heart disease in patients using 11 clinical and demographic features.
.keras| File | Purpose |
|---|---|
heart_model.keras | Trained Keras model |
scaler.joblib | StandardScaler fitted on training data |
feature_columns.joblib | Column names after one-hot encoding |
Educational and research purposes only. Explore how clinical features relate to heart disease risk.
from huggingface_hub import hf_hub_download
import joblib
import pandas as pd
from tensorflow import keras
# Download model + preprocessing artifacts
model_path = hf_hub_download("abdalla732/heart_failure_prediction", "heart_model.keras")
scaler_path = hf_hub_download("abdalla732/heart_failure_prediction", "scaler.joblib")
cols_path = hf_hub_download("abdalla732/heart_failure_prediction", "feature_columns.joblib")
# Load
model = keras.models.load_model(model_path)
scaler = joblib.load(scaler_path)
columns = joblib.load(cols_path)
# Prepare a sample input
raw = pd.DataFrame([{
"Age": 54, "Sex": "M", "ChestPainType": "NAP", "RestingBP": 150,
"Cholesterol": 195, "FastingBS": 0, "RestingECG": "Normal",
"MaxHR": 122, "ExerciseAngina": "N", "Oldpeak": 0.0, "ST_Slope": "Up"
}])
raw = pd.get_dummies(raw, drop_first=False)
raw = raw.reindex(columns=columns, fill_value=0)
X = scaler.transform(raw.values.astype("float32"))
# Predict
prob = float(model.predict(X, verbose=0)[0][0])
print("Heart disease" if prob > 0.5 else "No heart disease", f"(p = {prob:.3f})")