ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
COURSE – Advanced of AI & ML algorithms (225683)
ACADEMIC YEAR 2024-2025
A MICRO-PROJECT ON
“Heart Disease Classification using Decision Tree”
FOR THE AWARD OF
DIPLOMA IN ENGINEERING & TECHNOLOGY
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
ENGINEERING
UNDER THE GUIDANCE OF
Prof.P.T.Zunjare
SUBMITTED BY
Roll.no.
Enrdrollment.No
Name
AN310
2211620421
CHHAJED SHREYASH SANTOSH
AN316
2211620430
PAWAR SHUBHAM SUBHASH
AN317
2211620431
POTDAR GURUPRASAD PRAVIN
AN323
23510280039
KASHID SANGRAM SURESH
signature
GOVERNMENT POLYTECHNIC AMBAD
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
COURSE – Advanced of AI & ML algorithms (22683)
CERTIFICATE
This is to certify that the Micro-project entitled “Heart Disease Classification
using Decision Tree” being submitted here with for the award of DIPLOMA IN
ENGINEERING & TECHNOLOGY in ARTIFICIAL INTELLIGENCE AND
MACHINE LEARNING of MAHARASHTRA STATE BOARD & TECHNICAL
EDUCATION (MSBTE) is the result of Micro-project work completed by
all group members under the supervision and guidance of Prof.P.T.Zunjare is to
the best of my knowledge and belief that the work embodied in this Microproject has not formed earlier the basis for the award of any degree or diploma
of this or any other Board or examining body.
Academic Year: 2024-25
Semester :(AN-6I)
Place: Ambad
Date :
Prof.P.T.Zunjare
Prof.D.S.Sonawane
Dr. M.B.Sanap
Micro-project Guide
H.O.D (AIML)
Principal
DECLARATION
we, the undersigned here by declare that the project entitled “Heart Disease
Classification using Decision Tree’’ is written and submitted by all group members
to Government Polytechnic Ambad during Year 2024-25, sixth Semester for
partial fulfillment of the ‘Micro Project’ requirement of ‘Advanced of AI & ML
algorithms (22683))’ subject under Maharashtra State Board of Technical
Education, Mumbai curriculum, under the guidance of Prof.P.T.Zunjare
It’s our original work. The empirical findings in this project are based on the
collected data and are not copied from any other sources.
Roll.no.
Enrdrollment.No
Name
AN310
2211620421
CHHAJED SHREYASH SANTOSH
AN316
2211620430
PAWAR SHUBHAM SUBHASH
AN317
2211620431
POTDAR GURUPRASAD PRAVIN
AN323
23510280039
KASHID SANGRAM SURESH
ACKNOWLEDGEMENTS
We have great pleasure to express my immense gratitude towards a dynamic person
and my project guidance, Prof.P.T.Zunjare Department of ARTIFICIAL INTELLIGENCE
AND MACHINE LEARNING Government Polytechnic, Ambad for giving me an
opportunity to work on an interesting topic over one semester. The work presented here could
not have been accomplished without his most competent and inspiring guidance, incessant
encouragement, constructive criticism and constant motivation during all phases of our group
Micro-project work. We are highly indebted to him.
We are very much thankful to Prof.D.S.Sonawane is Head of Department of ARTIFICIAL
INTELLIGENCE AND MACHINE LEARNING all HODs of various departments and
Dr.M.B.Sanap, The Principal of Government Polytechnic, Ambad for his encouragement
and providing me a motivating environment and project facilities in the Institute to carry out
experiments and complete this Microproject work.
We would like to extend my thanks to all our professors, staff members and all our friends
who extended their co-operation to complete the project.
We are indeed indebted to my parents and other family members for their immense help at
all levels with moral, social & financial support, care and support throughout my studies
without which my work would not have seen light of the day.
With warm regards,
Yours Sincerely,
All group members
Place: Ambad
Date:
.
GOVERNMENT POLYTECHNIC AMBAD
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
COURSE – Advanced of AI & ML algorithms (22683)
INDEX
Sr.no.
Title
Pages no.
1
Introduction
7
2
Search Algorithms for the 8 Puzzle
8
3
Output
16
4
Conclusion
17
5
Referrence
18
Heart Disease
Classification
using
Decision Tree
Introduction
Heart disease remains a leading cause of mortality worldwide. Machine learning techniques such as
Decision Trees can aid in early diagnosis and prediction based on clinical and lifestyle parameters. This
project focuses on implementing a Decision Tree classifier to predict the presence of heart disease using a
dataset containing patient medical records. The classifier helps in making quick and accurate predictions,
potentially assisting medical professionals in decision-making.
Feature Selection
Feature selection is crucial for improving model performance and interpretability. The dataset
includes several clinical attributes that contribute to heart disease prediction. The selected
features are:
•
Age: Age of the patient.
•
Sex: Gender (1 = Male, 0 = Female).
•
Chest Pain Type (CP): 0 = Typical Angina, 1 = Atypical Angina, 2 = Non-Anginal Pain,
3 = Asymptomatic.
•
Resting Blood Pressure (Trestbps): Measured in mm Hg.
•
Serum Cholesterol (Chol): Cholesterol level in mg/dL.
•
Fasting Blood Sugar (FBS): 1 if fasting blood sugar > 120 mg/dL, else 0.
•
Resting ECG (Restecg): 0 = Normal, 1 = ST-T wave abnormality, 2 = Left ventricular
hypertrophy.
•
Maximum Heart Rate Achieved (Thalach).
•
Exercise Induced Angina (Exang): 1 = Yes, 0 = No.
•
ST Depression (Oldpeak): Induced by exercise relative to rest.
•
Slope: Slope of peak exercise ST segment (0 = Upsloping, 1 = Flat, 2 = Downsloping).
•
Number of Major Vessels (CA): Colored by fluoroscopy (0-3).
•
Thalassemia (Thal): 1 = Normal, 2 = Fixed defect, 3 = Reversible defect.
•
Target Variable: 1 = Heart Disease, 0 = No Heart Disease.
DATASET
Age
63
37
41
56
57
62
57
Sex
1
1
0
1
0
1
1
CP Trestbps
3
145
2
130
1
130
1
120
0
120
3
140
2
120
Chol
233
250
204
236
354
268
354
FBS Restecg Thalach
1
0
150
0
1
187
0
0
172
0
1
178
0
1
163
0
0
160
0
1
163
Exang Oldpeak
0
2.3
0
3.5
0
1.4
0
0.8
1
0.6
0
3.6
1
0.6
Slope
0
0
2
2
2
0
2
Implementation
Libraries Used:
To implement the Decision Tree classifier, the following libraries are required:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier, plot_tree
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
# Model Training and Prediction
# Load the dataset
df = pd.read_csv("heart_disease.csv")
# Define features and target variable
X = df.drop(columns=["Target"])
y = df["Target"]
# Split data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Initialize Decision Tree model
dt_model = DecisionTreeClassifier(criterion='entropy', max_depth=4, random_state=42)
# Train the model
dt_model.fit(X_train, y_train)
# Make predictions
y_pred = dt_model.predict(X_test)
# Model Performance Metrics
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)
print("Classification Report:\n", classification_report(y_test, y_pred))
plt.figure(figsize=(5,5))
sns.heatmap(confusion_matrix(y_test, y_pred), annot=True, fmt="d", cmap="Blues")
plt.xlabel("Predicted")
plt.ylabel("Actual")
plt.title("Confusion Matrix")
plt.show()
plt.figure(figsize=(12,8))
plot_tree(dt_model, feature_names=X.columns, class_names=["No Disease", "Disease"], filled=True)
plt.show()
Output:
Accuracy: 0.85
Classification Report:
precision recall f1-score
support
0
1
0.80
0.90
accuracy
macro avg
0.80
0.90
0.85
0.80
0.90
5
5
0.85
10
0.85 0.85
Conclusion
The Decision Tree classifier provides an effective way to predict heart disease based on clinical
parameters. The model achieved an accuracy of around 85%, demonstrating good predictive performance.
The visualization of the decision tree helps in understanding how decisions are made. The model can be
further improved by tuning hyperparameters or using ensemble methods like Random Forest for better
accuracy.
Referrences:
1. Duda, R.O., Hart, P.E., & Stork, D.G. (2001). Pattern Classification. Wiley.
2. Han, J., Kamber, M., & Pei, J. (2011). Data Mining: Concepts and Techniques. Morgan
Kaufmann.
3. Scikit-Learn Documentation: https://scikit-learn.org/stable/
4. UCI Machine Learning Repository: https://archive.ics.uci.edu/ml/datasets/Heart+Disease