Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🫀 Smart Heart Disease Detection System

A machine learning project that predicts the likelihood of heart disease in a patient based on clinical features. Multiple classification algorithms are trained, evaluated, and compared to find the best-performing model.


📌 Problem Statement

Given a set of medical features, predict whether a person has heart disease:

  • 1 → Person has heart disease
  • 0 → Person does not have heart disease

📂 Dataset


🛠️ Tech Stack

Category Tools
Language Python
Data Analysis Pandas, NumPy
Visualization Matplotlib, Seaborn
Machine Learning scikit-learn
Model Export Joblib
Notebook Jupyter Notebook

📊 Exploratory Data Analysis (EDA)

The following visualizations were used to understand the data:

  • Count Plot — class distribution of target variable
  • Density Plot — feature distributions
  • Histogram — spread of each feature
  • Box Plot — outlier detection
  • Correlation Heatmap — feature relationships
  • KDE Plot — kernel density estimation
  • Pair Plot — multi-feature relationships
  • Distance Plot — age and trestbps distributions

⚙️ Feature Engineering

  • Identified categorical vs continuous features based on unique value count
  • Applied One-Hot Encoding on categorical columns using pd.get_dummies()
  • Selected 7 key features for model training

🤖 Models Trained

Model Accuracy
Logistic Regression 83.61%
Naive Bayes 80.33%
Ensemble (LR + NB) 81.97%
Random Forest 75.41%
Support Vector Machine (SVC) 68.85%
Decision Tree 67.21%
K-Nearest Neighbors 65.57%

Best Model: Logistic Regression — 83.61% accuracy


📈 Model Evaluation

  • Train/Test Split: 80% / 20% (random_state=42)
  • Evaluation Metric: Accuracy Score
  • Confusion matrices plotted for all 7 models
  • Bar chart comparison of all model accuracies
  • Best K value for KNN identified as 6, 14, or 18 via score plot

💾 Model Export

The best model (Logistic Regression) is exported using joblib:

import joblib
joblib.dump(logreg, "hdp_model.pkl")

🚀 How to Run

  1. Clone the repository
git clone https://github.com/hema123-4/smart-heart-disease-detection.git
cd smart-heart-disease-detection
  1. Install dependencies
pip install pandas numpy matplotlib seaborn scikit-learn joblib
  1. Download the dataset from Kaggle and place heart.csv in the project folder

  2. Run the notebook

jupyter notebook Heart_Disease_Prediction.ipynb

📁 Project Structure

smart-heart-disease-detection/
│
├── Heart_Disease_Prediction.ipynb   # Main notebook
├── hdp_model.pkl                    # Exported Logistic Regression model
├── heart.csv                        # Dataset (download from Kaggle)
└── README.md                        # Project documentation

👩‍💻 Author

Hemalatha Muchumarri
AI Engineer | B.Tech CSE – AI & ML, Alliance University
LinkedIn GitHub

About

heart disease detection using different ML algorithms Like SVM ,KNN, Ensemble method ,decision tree,LR

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages