Project Goal
1. Use Naive Bayes’ Classifier to Predict Heart Attacks Based on Patient’s Symptoms.
Context
2. After completing the project to identify the rules that predict patient’s heart disease, the Clinic reached out again wanting to know who is likely to have a heart attack based on his/her symptoms.
Dataset
3. The dataset was explored for its relationships and patterns, and it’s found that, through its univariate, bivariate and multivariate analysis, the data is highly correlated and suitable for modelling.
Strategies For Modelling & Data Analysis
4. Data Preparation: Three new categorical features were created.
5. Train Model: PivotTables are created for the features and probabilities calculated.
6. Findings & Conclusions: The probability of Patient A, given her attributes, is 53.66% more likely to have an heart attack as compared to Patient B, whose probability of experiencing an heart attack is merely 9.79%, given his attributes.
Author: Anthony Mok
Date: 16 Nov 2023
Email: xxiaohao@yahoo.com
Similar to Decision Making Under Uncertainty - Predict the Chances of a Person Suffering a Heart Attack - An Application of a Classifier Using Bayes' Theorem
Similar to Decision Making Under Uncertainty - Predict the Chances of a Person Suffering a Heart Attack - An Application of a Classifier Using Bayes' Theorem (20)
Decision Making Under Uncertainty - Predict the Chances of a Person Suffering a Heart Attack - An Application of a Classifier Using Bayes' Theorem
1. PREDICTING HEART ATTACKS
BASED ON PATIENT’S SYMPTOMS
AN APPLICATION OF BAYES’ THEOREM CL ASSIFIER
A u t h o r : A n t h o n y M o k
D a t e : 1 6 N o v 2 0 2 3
E m a i l : x x i a o h a o @ y a h o o . c o m
2. AGENDA
• Briefs On Bayes’ Theorem, Classifiers &
Naïve Bayes’ Classifiers
• Project’s Objectives
• Context, Dataset & Dictionary
• Strategies For Modelling & Data Analysis
• Findings & Conclusions
2023 AN APPLIC A TI O N OF BAYES’ THEOREM CLASSIF IER 2
3. BAYES’ THEOREM
Bayes’ Theorem (Bayes' rule or Bayes' law), is a
mathematical formula that describes the
probability of an event, based on prior knowledge
of conditions that might be related to the event.
Bayes' theorem talks about the probability of
event A after we have observed event B since it
accounts that event B is related to event A
3
A Classifier is a type of
algorithm that automatically
assigns a class label to a data
input. Classifiers are trained
on labelled data, which means
the data are pre-classified into
different categories before
use. Once trained, it classifies
a new data point by analysing
its features and assigning it to
a class label based on the
training data used by the
Classifier
Are a simple but powerful type of
probabilistic classifier based on Bayes'
Theorem. They assume that the features of a
data point are independent of each other,
which is often not the case in real-world
scenarios. Despite this assumption, Naive
Bayes’ Classifiers often perform well in
practice, especially when a large amount of
training data are being used
NAÏVE BAYES CLASSIFIERS
CLASSIFIERS
2023 AN APPLIC A TI O N OF BAYES’ THEOREM CLASSIF IER
4. Project Goal
Use Naive Bayes’ Classifier to Predict Heart
Attacks Based on Patient’s Symptoms
2023 An Application of Bayes’ Theorem Classifier
5. CONTEXT, DATASET & DICTIONARY
5
2023 AN APPLIC A TI O N OF BAYES’ THEOREM CLASSIF IER
Context
After completing the project to identify the rules
that predict patient’s heart disease, the Clinic
reached out wanting to know who is likely to have
a heart attack based on his/her symptoms
Dataset & Data Dictionary
The dataset was explored for its relationships and
patterns, and it’s found that, through its univariate,
bivariate and multivariate analysis, the data is highly
correlated and suitable for modelling
6. 1. DATA PREPARATION
T HREE N EW C ATEGORICAL
F EATURES WERE C REATED
2023 AN APPLIC A TI O N OF BAYES’ THEOREM CLASSIF IER
‘ age_group’ fe ature (from the ‘age’
column)
Where Patients:
• U n d e r t h e a g e of 1 4 a re t o b e g ro u p e d
a s c h i l d re n
• G re a t e r t h a n o r e q u a l t o t h e a g e 1 4 a n d
l e s s t h a n 2 5 a re t o b e g ro u p e d a s Yo u t h
• G re a t e r t h a n o r e q u a l t o t h e a g e 2 5
a n d l e s s t h a n 6 4 a re t o b e g ro u p e d a s
A d u l t s
• O f t h e a g e of 6 4 a n d a b o v e a re t o b e
g ro u p e d a s S e n i o r s
F o r m u l a e U s e d
= I F ( A 4 < 1 4 , " C h i l d re n" , I F ( A 4 < 2 5 , " Yo u t h s " , I F ( A
4 > = 6 4 , " S e n i o r s " , " A d u l t s " ) ) )
‘chol_level ’ fe ature (from the
‘chol’ column), using VLOOKUP
Where ‘chol’:
• B e t w e e n 0 - 2 0 0 i s c l a s s i f i e d a s
‘g o o d ’
• B e t w e e n 2 0 1 - 2 4 0 i s c l a s s i f i e d
a s ‘ b o rd e r l i n e ’
• > 2 4 0 i s c l a s s i f i e d a s ‘ h i g h ’
F o r m u l a e U s e d
= V LO O K U P ( @ G 4 : G 3 0 6 , $ P $ 1 2 : $ Q $ 1 4
, 2 , T R U E )
‘ bp_level ’ fe ature (from the
‘rest_bp’ column), using VLOOKUP
Where ‘rest)_bp’:
• B e t w e e n 0 - 9 0 i s l a b e l l e d a s ‘ l o w ’
• B e t w e e n 9 1 - 1 4 0 i s l a b e l l e d a s
‘ i d e a l ’
• > 1 4 0 i s l a b e l l e d a s ‘ h i g h ’
F o r m u l a e U s e d
= V LO O K U P ( @ F 4 : F 3 0 6 , $ P $ 7 : $ Q $ 9 , 2 , T R
U E )
STRATEGIES FOR MODELLING & DATA ANALYSIS
7. 2. TRAIN MODEL
2023 AN APPLIC A TI O N OF BAYES’ THEOREM CLASSIF IER
P i votTables
PivotTables are created for the following
features:
• Age Group
• Sex
• BP Level
• EXNG
• Chol_level
• Target
C alculation of P robabilities
S a m p l e of F o r m u l a e U s e d
= G E T P I V OT DATA ( " a g e" , $ S $ 3 , " t a rg e t " , 1 , " A g e _ G ro u p s " , " A
d u l t s " )
STRATEGIES FOR MODELLING & DATA ANALYSIS
8. 3. MAKING PREDICTIONS
2023 AN APPLIC A TI O N OF BAYES’ THEOREM CLASSIF IER
What is the probability that these patients
have a hear t attack?
FINDINGS & CONCLUSIONS*
Snapshot of Two Health Report From the Clinic
Patient A Patient B
• age: 34
• sex: Female (i.e., 0)
• bp_level: ideal
• exng: has exercise induced
angina (i.e., 1) chol_level:
borderline
• age: 72
• sex: Male (i.e., 1)
• bp_level: high
• exng: has exercise induced
angina (i.e., 1)
• chol_level: high
Conclusions
The probability of Patient A , given her attributes, is 53.66% more likely to
have an hear t attack as compared to Patient B, whose probability of
experiencing an hear t attack is merely 9.79%, given his attributes
Findings
* More findings and conclusions are found in the project report, which are not released at the request of the Clinic
9. PREDICTING HEART ATTACKS
BASED ON PATIENT’S SYMPTOMS
AN APPLICATION OF BAYES’ THEOREM CL ASSIFIER
A u t h o r : A n t h o n y M o k
D a t e : 1 6 N o v 2 0 2 3
E m a i l : x x i a o h a o @ y a h o o . c o m