Skip to content

This repo hosts a compact, end-to-end example of predicting heart-failure mortality with a Keras neural network. A 12-feature clinical dataset is cleaned, scaled and one-hot encoded, then fed into a tiny 12-neuron dense model that reaches 76 % accuracy on the hold-out set.

Notifications You must be signed in to change notification settings

AnastasChoudra/heart-failure-survival-prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Heart Failure Prediction using Neural Networks

This project uses a machine learning approach to predict the survival of patients with heart failure using clinical and demographic features.

Dataset

The dataset is sourced from Kaggle and contains 12 features:

  • age: Age of the patient
  • anaemia: Presence of anaemia (1 = yes, 0 = no)
  • creatinine_phosphokinase: Level of CPK enzyme in the blood (mcg/L)
  • diabetes: Presence of diabetes (1 = yes, 0 = no)
  • ejection_fraction: Percentage of blood leaving the heart at each contraction
  • high_blood_pressure: Presence of hypertension (1 = yes, 0 = no)
  • platelets: Platelet count (kiloplatelets/mL)
  • serum_creatinine: Level of serum creatinine (mg/dL)
  • serum_sodium: Level of serum sodium (mEq/L)
  • sex: Gender of the patient (1 = male, 0 = female)
  • smoking: Smoking status (1 = yes, 0 = no)
  • time: Follow-up period (days)
  • death_event: Target variable (1 = death, 0 = survival)

Cardiovascular diseases (CVDs) are the leading cause of death globally, responsible for an estimated 17.9 million deaths annually (31% of all deaths). Heart failure is a major outcome of CVDs, and predicting mortality risk can aid early intervention.

Project Overview

The project implements a neural network classifier using TensorFlow/Keras to predict patient survival based on clinical data. Key steps include:

  1. Data Loading and Inspection: Load CSV dataset and inspect structure.
  2. Data Preprocessing:
    • One-hot encode categorical variables.
    • Scale numeric features using StandardScaler.
    • Encode target labels for classification.
  3. Model Architecture:
    • Input layer matching the number of features.
    • Hidden layer with 12 neurons and ReLU activation.
    • Output layer with 2 neurons (YES/NO) and softmax activation.
  4. Training:
    • Loss function: Categorical Crossentropy.
    • Optimizer: Adam.
    • Metrics: Accuracy.
    • Epochs: 100, Batch size: 16.
  5. Evaluation:
    • Classification report with precision, recall, f1-score.
    • Accuracy on the test set.

Results

Class Precision Recall F1-score Support
0 0.74 0.91 0.82 44
1 0.81 0.55 0.65 31
Accuracy - - 0.76 75
Macro Avg 0.78 0.73 0.74 75
Weighted Avg 0.77 0.76 0.75 75

Requirements

  • Python 3.x
  • Pandas
  • NumPy
  • scikit-learn
  • TensorFlow/Keras

Installation

pip install pandas numpy scikit-learn tensorflow

About

This repo hosts a compact, end-to-end example of predicting heart-failure mortality with a Keras neural network. A 12-feature clinical dataset is cleaned, scaled and one-hot encoded, then fed into a tiny 12-neuron dense model that reaches 76 % accuracy on the hold-out set.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages