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.
- 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: Heart Disease UCI Dataset
- Target Variable:
target- 0 → No heart disease
- 1 → Heart disease present
- 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
- Linear classification model
- Uses sigmoid function for probability estimation
- Works well when data is linearly separable
- Non-linear model
- Splits data based on feature conditions
- Captures complex relationships in data
- Checked missing values
- Applied StandardScaler for feature normalization
- Split dataset into training and testing sets (80/20)
- Target distribution analysis
- Correlation heatmap
- Feature relationship study
- Logistic Regression model trained on scaled data
- Decision Tree model trained on original feature structure
- Accuracy Score
- ROC-AUC Score
- Confusion Matrix
- ROC Curve
| Model | Accuracy | ROC-AUC |
|---|---|---|
| Logistic Regression | 0.810 | 0.930 |
| Decision Tree | 0.985 | 0.986 |
- 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
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)
- 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
- Dataset size is relatively small
- No external medical validation performed
- Potential overfitting in Decision Tree model
- No hyperparameter tuning applied
- 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
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.
- Python
- Pandas
- NumPy
- Matplotlib
- Seaborn
- Scikit-learn
heart-disease-prediction/ │── heart_disease.ipynb │── README.md │── heart-2.csv
Malik Muhammad Mudassir Iqbal AI/ML Engineering Intern at DevelopersHub Corporation
- UCI Machine Learning Repository
- Scikit-learn Documentation
- Kaggle Dataset Contributors