/
04-02-ACA-Inference-RegressionClustering.tex
218 lines (204 loc) · 10.5 KB
/
04-02-ACA-Inference-RegressionClustering.tex
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
% move all configuration stuff into includes file so we can focus on the content
\input{include}
\subtitle{module 4.2: regression \& clustering}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
% generate title page
\input{include/titlepage}
\section[overview]{lecture overview}
\begin{frame}{introduction}{overview}
\begin{block}{corresponding textbook section}
%\href{http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6331125}{Chapter 8: Musical Genre, Similarity, and Mood} (pp.~155)
sections~4.2 -- 4.4
\end{block}
\begin{itemize}
\item \textbf{lecture content}
\begin{itemize}
\item regression: non-categorical data analysis
\item clustering: unsupervised data analysis
\end{itemize}
\bigskip
\item<2-> \textbf{learning objectives}
\begin{itemize}
\item describe the basic principles of data-driven machine learning approaches
\item implement linear regression in Python
\item implement kMeans clustering in Python
\end{itemize}
\end{itemize}
\inserticon{directions}
\end{frame}
\section[intro]{introduction}
\begin{frame}{regression}{introduction}
remember the flow chart of a general ACA system:
\vspace{-3mm}
\begin{figure}
\input{pict/introduction_ACASystem_3}
\end{figure}
\begin{itemize}
\item<2-> \textit{classification}:
\begin{itemize}
\item assign class labels to data
\end{itemize}
\item<2-> \color<3->{highlight}{\textit{regression}}:
\begin{itemize}
\item estimate numerical labels for data
\end{itemize}
\item<2-> \color<3->{highlight}{\textit{clustering}}:
\begin{itemize}
\item find grouping patterns in data
\end{itemize}
\end{itemize}
\end{frame}
\section{regression}
\begin{frame}{regression}{introduction}
\vspace{-3mm}
\begin{itemize}
\item given a set of pairs of data and corresponding output observations
\item find model that maps input to output
\bigskip
\item<2-> model can then be used to predict (continuous value) output for an unknown new input
\end{itemize}
\end{frame}
\begin{frame}{regression}{linear regression}
\vspace{-3mm}
\begin{columns}
\column{.4\linewidth}
\begin{itemize}
\item estimate the slope $m$ and offset $b$ of a straight line that fits the data best:
\begin{footnotesize}
\begin{equation*}
\hat{y}(r) = m\cdot v(r) + b
\end{equation*}
\end{footnotesize}
\bigskip
\item minimizing the mean squared error leads to:
\begin{footnotesize}
\begin{eqnarray*}
b &=& \mu_y - m\cdot \mu_v \\
m &=& \frac{\sum\limits_{r=0}^{\mathcal{R}-1}\left(y(r)- \mu_y\right)\cdot \left(v(r) - \mu_v\right)}{\sum\limits_{r=0}^{\mathcal{R}-1}\left(v(r) - \mu_v\right)^2}
\end{eqnarray*}
\end{footnotesize}
\end{itemize}
\column{.6\linewidth}
\vspace{-10mm}
\figwithmatlab{LinearRegression}
\end{columns}
\end{frame}
\section{clustering}
\begin{frame}{clustering}{introduction}
\begin{itemize}
\item clustering is usually unsupervised and exploratory
\item group observations
\begin{itemize}
\item 'similar' observations are grouped together
\item 'dissimilar' observations are in different groups
\end{itemize}
\item depends on definition of 'similarity'/ distance
\end{itemize}
\begin{figure}%
\centering
\input{pict/inference_clustering_example}
\end{figure}
\end{frame}
\begin{frame}{clustering}{kMeans clustering}
\only<1>{
\vspace{-5mm}
\begin{columns}
\column{.33\linewidth}
\begin{enumerate}
\item \emph{Initialization}: randomly select $K$ observations from the data set as initialization.
\item \emph{Update}: compute the mean for each cluster.
\item \emph{Assignment}: assign each observation to the cluster with the mean of the closest cluster.
\item \emph{Iteration}: go to step $2$ until the clusters converge.
\end{enumerate}
\column{.67\linewidth}
%\vspace{-10mm}
\includeanimation
{Kmeans}
{00}
{04}
{.5}
%
\end{columns}
}
\only<2>{\figwithmatlab{Kmeans}}
\end{frame}
\section{distances}
\begin{frame}{distances}{overview }
\vspace{-5mm}
\begin{columns}
\column{.5\linewidth}
\begin{itemize}
\item<1-> \emph{\only<1>{\textcolor{blue}}{Euclidean Distance}} (L2 Distance)
\smallskip
\item<2-> \emph{\only<2>{\textcolor{blue}}{Manhattan Distance}} (L1 Distance)
\smallskip
\item<3-> \emph{\only<3>{\textcolor{blue}}{Cosine Similarity/Distance}}
\begin{itemize}
\item range is from $[-1;1]$ ($[0;1]$ for non-negative input),
\item not distance but similarity measure
\item independent of vector length, only on angle
\end{itemize}
\smallskip
\item<4-> \emph{\only<4>{\textcolor{blue}}{Kullback-Leibler Divergence}}
\begin{itemize}
\item not symmetric: $d_\mathrm{KL}(\vec{v}_\mathrm{a},\vec{v}_\mathrm{b})\neq d_\mathrm{KL}(\vec{v}_\mathrm{b},\vec{v}_\mathrm{a})$,
\item designed to measure distance between probability distributions
\end{itemize}
\end{itemize}
\column{.5\linewidth}
\only<1>{
\begin{footnotesize}\begin{equation*}\label{eq:dist_eucl}
d_\mathrm{EU}(\vec{v}_\mathrm{a},\vec{v}_\mathrm{b}) = \left\|\vec{v}_\mathrm{a}-\vec{v}_\mathrm{b}\right\|_2 = \sqrt{\sum\limits_{j = 0}^{\mathcal{J}-1}{\big(v_\mathrm{a}(j)-v_\mathrm{b}(j)\big)^2}} .
\end{equation*}\end{footnotesize}
}
\only<2>{
\begin{footnotesize}\begin{equation*}\label{eq:dist_manh}
d_\mathrm{M}(\vec{v}_\mathrm{a},\vec{v}_\mathrm{b}) = \left\|\vec{v}_\mathrm{a}-\vec{v}_\mathrm{b}\right\|_1 = \sum\limits_{j = 0}^{\mathcal{J}-1}{\big|v_\mathrm{a}(j)-v_\mathrm{b}(j)\big|} .
\end{equation*}\end{footnotesize}
}
\only<3>{
\begin{footnotesize}\begin{equation*}\label{eq:dist_cos}
s_\mathrm{C}(\vec{v}_\mathrm{a},\vec{v}_\mathrm{b}) = \frac{\sum\limits_{j = 0}^{\mathcal{J}-1}{v_\mathrm{a}(j)\cdot v_\mathrm{b}(j)}}{\sqrt{\sum\limits_{j = 0}^{\mathcal{J}-1}{v_\mathrm{a}(j)^2}}\cdot\sqrt{ \sum\limits_{j = 0}^{\mathcal{J}-1}{v_\mathrm{b}(j)^2}}} .
\end{equation*}\end{footnotesize}
\begin{footnotesize}\begin{equation*}
d_\mathrm{C}(\vec{v}_\mathrm{a},\vec{v}_\mathrm{b}) = 1-s_\mathrm{C}(\vec{v}_\mathrm{a},\vec{v}_\mathrm{b}) .
\end{equation*}\end{footnotesize}
}
\only<4>{
\begin{footnotesize}\begin{equation*}\label{eq:dist_kl}
d_\mathrm{KL}(\vec{v}_\mathrm{a},\vec{v}_\mathrm{b}) = \sum\limits_{j = 0}^{\mathcal{J}-1}{v_\mathrm{a}(j)\cdot\log\left(\frac{v_\mathrm{a}(j)}{v_\mathrm{b}(j)}\right)} . %-v_\mathrm{a}(j)+v_\mathrm{b}(j)
\end{equation*}\end{footnotesize}
}
\end{columns}
\end{frame}
\section{summary}
\begin{frame}{summary}{lecture content}
\begin{itemize}
\item \textbf{regression}
\begin{itemize}
\item model to estimate numeric labels from features
\item linear regression assumes model is straight line
\end{itemize}
\bigskip
\item \textbf{clustering}
\begin{enumerate}
\item unsupervised grouping
\item feature space and distance measure determine result
\item number of clusters usually has to be known
\item kMeans is simple way of clustering
\end{enumerate}
\bigskip
\item \textbf{distances}
\begin{itemize}
\item L1 and L2 are most common distances
\item not all 'distances' are consistent. a real distance
\begin{itemize}
\item cannot be negative
\item is symmetric
\end{itemize}
\end{itemize}
\end{itemize}
\inserticon{summary}
\end{frame}
\end{document}