A machine-learning study that predicts heart-failure mortality risk from clinical patient data. A logistic-regression pipeline trained on 299 heart-failure records reaches 86.7% test accuracy across 13 clinical features (age, ejection fraction, serum creatinine, and more).
This repository contains a Jupyter Notebook for analyzing a dataset on heart attack prediction. The notebook explores the data, performs feature engineering, trains a machine learning model, and evaluates it's performance.
Data Description:
The dataset, "Heart Failure prediction.csv", contains 299 rows and 13 columns related to heart failure patients. The columns include:
- Demographic information: age, sex
- Medical history: anaemia, diabetes, high_blood_pressure, smoking
- Lab results: creatinine_phosphokinase, ejection_fraction, platelets, serum_creatinine, serum_sodium
- Target variable: DEATH_EVENT (1: death event, 0: no death event)
Notebook Content:
-
Imports:
- Standard libraries: pandas, numpy, matplotlib, seaborn
- Machine learning libraries: sci-kit-learn for data preprocessing, model training, and evaluation
-
Data Loading:
- Loads the CSV data using pandas.read_csv()
-
Exploratory Data Analysis (EDA):
- Provides basic summary statistics using describe().T
- Analyzes data distribution and missing values
- Creates visualizations (count plots, heatmaps) to understand relationships between features and the target variable (DEATH_EVENT)
-
Data Preprocessing:
- Identifies categorical and numerical features
- Encodes categorical features (if necessary)
- Handles missing values (if any)
- Splits the data into training and testing sets using train_test_split()
-
Model Training:
- Uses Logistic Regression for heart attack prediction
- Applies StandardScaler() for feature scaling
-
Model Evaluation:
- Trains the model on the training set using fit()
- Makes predictions on the testing set using predict()
- Evaluates model performance using:
- Classification report (precision, recall, F1-score)
- Accuracy score
- Compares training and testing set performance
Getting Started:
- Clone this repository.
- Install required libraries using
pip install pandas numpy matplotlib seaborn scikit-learn - Open the Jupyter Notebook (e.g.,
Heart_Attack_Failure_Prediction.ipynb) - Run the code cells sequentially.