Downloads · 30 days
16
31% of all-time downloads
nexusbert/heart-disease-cnn
heart-disease-cnn is a tabular classification model from nexusbert. 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 transformers.
A PyTorch 1D Convolutional Neural Network for binary heart disease classification from seven selected tabular features.
Downloads · 30 days
16
31% of all-time downloads
All-time downloads
52
Public
Repo size
292 KB
Likes
0
Public
Click a slice to open those files.
.bin149 KB · 93%
From the Hugging Face model README
A PyTorch 1D Convolutional Neural Network for binary heart disease classification from seven selected tabular features.
This model was developed as part of a comparative machine learning study for heart disease classification.
The model uses a 1D convolutional architecture over seven preprocessed features.
Binary classification:
0 — No Heart Disease1 — Heart DiseaseThe model expects seven preprocessed features in exactly this order:
| Index | Feature |
|---|---|
| 0 | Age |
| 1 | Resting Blood Pressure |
| 2 | Cholesterol |
| 3 | Fasting Blood Sugar |
| 4 | Oldpeak |
| 5 | Exercise Angina: No |
| 6 | Exercise Angina: Yes |
The numerical features must use the same preprocessing/scaling procedure used during training.
The CNN contains:
Input shape:
(batch_size, 7)
and internally reshapes them to:
(batch_size, 1, 7)
for Conv1D processing.
| Parameter | Value |
|---|---|
| Optimizer | AdamW |
| Learning Rate | 0.001 |
| Weight Decay | 1e-4 |
| Batch Size | 128 |
| Early Stopping Patience | 7 |
| Loss | Binary Cross Entropy with Logits |
| Random Seed | 42 |
| Split | Samples |
|---|---|
| Training | 38,427 |
| Validation | 8,235 |
| Test | 8,235 |
The datasets were kept independent during model development and evaluation.
The CNN should be evaluated using:
Final CNN test metrics should be added to this model card after the final CNN experiment.
This repository contains a custom Transformers configuration and model implementation.
The model can be loaded using Hugging Face Transformers with remote-code support.
Install dependencies:
pip install -r requirements.txt
Load the model:
import torch
from transformers import AutoModel
model_id = "nexusbert/heart-disease-cnn"
model = AutoModel.from_pretrained(
model_id,
trust_remote_code=True
)
model.eval()
import torch
from transformers import AutoModel
model_id = "nexusbert/heart-disease-cnn"
model = AutoModel.from_pretrained(
model_id,
trust_remote_code=True
)
model.eval()
features = torch.tensor(
[[
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
]],
dtype=torch.float32
)
with torch.no_grad():
outputs = model(
input_features=features
)
probability = torch.sigmoid(
outputs["logits"]
).item()
prediction = int(probability >= 0.5)
label = (
"Heart Disease"
if prediction == 1
else "No Heart Disease"
)
print("Prediction:", prediction)
print("Label:", label)
print("Probability:", probability)
The model expects the seven features in their processed/scaled representation.
Raw clinical measurements should not be passed directly into the model unless they have first been transformed using the same preprocessing pipeline used during training.
For example, values such as:
cannot automatically be assumed to be valid model inputs.
The exact preprocessing procedure must be reproduced before inference.
This model is intended for:
This model is a research and educational machine learning system.
It is not a medical diagnostic device and must not be used to diagnose, treat, or make clinical decisions about an individual.
Performance on the development dataset does not establish clinical validity or guarantee generalization to other populations or real-world clinical environments.
Healthcare prediction systems can have significant consequences when incorrectly interpreted or deployed.
Any real-world clinical application would require appropriate external validation, clinical review, safety evaluation, monitoring, and regulatory assessment.
heart-disease-cnn/
config.jsonpytorch_model.binmodeling_heart_disease_cnn.pyinference.pyrequirements.txtREADME.mdDeveloped as part of a heart disease machine learning research project.