Skip to content

Commit 36ae786

Browse files
committed
Update ddasp_exercise_slides.tex
1 parent 569afa0 commit 36ae786

File tree

1 file changed

+92
-100
lines changed

1 file changed

+92
-100
lines changed

slides/ddasp_exercise_slides.tex

Lines changed: 92 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -3532,8 +3532,8 @@ \subsection{Exercise 12}
35323532
\begin{frame}{Ex12: Binary Classification}
35333533
Objectives
35343534
\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
35373537
\end{itemize}
35383538
\end{frame}
35393539

@@ -3972,7 +3972,7 @@ \subsection{Exercise 13}
39723972
\end{itemize}
39733973
\end{frame}
39743974

3975-
\begin{frame}{Binary Classification with Hidden Layer Model}
3975+
\begin{frame}{Binary Classification with Hidden Layers and Sigmoid Output Model}
39763976
%
39773977
\vspace{-0.25cm}
39783978
\begin{center}
@@ -4121,8 +4121,89 @@ \subsection{Exercise 13}
41214121

41224122

41234123

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+
41244168

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}
41264207
%
41274208
\vspace{-0.25cm}
41284209
\begin{center}
@@ -4192,7 +4273,7 @@ \subsection{Exercise 13}
41924273
\end{bmatrix}
41934274
$};
41944275
%
4195-
\node[](sigmoid) at (9.5,0)[]{sigmoid $\sigma_3(\cdot)$};
4276+
\node[](sigmoid) at (9.5,0)[]{\underline{sigmoid} $\sigma_3(\cdot)$};
41964277
%
41974278
\end{tikzpicture}
41984279
\end{center}
@@ -4246,95 +4327,6 @@ \subsection{Exercise 13}
42464327

42474328

42484329

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-
43384330
\subsection{Exercise 14}
43394331

43404332
\begin{frame}{Ex14: Multi-Class Classification with Softmax Output Layer}
@@ -4476,7 +4468,7 @@ \subsection{Exercise 14}
44764468

44774469
\againframe{MultiLabelClassification}
44784470
%
4479-
\begin{frame}{Multi-Class Classification with Hidden Layer Model}
4471+
\begin{frame}{Multi-Class Classification with Hidden Layer and Softmax Output Model}
44804472
%
44814473
\vspace{-0.25cm}
44824474
\begin{center}
@@ -4546,7 +4538,7 @@ \subsection{Exercise 14}
45464538
\end{bmatrix}
45474539
$};
45484540
%
4549-
\node[](sigmoid) at (9.5,0)[]{softmax $\sigma_3(\cdot)$};
4541+
\node[](sigmoid) at (9.5,0)[]{\underline{softmax} $\sigma_3(\cdot)$};
45504542
%
45514543
\end{tikzpicture}
45524544
\end{center}
@@ -4596,7 +4588,7 @@ \subsection{Exercise 14}
45964588

45974589

45984590

4599-
\begin{frame}{Softmax Activation Combined With Categorical Cross Entropy}
4591+
\begin{frame}{Softmax Activation Output Combined With Categorical Cross Entropy}
46004592

46014593
$\cdot$ $\hat{y}_{i=1 \dots K} \in\mathbb{R}$ model outputs with $K$ mutual exclusive classes
46024594

@@ -4629,7 +4621,7 @@ \subsection{Exercise 14}
46294621

46304622

46314623

4632-
\begin{frame}{Multi-Class Classification with Hidden Layer Model}
4624+
\begin{frame}{Multi-Class Classification with Hidden Layer and Softmax Output Model}
46334625
%
46344626
\vspace{-0.25cm}
46354627
\begin{center}
@@ -4699,7 +4691,7 @@ \subsection{Exercise 14}
46994691
\end{bmatrix}
47004692
$};
47014693
%
4702-
\node[](sigmoid) at (9.5,0)[]{softmax $\sigma_3(\cdot)$};
4694+
\node[](sigmoid) at (9.5,0)[]{\underline{softmax} $\sigma_3(\cdot)$};
47034695
%
47044696
\end{tikzpicture}
47054697
\end{center}
@@ -4851,7 +4843,7 @@ \subsection{Exercise 14}
48514843
\node[mtxo, align=center](predlbl) at (0,2){\textcolor{C0}{predicted} class};
48524844
%
48534845
\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};
48554847
\end{scope}
48564848
%
48574849
\end{tikzpicture}

0 commit comments

Comments
 (0)