Downloads · 30 days
0
BrejBala/Heart-Disease-Prediction
Heart-Disease-Prediction is a tabular classification model from BrejBala. 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 scikit-learn. The card lists the license as mit.
A classic machine learning model that predicts the likelihood of heart disease from structured patient medical attributes (tabular data). This repository contains a joblib-serialized scikit-learn model trained and eva…
Downloads · 30 days
0
Access
Public
Updated Dec 13, 2025
Repo size
249 KB
Likes
0
Public
Click a slice to open those files.
.ipynb1.1 MB · 80%
From the Hugging Face model README
A classic machine learning model that predicts the likelihood of heart disease from structured patient medical attributes (tabular data).
This repository contains a joblib-serialized scikit-learn model trained and evaluated in an end-to-end Jupyter Notebook workflow.
RandomForestClassifier (scikit-learn)0 → No heart disease1 → Heart disease presentheart_disease_model.joblibHeartDiseasePredictionProject.ipynbThe model was trained on a tabular dataset included in the project repository as heart-disease.csv.
target)1: 1650: 138The model expects 13 columns:
| Feature | Description |
|---|---|
age | Age in years |
sex | Sex (commonly encoded as 1 = male, 0 = female) |
cp | Chest pain type (categorical encoded as integers) |
trestbps | Resting blood pressure |
chol | Serum cholesterol |
fbs | Fasting blood sugar (binary) |
restecg | Resting ECG results (categorical encoded as integers) |
thalach | Maximum heart rate achieved |
exang | Exercise-induced angina (binary) |
oldpeak | ST depression induced by exercise relative to rest |
slope | Slope of peak exercise ST segment (categorical encoded as integers) |
ca | Number of major vessels (categorical encoded as integers) |
thal | Thalassemia category (categorical encoded as integers) |
train_test_split(test_size=0.2)np.random.seed(42) in the notebookRandomizedSearchCV used to tune Random Forest
cv=5, n_iter=20n_estimators=210max_depth=3min_samples_split=4min_samples_leaf=19The saved model (heart_disease_model.joblib) corresponds to:
RandomForestClassifier(n_estimators=210, max_depth=3, min_samples_split=4, min_samples_leaf=19)Note: The notebook also visualizes confusion matrices and ROC curves for model comparison.
pip install scikit-learn joblib pandas numpy huggingface_hubfrom huggingface_hub import hf_hub_download
import joblib
import pandas as pd
# Replace with your HF repo id, e.g. "brej-29/heart-disease-prediction-rf"
repo_id = "YOUR_USERNAME/YOUR_MODEL_REPO"
model_path = hf_hub_download(
repo_id=repo_id,
filename="heart_disease_model.joblib"
)
model = joblib.load(model_path)
# Example input (values are placeholders; use correctly-encoded values)
sample = pd.DataFrame([{
"age": 57,
"sex": 1,
"cp": 0,
"trestbps": 120,
"chol": 354,
"fbs": 0,
"restecg": 1,
"thalach": 163,
"exang": 1,
"oldpeak": 0.6,
"slope": 2,
"ca": 0,
"thal": 2
}])
pred = model.predict(sample)[0]
proba = model.predict_proba(sample)[0, 1] # probability of class "1"
print("Prediction:", int(pred))
print("P(heart disease):", float(proba))
cp, restecg, slope, ca, thal) follow the same integer encoding as used in trainingint/float); no missing valuesTraining and evaluation were performed using classical ML methods on a small tabular dataset and are expected to have minimal compute and carbon impact (CPU-only, short runtime).
heart_disease_model.joblib)For questions/feedback, please open an issue on the GitHub repository:
https://github.com/brej-29/Logicmojo-AIML-Assignments-heart-disease-prediction-ml