NAME : ABDUL TAUFEEQ M
REGNO : 22BCE7964
TITLE : HEART DISEASE PREDICTION AND
CLASSIFICATION USING MACHINE
LEARNING MODELS
INSTITUTE : VIT-AP
Heart Disease Prediction using Machine Learning
Project Report
1. Abstract
Heart disease remains a primary cause of mortality across the globe,
accounting for a significant percentage of deaths annually. As healthcare
becomes increasingly data-driven, the integration of machine learning in
predictive diagnostics offers an invaluable asset for early detection and
intervention. This project investigates the application of three machine
learning algorithms—Logistic Regression, Support Vector Machine (SVM),
and XGBoost—to predict the presence of heart disease based on 14 clinical
features. By analyzing patient data from the UCI Heart Disease dataset, this
research evaluates each model's predictive accuracy, reliability, and
practicality in medical applications. The project demonstrates how such
predictive systems can augment traditional medical practices by providing
rapid, data-driven insights.
2. Introduction
2.1 Background
Cardiovascular diseases are chronic conditions that affect the heart and
blood vessels. Despite significant advancements in medicine, heart disease
remains the top cause of death globally. Diagnosing heart disease early is
essential for effective treatment and management. Traditionally, diagnosis
has depended on a combination of symptoms, clinical history, physical
examination, and a series of tests. However, due to variability in
human judgment, errors can occur.
With the growth of electronic health records and data availability, the
application of machine learning in medicine has gained traction. Predictive
analytics can help in recognizing patterns and correlations within clinical
data that might go unnoticed by human clinicians.
2.2 Motivation
Detecting heart disease at an early stage can significantly reduce treatment
costs, improve patient outcomes, and save lives. Machine learning models,
trained on historical clinical data, can support doctors by offering a second
opinion or early warning system. The motivation behind this project is to
develop an accurate and interpretable prediction model that leverages patient
data to assist healthcare providers in making timely and informed decisions.
3. Literature Review
Numerous studies have evaluated the performance of machine learning
models in predicting cardiovascular conditions. For instance, Detrano et al.
analyzed heart disease prediction using logistic regression and reported
notable success. Subsequent studies implemented decision trees and neural
networks, showing improvements in precision and recall.
Recent developments focus on ensemble learning methods such as Random
Forests and Gradient Boosting Machines (GBMs), with XGBoost emerging
as one of the most powerful algorithms due to its ability to handle sparse
data, manage missing values, and prevent overfitting through regularization.
Another notable trend is the use of Support Vector Machines in clinical
prediction, which provide strong performance on non-linear problems due to
their flexibility with kernel functions.
In summary, research indicates that combining robust data
preprocessing techniques with advanced machine learning models can
significantly improve diagnostic accuracy.
4. Problem Statement
The goal of this study is to build a machine learning-based system capable
of predicting the presence of heart disease in patients using a variety of
clinical indicators. Specifically, the project seeks to:
Develop and evaluate models using Logistic Regression, SVM, and
XGBoost.
Analyze and compare model performance using standardized metrics.
Interpret the models to identify key predictors of heart disease.
This system should be interpretable, reliable, and usable in clinical settings,
either as a diagnostic support tool or as a screening mechanism.
5. Dataset Description
5.1 Data Source
The dataset originates from the UCI Machine Learning Repository and is
one of the most cited datasets for heart disease prediction. It contains data
collected from patients undergoing diagnostic procedures related to heart
conditions.
5.2 Attributes
The dataset contains 303 observations across 14 features. Each
instance corresponds to a patient and includes both categorical and
continuous variables:
Age: Age in years
Sex: 1 = male, 0 = female
cp (Chest Pain Type): 0 = typical angina, 1 = atypical angina, 2 = non-
anginal pain, 3 = asymptomatic
trestbps: Resting blood pressure (in mm Hg)
chol: Serum cholesterol (in mg/dl)
fbs: Fasting blood sugar > 120 mg/dl (1 = true; 0 = false)
restecg: Resting electrocardiographic results (0, 1, 2)
thalach: Maximum heart rate achieved
exang: Exercise-induced angina (1 = yes; 0 = no)
oldpeak: ST depression induced by exercise relative to rest
slope: Slope of the peak exercise ST segment (0 = upsloping, 1 = flat, 2 =
downsloping)
ca: Number of major vessels colored by fluoroscopy (0 to 3)
thal: Thalassemia (1 = normal, 2 = fixed defect, 3 = reversible defect)
target: Diagnosis of heart disease (1 = presence; 0 = absence)
The dataset is moderately balanced, with a slight skew towards patients with
heart disease.
6. Data Preprocessing
6.1 Cleaning
Initial exploration identified missing values in ca and thal. These were
replaced using the mode, as they represent categorical data. Outliers in
numeric fields were examined using boxplots, and none were removed since
all fell within clinically acceptable ranges.
6.2 Encoding
One-hot encoding was applied to cp, thal, and slope.
Binary encoding was used for sex, fbs, and exang.
6.3 Normalization
Continuous features (age, trestbps, chol, thalach, oldpeak) were
normalized using Min-Max scaling to bring them to a 0-1 range, which
benefits convergence in gradient-based algorithms.
7. Exploratory Data Analysis
7.1 Univariate Analysis
Age: Patients with heart disease tended to be older, with a significant
concentration between 50-60 years.
Cholesterol: Wide variation, but higher cholesterol did not always correlate
with disease presence.
Chest Pain Type: Type 0 (typical angina) was more prevalent among non-
diseased patients.
7.2 Bivariate Analysis
cp vs target: Type 2 and 3 chest pain were more common among heart
disease patients.
thalach vs target: Higher heart rate was observed in non-diseased
individuals.
7.3 Correlation Matrix
Heatmap revealed moderate to strong correlations between:
cp and target
oldpeak and target
thalach and target
8. Modeling
8.1 Logistic Regression
Linear model for binary classification.
Easily interpretable coefficients.
Accuracy: 85%
Highlighted importance of cp, thalach, oldpeak.
8.2 Support Vector Machine (SVM)
Utilized RBF kernel.
Required tuning of C and gamma.
Accuracy: 87%
Advantage: Handles non-linear relationships well.
8.3 XGBoost
Ensemble of gradient boosted trees.
Regularization (L1 and L2) helps prevent overfitting.
Native handling of missing values.
Accuracy: 91%
Feature importance revealed top predictors: cp, thal, oldpeak,
thalach.
9. Evaluation Metrics
Each model was evaluated using:
Accuracy: Overall correctness
Precision: True Positives / Predicted Positives
Recall: True Positives / Actual Positives
F1-Score: Harmonic mean of Precision and Recall
ROC-AUC: Area under Receiver Operating Characteristic
curve
9.1 Comparison Table
Model Accuracy Precision Recall F1-Score ROC-AUC
Logistic
85% 0.84 0.86 0.85 0.88
Regression
SVM 87% 0.86 0.87 0.86 0.89
XGBoost 91% 0.90 0.92 0.91 0.93
10. Results and Discussion
The evaluation clearly shows that XGBoost outperforms both Logistic
Regression and SVM in accuracy and other key metrics. Logistic Regression
remains valuable for its interpretability. SVM proved to be effective but
required substantial tuning.
XGBoost identified cp, thal, oldpeak, and thalach as the most
influential features. These align with known clinical indicators of heart
disease, suggesting the model's reliability.
11. Conclusion
Machine learning models, particularly ensemble methods like XGBoost,
offer strong potential in the early prediction of heart disease. The
comparative study showed that while traditional models like Logistic
Regression are simple and interpretable, advanced models provide superior
accuracy and robustness.
Integrating such predictive systems into healthcare environments can
improve decision-making, reduce diagnostic delays, and ultimately enhance
patient care.
12. References
UCI Machine Learning Repository
Heart Disease Prediction using Machine Learning Algorithms - International
Journal of Science and Research
Chen, T., & Guestrin, C. (2016). XGBoost: A Scalable Tree Boosting
System
WHO Cardiovascular Disease Factsheet
Scikit-learn Documentation
Papers with Code - Heart Disease Prediction Benchmarks
Towards Data Science articles on Heart Disease Prediction
CODE SNIPETS :