Skip to content

mudassir-08/Heart_Disease_Prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Heart Disease Prediction using Machine Learning

Project Overview

This project focuses on predicting the presence of heart disease in patients using machine learning techniques. The dataset contains various medical attributes such as chest pain type, cholesterol levels, age, and more.

The goal is to build and compare classification models to identify whether a patient is at risk of heart disease and understand which medical features contribute most to the prediction.


Objectives

  • Perform data cleaning and preprocessing
  • Conduct Exploratory Data Analysis (EDA)
  • Train machine learning classification models
  • Compare Linear vs Non-linear models
  • Evaluate model performance using multiple metrics
  • Identify important medical features affecting heart disease

Dataset Information

  • Dataset: Heart Disease UCI Dataset
  • Target Variable: target
    • 0 → No heart disease
    • 1 → Heart disease present

Features include:

  • age
  • sex
  • cp (chest pain type)
  • trestbps (resting blood pressure)
  • chol (cholesterol)
  • fbs (fasting blood sugar)
  • restecg (resting ECG results)
  • thalach (maximum heart rate achieved)
  • exang (exercise induced angina)
  • oldpeak (ST depression)
  • slope
  • ca (number of major vessels)
  • thal

Machine Learning Models Used

1. Logistic Regression

  • Linear classification model
  • Uses sigmoid function for probability estimation
  • Works well when data is linearly separable

2. Decision Tree Classifier

  • Non-linear model
  • Splits data based on feature conditions
  • Captures complex relationships in data

Workflow

1. Data Preprocessing

  • Checked missing values
  • Applied StandardScaler for feature normalization
  • Split dataset into training and testing sets (80/20)

2. Exploratory Data Analysis (EDA)

  • Target distribution analysis
  • Correlation heatmap
  • Feature relationship study

3. Model Training

  • Logistic Regression model trained on scaled data
  • Decision Tree model trained on original feature structure

4. Evaluation Metrics

  • Accuracy Score
  • ROC-AUC Score
  • Confusion Matrix
  • ROC Curve

Model Performance

Model Accuracy ROC-AUC
Logistic Regression 0.810 0.930
Decision Tree 0.985 0.986

Key Findings

  • Decision Tree outperforms Logistic Regression significantly
  • The dataset contains strong non-linear relationships
  • Chest pain type (cp) is the most important predictor
  • Number of major vessels (ca) is highly influential
  • Some features like fasting blood sugar (fbs) have negligible impact

Feature Importance Analysis

Top contributing features:

  • cp (Chest Pain Type)
  • ca (Number of Major Vessels)
  • age
  • chol (Cholesterol)
  • thal

Less important features:

  • fbs
  • restecg
  • sex (low individual impact)

Key Insights

  • Medical data is highly non-linear in nature
  • Feature interactions play a major role in prediction
  • Simple linear models are not sufficient for high accuracy
  • Model interpretability is crucial in healthcare applications

Limitations

  • Dataset size is relatively small
  • No external medical validation performed
  • Potential overfitting in Decision Tree model
  • No hyperparameter tuning applied

Future Improvements

  • Use ensemble models (Random Forest, XGBoost)
  • Perform cross-validation
  • Hyperparameter tuning for better generalization
  • Deploy model as a web application
  • Integrate real-time medical prediction system

Conclusion

This project demonstrates how machine learning can assist in predicting heart disease using clinical data. Among the tested models, Decision Tree performed best due to its ability to capture non-linear relationships.

However, for real-world deployment, more robust models and validation techniques are recommended.


Tools & Technologies

  • Python
  • Pandas
  • NumPy
  • Matplotlib
  • Seaborn
  • Scikit-learn

Project Structure

heart-disease-prediction/ │── heart_disease.ipynb │── README.md │── heart-2.csv


Author

Malik Muhammad Mudassir Iqbal AI/ML Engineering Intern at DevelopersHub Corporation


Acknowledgements

  • UCI Machine Learning Repository
  • Scikit-learn Documentation
  • Kaggle Dataset Contributors

About

This project applies machine learning techniques to predict cardiovascular disease using clinical data. It focuses on data preprocessing, feature engineering, and supervised learning models to support early diagnosis and clinical decision-making in healthcare.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors