-
Notifications
You must be signed in to change notification settings - Fork 0
/
jQ1_ConfusionMatrix.html
246 lines (210 loc) · 13.6 KB
/
jQ1_ConfusionMatrix.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- START CSS Scripts -->
<!-- Bootstrap v5 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
<!-- END CSS Scripts -->
<!-- START Favicons Stuff -->
<link rel="apple-touch-icon" sizes="180x180" href="img/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="img/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicons/favicon-16x16.png">
<link rel="manifest" href="img/favicons/site.webmanifest">
<link rel="mask-icon" href="img/favicons/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<!-- END Favicons Stuff -->
<!-- Page Descripting -->
<title>Confusion Matrix</title>
</head>
<body>
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-md navbar-light border-bottom bg-light">
<div class="container-fluid mx-5">
<a class="navbar-brand" href="index.html">
<img src="img/user-astronaut-solid.svg" alt="" width="30" height="24"
class="d-inline-block align-text-top">
Adam A. Butchy
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link" href="index.html">Home</a>
<a class="nav-link" href="jAboutMe.html">About Me</a>
<a class="nav-link active" aria-current="page" href="jProjects.html">Projects</a>
<!-- <a class="nav-link" href="#">Projects</a> -->
<!-- <a class="nav-link disabled">Disabled</a> -->
</div>
</div>
</div>
</nav>
<!-- Content -->
<div class="container mt-3 ml-5 mb-5">
<h1 class="my-3">The Confusion Matrix</h1>
<div class="row">
<div class="col-md-5">
<h3>Introduction</h3>
<p style="text-align: justify;">The confusion matrix is a handy data visualization tool that allows
doctors to quickly understand the accuracy of a medical test. It summarizes how often the test
correctly identifies healthy and sick patients in a group. As such, it is invaluable for conveying
how accurate a test is, and how confident the doctor can be in the test's result. </p>
<p style="text-align: justify;">Imagine you are an engineer, trying to develop a test that can
correctly identify patients that have a disease. In the image to the right, we see an example of a
simple confusion matrix that shows the four different outcomes in a patient population. In the rows,
we see different types of patients (Healthy and Sick), and in the columns, we see the test results
(a Negative Test indicates that the test believes the patient is Healthy, while a Positive Test
indicates that the test believes the patient is Sick). Pretty simple right?
</p>
<p style="text-align: justify;">As an engineer, we have to describe exactly how often the test is
correct in its diagnoses. The problem is, there are many different ways that a diagnostic test can
be right, and there are just as many ways that it can be wrong. The Confusion Matrix allows us to
quickly articulate the relative strenghts and weaknesses of a test in a multitude of scenarios. In
the sections to follow, we'll walk through the main pieces of a the confusion matrix and show
exactly how handy it can be!
</p>
</div>
<div class="col-md-7 d-flex align-text-top">
<div class="row d-flex justify-content-center">
<div class="col-md-12 d-flex justify-content-center align-items-start" height="30%">
<img src="img/ConfMatrix.png" alt="" width="60%" style="object-fit: contain;">
</div>
<div class="col-md-12 pt-4">
<h3>Terminology and Definitions</h3>
<p>
<strong>Healthy </strong> = does not have disease. <br>
<strong>Sick </strong>= does have the disease.<br>
<strong>A Positive Test </strong>= the test says the patient has the disease.<br>
<strong>A Negative Test </strong>= the test says the patient does not have the
disease.<br>
<strong>True Positives \((TP)\) </strong>= a <strong>correct</strong> diagnosis that the
patient
is <strong>
sick</strong>. <br>
<strong>True Negative \((TN)\) </strong>= a <strong>correct</strong> diagnosis that the
patient
is <strong>
NOT sick</strong>.<br>
<strong>False Positive \((FP)\) </strong>= an <strong>incorrect</strong> diagnosis that
the
patient is <strong>
sick</strong>.<br>
<strong>False Negative \((FN)\)</strong> = an <strong>incorrect</strong> diagnosis that
the
patient is <strong>
NOT sick</strong>.
</p>
</div>
</div>
</div>
</div>
<div class="row">
<h3>Still Confused?</h3>
In this description, I will be using "sick" to denote people with some "disease" that we are trying to
identify. In contrast, I will be using "healthy" to denote people without the "disease" that we are trying
to identify. A "Positive" test is one that says the patient in "sick". When the patient is actually sick,
this is known as a True Positive. If the patient was healthy and the test incorrectly indicated that they
were "sick", this is refered to as a "False Positive". In contrast, a "Negative" test
Wikipedia provides a nice introduction to this topic. Much of this content is taken from here. I'm just
trying to visualize it in a clearer, more focused approach (link to citation =
https://en.wikipedia.org/wiki/Confusion_matrix).
There are many different ways to look at this concept. I am going to approach it from the standpoint of a
diagnostic test. In this example, there is a medical test that is meant to determine if pateints are sick or
not sick (healthy)?
Now, there are two piece of of terminology for this situation. The first is "True" vs "False"; and the
second is "Positive" vs "Negative".
<p>In a Confusion Matrix, "True" and "False" are meant to refer to correctly getting the write result. For
instance, the test telling you that you are sick when you are in fact sick. This is pretty intuitive. A
"true" test is one that returns the correct information while a false test is one that returns the
incorrect
result. </p>
<p>Next, "Positive" vs "Negative". This refers to the result of the test itself. For instance if the test
returns "sick" that is considered a "positive" result because it found the presence of disease. In
contrast, a "Negative" test is one that returns a "healthy" </p>
<p>Unfortunately, there are many different ways you can be wrong in such a simple problem. What if you are
really good at identifying healthy patients but not really great at identifying when someone is sick?
Sound confusing, right? If someone isn't healthy, they're automatically sick, right? Yes this is where
the math doen't really translate well into english (or I am just bad at describing it). Perhaps the
clearest way to show you this problem is with another example. Let's say there are 10 patients, 5
healthy and 5 sick. Imagine that this medical test only looks at whether the patient has barfed. Not at
great test, but stick with me. In this case, the test asks each patient if they've barfed. Even though
there are 5 sick patients, only 3 have barfed, leaving you with 7 patients (5 healthy and 2 sick) that
haven't barfed. Guess what, your test is great at identifying healthy people (5 out of 5 healthy people
found), but not great at telling when a patient is sick (3 out of 5 sick people found). In the
paragraphs to follow, this test would be considered a very "Specific" test (or a test with high
specificity) because it is able to accurately identify healthy patients.
</p>
<p>In a perfect world, we wouldn't have to care about such things! Every test would be 100% and the only
things clinicians would need to do was know what tests to order and when. But unfortunately, tests are
not always accurate and clinicians must always consider the accuracy of the tests they prescribe, and
the risks that some tests carry for the patients. but unfortunately we have very few perfect tests that
are able to get it right 100% of the time. Science is still progressing, but in the mean time, we have
to make trade offs depending upon the resources we have availabilt to us, and what we are trying to
detect. In truth, sensitivity is not more important thatn specificity or vice versa, it really matters
what situation you are in and what you are trying to accomplish. Think about pregnancy tests. Is it more
important to correclty identify a pregnant woman, or be able to definitely tell a woman she is not? we
have to make trade offs in different situations. </p>
<p>\(TP = \) True Positives</p>
<p>\(TN = \) True Negatives</p>
<p>\(FP = \) False Positives</p>
<p>\(FN = \) False Negatives</p>
<p>\(Se = \) Sensitivity</p>
<p>\(Sp = \) Specificity</p>
<p>\(PPV = \) Positive Predictive Value</p>
<p>\(NPV = \) Negative Predictive Value</p>
Sensitivity (SE)
$$Se = \frac{TP}{TP+FN}$$
Specificity (Sp)
$$Sp = \frac{TN}{TN+FP}$$
Positive Predictive Value (PPV)
$$PPV = \frac{TP}{TP+FP}$$
Negative Predictive Value (NPV)
$$NPV = \frac{TN}{TN+FN}$$
Accuracy (Acc)
$$Acc = \frac{TP+TN}{TP+TN+FP+FN}$$
<p>In this context, a sensitive diagnostic test is one that is able to correctly diagnose sick people.</p>
<p>In this context, a specific diagnostic test is one that is able to correctly identify healthy people.</p>
</div>
</div>
<!-- Footer -->
<nav class="navbar fixed-bottom navbar-light bg-light border-top">
<div class="container-fluid mx-5 my-2">
<div class="col-md-4">
<span class="text-muted">© 2022 Adam A. Butchy</span>
</div>
<div class="d-flex col-md-4 justify-content-end">
<a href="https://github.com/aabutchy">
<img src="img/github1.svg" alt="" width="30" height="24" class="mx-1">
</a>
<a href="https://www.linkedin.com/in/adambutchy/">
<img src="img/linked3.svg" alt="" width="30" height="24" class="mx-1">
</a>
<a href="https://scholar.google.com/citations?view_op=list_works&hl=en&hl=en&user=iLmtbRYAAAAJ">
<img src="img/scholar7.png" alt="" width="24" height="24" class="mx-1">
</a>
<a href="https://twitter.com/Abutchy">
<img src="img/twitter1.svg" alt="" width="30" height="24" class="mx-1">
</a>
<a href="https://www.instagram.com/abutchy/">
<img src="img/insta2.svg" alt="" width="30" height="24" class="mx-1">
</a>
</div>
</div>
</nav>
<!-- Start JS libraries -->
<!-- Bootstrap v5 -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous">
</script>
<!-- Mathjax js -->
<script src="js/load-mathjax.js" async></script>
<!-- End JS libraries -->
</body>
</html>