Instructions to use nexusbert/heart-disease-cnn with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nexusbert/heart-disease-cnn with Transformers:
# Load model directly from transformers import HeartDiseaseCNN model = HeartDiseaseCNN.from_pretrained("nexusbert/heart-disease-cnn", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Heart Disease 1D CNN
A PyTorch 1D Convolutional Neural Network for binary heart disease classification from seven selected tabular features.
Model Description
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.
Task
Binary classification:
0โ No Heart Disease1โ Heart Disease
Input Features
The 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.
Architecture
The CNN contains:
- Conv1D โ 32 filters
- Batch Normalization
- ReLU
- Conv1D โ 64 filters
- Batch Normalization
- ReLU
- Dropout
- Flatten
- Dense layer โ 64 units
- ReLU
- Dropout
- Binary output layer
Input shape:
(batch_size, 7)
and internally reshapes them to:
(batch_size, 1, 7)
for Conv1D processing.
Training Configuration
| 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 |
Dataset Split
| Split | Samples |
|---|---|
| Training | 38,427 |
| Validation | 8,235 |
| Test | 8,235 |
The datasets were kept independent during model development and evaluation.
Evaluation
The CNN should be evaluated using:
- Accuracy
- Precision
- Recall
- F1 Score
- ROC-AUC
- PR-AUC
- Sensitivity
- Specificity
Final CNN test metrics should be added to this model card after the final CNN experiment.
Transformers Compatibility
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()
Inference Example
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)
Important Preprocessing Requirement
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:
- Age = 56
- Resting Blood Pressure = 145
- Cholesterol = 370
cannot automatically be assumed to be valid model inputs.
The exact preprocessing procedure must be reproduced before inference.
Intended Use
This model is intended for:
- Machine learning research
- Educational demonstrations
- Tabular classification experiments
- Benchmarking neural-network approaches
- Research into healthcare machine learning
Limitations
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.
Ethical Considerations
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.
Repository Contents
heart-disease-cnn/config.jsonpytorch_model.binmodeling_heart_disease_cnn.pyinference.pyrequirements.txtREADME.md
Model Card Authors
Developed as part of a heart disease machine learning research project.
License
- Downloads last month
- 21