@@ -3532,8 +3532,8 @@ \subsection{Exercise 12}
3532
3532
\begin {frame }{Ex12: Binary Classification}
3533
3533
Objectives
3534
3534
\begin {itemize }
3535
- \item binary classifier as most simple non-linear model
3536
- \item check ingredients on that model: architecture, output activation function, an appropriate loss function, forward and back propagation, gradient descent
3535
+ \item binary classifier as most simple non-linear model using sigmoid activation function
3536
+ \item check ingredients on that model: architecture, output activation function, an appropriate loss function (sigmoid) , forward and back propagation, gradient descent
3537
3537
\end {itemize }
3538
3538
\end {frame }
3539
3539
@@ -3972,7 +3972,7 @@ \subsection{Exercise 13}
3972
3972
\end {itemize }
3973
3973
\end {frame }
3974
3974
3975
- \begin {frame }{Binary Classification with Hidden Layer Model}
3975
+ \begin {frame }{Binary Classification with Hidden Layers and Sigmoid Output Model}
3976
3976
%
3977
3977
\vspace {-0.25cm}
3978
3978
\begin {center }
@@ -4121,8 +4121,89 @@ \subsection{Exercise 13}
4121
4121
4122
4122
4123
4123
4124
+ \begin {frame }[t]{Confusion Matrix for Binary Classification}
4125
+ %
4126
+ \begin {center }
4127
+ \begin {tikzpicture }[scale=1.25]
4128
+ \tikzstyle {mtxi}=[draw, shape=rectangle,minimum size=1.5cm]
4129
+ \tikzstyle {mtxo}=[draw=none, shape=rectangle,minimum size=0.5cm]
4130
+ \node [mtxi, fill=C2!75, align=center](tn) at (-0.75,+0.75){$ \textcolor {C0}{0} | \textcolor {C3}{0}$ \\ TN\\ \textcolor {C3}{0},\textcolor {C0}{0}};
4131
+ \node [mtxi, align=center](fp) at (+0.75,+0.75){$ \textcolor {C0}{1} | \textcolor {C3}{0}$ \\ FP\\ \textcolor {C3}{0},\textcolor {C0}{1}};
4132
+ \node [mtxi, align=center](fn) at (-0.75,-0.75){$ \textcolor {C0}{0} | \textcolor {C3}{1}$ \\ FN\\ \textcolor {C3}{1},\textcolor {C0}{0}};
4133
+ \node [mtxi, fill=C2!75, align=center](tp) at (+0.75,-0.75){$ \textcolor {C0}{1} | \textcolor {C3}{1}$ \\ TP\\ \textcolor {C3}{1},\textcolor {C0}{1}};
4134
+ %
4135
+ \node [mtxo, align=center](realtrue) at (-1.5,+0.75){$ \textcolor {C3}{0}$ };
4136
+ \node [mtxo, align=center](realfalse) at (-1.5,-0.75){$ \textcolor {C3}{1}$ };
4137
+ \node [mtxo, align=center](predtrue) at (-0.75,+1.5){$ \textcolor {C0}{0}$ };
4138
+ \node [mtxo, align=center](predfalse) at (+0.75,1.5){$ \textcolor {C0}{1}$ };
4139
+ %
4140
+ \node [mtxo, align=center, rotate=90](reallbl) at (-1.75,0){\textcolor {C3}{real} class};
4141
+ \node [mtxo, align=center](predlbl) at (0,1.75){\textcolor {C0}{predicted} class};
4142
+ %
4143
+ \node [mtxo, align=left](realfalse) at (2.25,+0.75){$ \text {R}_0 = \text {TN}+\text {FP}$ };
4144
+ \node [mtxo, align=left](realtrue) at (2.25,-0.75){$ \text {R}_1 = \text {FN}+\text {TP}$ };
4145
+ %
4146
+ \node [mtxo, align=center](predfalse) at (-0.75,-1.75){$ \text {P}_0 =$ \\ $ \text {TN}+\text {FN}$ };
4147
+ \node [mtxo, align=center](predtrue) at (+0.75,-1.75){$ \text {P}_1 =$ \\ $ \text {FP}+\text {TP}$ };
4148
+ %
4149
+ \end {tikzpicture }
4150
+ \end {center }
4151
+ %
4152
+ \begin {align* }
4153
+ &\text {ACC}=\frac {\text {TN}+\text {TP}}{\text {R}_0+\text {R}_1}
4154
+ \qquad
4155
+ \text {TNR}=\frac {\text {TN}}{\text {R}_0}
4156
+ \qquad
4157
+ \text {TPR}=\frac {\text {TP}}{\text {R}_1}
4158
+ \\
4159
+ &\text {ACC}=\frac {\text {TN}+\text {TP}}{\text {P}_0+\text {P}_1}
4160
+ \qquad
4161
+ \text {NPV}=\frac {\text {TN}}{\text {P}_0}
4162
+ \qquad
4163
+ \text {PPV}=\frac {\text {TP}}{\text {P}_1}
4164
+ \end {align* }
4165
+ %
4166
+ \end {frame }
4167
+
4124
4168
4125
- \begin {frame }[label=MultiLabelClassification]{Multi-Label Classification with Hidden Layer Model}
4169
+
4170
+ \begin {frame }[t]{Binary Classification Metrics}
4171
+ %
4172
+ $ \cdot $ TNR = specificity / selectivity, NPV = ?, TPR = sensitivity / recall, PPV = precision
4173
+
4174
+ $ \cdot $ metric based on TNR and TPR
4175
+
4176
+ $ \cdot $ metric based on TNR and NPV and/or TPR and PPV
4177
+
4178
+ $ \cdot $ TPR vs. PPV extrem cases
4179
+ \begin {align* }
4180
+ &\text {TPR}=\frac {\text {TP}}{\text {R}_1}=\frac {\text {TP}}{\text {TP}+\text {FN}}
4181
+ &\text {PPV}=\frac {\text {TP}}{\text {P}_1}=\frac {\text {TP}}{\text {TP}+\text {FP}}\\
4182
+ &\text {TPR}\approx 0: \text {FN} \gg \text {TP},\,\,\, \text {TP} \approx 0
4183
+ &\text {PPV}\approx 0: \text {FP} \gg \text {TP},\,\,\, \text {TP} \approx 0\\
4184
+ &\text {TPR}\approx 1: \text {TP} \gg \text {FN},\,\,\, \text {FN} \approx 0
4185
+ &\text {PPV}\approx 1: \text {TP} \gg \text {FP},\,\,\, \text {FP} \approx 0\\
4186
+ \end {align* }
4187
+ %
4188
+ $ \cdot $ $ \text {TPR}\approx 1 $ and $ \text {PPV}\approx 0 $ : few FN but many FP (e.g. overestimation of infections)
4189
+
4190
+ $ \cdot $ $ \text {TPR}\approx 0 $ and $ \text {PPV}\approx 1 $ : few FP but many FN (e.g. underestimation of infections)
4191
+
4192
+ $ \cdot $ a potentially meaningful(?!) average (harmonic mean)
4193
+ $$
4194
+ \left (\frac {\frac {1}{\text {TPR}} + \frac {1}{\text {PPV}}}{2}\right )^{-1}
4195
+ =
4196
+ 2 \cdot \frac {\text {TPR}\cdot\text {PPV}}{\text {TPR}+\text {PPV}}
4197
+ =
4198
+ 2 \cdot \frac {\text {recall}\cdot\text {precision}}{\text {recall}+\text {precision}}
4199
+ =F_1 \,\,\, \text {score}
4200
+ $$
4201
+
4202
+ \end {frame }
4203
+
4204
+
4205
+
4206
+ \begin {frame }[label=MultiLabelClassification]{Multi-Label Classification with Hidden Layer and Sigmoid Output Model}
4126
4207
%
4127
4208
\vspace {-0.25cm}
4128
4209
\begin {center }
@@ -4192,7 +4273,7 @@ \subsection{Exercise 13}
4192
4273
\end {bmatrix}
4193
4274
$ };
4194
4275
%
4195
- \node [](sigmoid) at (9.5,0)[]{sigmoid $ \sigma _3 (\cdot )$ };
4276
+ \node [](sigmoid) at (9.5,0)[]{\underline { sigmoid} $ \sigma _3 (\cdot )$ };
4196
4277
%
4197
4278
\end {tikzpicture }
4198
4279
\end {center }
@@ -4246,95 +4327,6 @@ \subsection{Exercise 13}
4246
4327
4247
4328
4248
4329
4249
-
4250
-
4251
-
4252
-
4253
-
4254
-
4255
-
4256
- \begin {frame }[t]{Confusion Matrix for Binary Classification}
4257
- %
4258
- \begin {center }
4259
- \begin {tikzpicture }[scale=1.25]
4260
- \tikzstyle {mtxi}=[draw, shape=rectangle,minimum size=1.5cm]
4261
- \tikzstyle {mtxo}=[draw=none, shape=rectangle,minimum size=0.5cm]
4262
- \node [mtxi, align=center](tn) at (-0.75,+0.75){$ \textcolor {C0}{0} | \textcolor {C3}{0}$ \\ TN\\ \textcolor {C3}{0},\textcolor {C0}{0}};
4263
- \node [mtxi, align=center](fp) at (+0.75,+0.75){$ \textcolor {C0}{1} | \textcolor {C3}{0}$ \\ FP\\ \textcolor {C3}{0},\textcolor {C0}{1}};
4264
- \node [mtxi, align=center](fn) at (-0.75,-0.75){$ \textcolor {C0}{0} | \textcolor {C3}{1}$ \\ FN\\ \textcolor {C3}{1},\textcolor {C0}{0}};
4265
- \node [mtxi, align=center](tp) at (+0.75,-0.75){$ \textcolor {C0}{1} | \textcolor {C3}{1}$ \\ TP\\ \textcolor {C3}{1},\textcolor {C0}{1}};
4266
- %
4267
- \node [mtxo, align=center](realtrue) at (-1.5,+0.75){$ \textcolor {C3}{0}$ };
4268
- \node [mtxo, align=center](realfalse) at (-1.5,-0.75){$ \textcolor {C3}{1}$ };
4269
- \node [mtxo, align=center](predtrue) at (-0.75,+1.5){$ \textcolor {C0}{0}$ };
4270
- \node [mtxo, align=center](predfalse) at (+0.75,1.5){$ \textcolor {C0}{1}$ };
4271
- %
4272
- \node [mtxo, align=center, rotate=90](reallbl) at (-1.75,0){\textcolor {C3}{real} class};
4273
- \node [mtxo, align=center](predlbl) at (0,1.75){\textcolor {C0}{predicted} class};
4274
- %
4275
- \node [mtxo, align=left](realfalse) at (2.25,+0.75){$ \text {R}_0 = \text {TN}+\text {FP}$ };
4276
- \node [mtxo, align=left](realtrue) at (2.25,-0.75){$ \text {R}_1 = \text {FN}+\text {TP}$ };
4277
- %
4278
- \node [mtxo, align=center](predfalse) at (-0.75,-1.75){$ \text {P}_0 =$ \\ $ \text {TN}+\text {FN}$ };
4279
- \node [mtxo, align=center](predtrue) at (+0.75,-1.75){$ \text {P}_1 =$ \\ $ \text {FP}+\text {TP}$ };
4280
- %
4281
- \end {tikzpicture }
4282
- \end {center }
4283
- %
4284
- \begin {align* }
4285
- &\text {ACC}=\frac {\text {TN}+\text {TP}}{\text {R}_0+\text {R}_1}
4286
- \qquad
4287
- \text {TNR}=\frac {\text {TN}}{\text {R}_0}
4288
- \qquad
4289
- \text {TPR}=\frac {\text {TP}}{\text {R}_1}
4290
- \\
4291
- &\text {ACC}=\frac {\text {TN}+\text {TP}}{\text {P}_0+\text {P}_1}
4292
- \qquad
4293
- \text {NPV}=\frac {\text {TN}}{\text {P}_0}
4294
- \qquad
4295
- \text {PPV}=\frac {\text {TP}}{\text {P}_1}
4296
- \end {align* }
4297
- %
4298
- \end {frame }
4299
-
4300
-
4301
-
4302
- \begin {frame }[t]{Binary Classification Metrics}
4303
- %
4304
- $ \cdot $ TNR = specificity / selectivity, NPV = ?, TPR = sensitivity / recall, PPV = precision
4305
-
4306
- $ \cdot $ metric based on TNR and TPR
4307
-
4308
- $ \cdot $ metric based on TNR and NPV and/or TPR and PPV
4309
-
4310
- $ \cdot $ TPR vs. PPV extrem cases
4311
- \begin {align* }
4312
- &\text {TPR}=\frac {\text {TP}}{\text {R}_1}=\frac {\text {TP}}{\text {TP}+\text {FN}}
4313
- &\text {PPV}=\frac {\text {TP}}{\text {P}_1}=\frac {\text {TP}}{\text {TP}+\text {FP}}\\
4314
- &\text {TPR}\approx 0: \text {FN} \gg \text {TP},\,\,\, \text {TP} \approx 0
4315
- &\text {PPV}\approx 0: \text {FP} \gg \text {TP},\,\,\, \text {TP} \approx 0\\
4316
- &\text {TPR}\approx 1: \text {TP} \gg \text {FN},\,\,\, \text {FN} \approx 0
4317
- &\text {PPV}\approx 1: \text {TP} \gg \text {FP},\,\,\, \text {FP} \approx 0\\
4318
- \end {align* }
4319
- %
4320
- $ \cdot $ $ \text {TPR}\approx 1 $ and $ \text {PPV}\approx 0 $ : few FN but many FP (e.g. overestimation of infections)
4321
-
4322
- $ \cdot $ $ \text {TPR}\approx 0 $ and $ \text {PPV}\approx 1 $ : few FP but many FN (e.g. underestimation of infections)
4323
-
4324
- $ \cdot $ a potentially meaningful(?!) average (harmonic mean)
4325
- $$
4326
- \left (\frac {\frac {1}{\text {TPR}} + \frac {1}{\text {PPV}}}{2}\right )^{-1}
4327
- =
4328
- 2 \cdot \frac {\text {TPR}\cdot\text {PPV}}{\text {TPR}+\text {PPV}}
4329
- =
4330
- 2 \cdot \frac {\text {recall}\cdot\text {precision}}{\text {recall}+\text {precision}}
4331
- =F_1 \,\,\, \text {score}
4332
- $$
4333
-
4334
- \end {frame }
4335
-
4336
-
4337
-
4338
4330
\subsection {Exercise 14 }
4339
4331
4340
4332
\begin {frame }{Ex14: Multi-Class Classification with Softmax Output Layer}
@@ -4476,7 +4468,7 @@ \subsection{Exercise 14}
4476
4468
4477
4469
\againframe {MultiLabelClassification}
4478
4470
%
4479
- \begin {frame }{Multi-Class Classification with Hidden Layer Model}
4471
+ \begin {frame }{Multi-Class Classification with Hidden Layer and Softmax Output Model}
4480
4472
%
4481
4473
\vspace {-0.25cm}
4482
4474
\begin {center }
@@ -4546,7 +4538,7 @@ \subsection{Exercise 14}
4546
4538
\end {bmatrix}
4547
4539
$ };
4548
4540
%
4549
- \node [](sigmoid) at (9.5,0)[]{softmax $ \sigma _3 (\cdot )$ };
4541
+ \node [](sigmoid) at (9.5,0)[]{\underline { softmax} $ \sigma _3 (\cdot )$ };
4550
4542
%
4551
4543
\end {tikzpicture }
4552
4544
\end {center }
@@ -4596,7 +4588,7 @@ \subsection{Exercise 14}
4596
4588
4597
4589
4598
4590
4599
- \begin {frame }{Softmax Activation Combined With Categorical Cross Entropy}
4591
+ \begin {frame }{Softmax Activation Output Combined With Categorical Cross Entropy}
4600
4592
4601
4593
$ \cdot $ $ \hat {y}_{i=1 \dots K} \in \mathbb {R}$ model outputs with $ K$ mutual exclusive classes
4602
4594
@@ -4629,7 +4621,7 @@ \subsection{Exercise 14}
4629
4621
4630
4622
4631
4623
4632
- \begin {frame }{Multi-Class Classification with Hidden Layer Model}
4624
+ \begin {frame }{Multi-Class Classification with Hidden Layer and Softmax Output Model}
4633
4625
%
4634
4626
\vspace {-0.25cm}
4635
4627
\begin {center }
@@ -4699,7 +4691,7 @@ \subsection{Exercise 14}
4699
4691
\end {bmatrix}
4700
4692
$ };
4701
4693
%
4702
- \node [](sigmoid) at (9.5,0)[]{softmax $ \sigma _3 (\cdot )$ };
4694
+ \node [](sigmoid) at (9.5,0)[]{\underline { softmax} $ \sigma _3 (\cdot )$ };
4703
4695
%
4704
4696
\end {tikzpicture }
4705
4697
\end {center }
@@ -4851,7 +4843,7 @@ \subsection{Exercise 14}
4851
4843
\node [mtxo, align=center](predlbl) at (0,2){\textcolor {C0}{predicted} class};
4852
4844
%
4853
4845
\node at (0,-2){100\% percent per row};
4854
- \node at (0,-3){good for unbalanced classes};
4846
+ \node at (0,-3){good for (un)balanced classes};
4855
4847
\end {scope }
4856
4848
%
4857
4849
\end {tikzpicture }
0 commit comments