\documentclass{beamer}
% \documentclass[handout]{beamer}

\usetheme{dcc}

\usepackage[utf8]{inputenc}
\usepackage[american]{babel}

\newcommand{\ie}{i.\,e.}
\newcommand{\Ie}{I.\,e.}
\newcommand{\eg}{e.\,g.}
\newcommand{\Eg}{E.\,g.}

\title{Mineração de Dados Aplicada}
\subtitle{Four ``Traditional'' Data Mining Tasks}

\author{Loïc Cerf}

\date{April 28th 2025}

\institute
{
  \scriptsize
  DCC -- ICEx -- UFMG\\
  \bigskip
  \includegraphics[width=.334113288\linewidth]{images/dcc}\hfill\includegraphics[width=.5\linewidth]{images/ufmg}
}

\subject{Four "Traditional" Data Mining Tasks}

\keywords{data mining, tasks, clustering, classification,
  dimensionality reduction, local patterns}

\hypersetup{pdfpagemode=FullScreen}

\AtBeginSection[]
{
  \begin{frame}<beamer>
    \frametitle{Outline}
    \tableofcontents[currentsection]
  \end{frame}
}

\begin{document}

\begin{frame}[plain]
  \titlepage
\end{frame}

\begin{frame}
  \frametitle{Outline for the next sessions}
  \begin{description}
  \item[Today] Four ``Traditional'' Data Mining Tasks;
  \item[30/04] Exam on the POSIX text-processing commands;
  \item[05/05] Similarities;
  \item[07/05] Clustering.
  \end{description}
\end{frame}

\begin{frame}
  \frametitle{Outline}
  \tableofcontents
\end{frame}

\begin{frame}
  \frametitle{The pattern discovery process}
    \begin{center}
      \begin{tabular}{ccccc}
        & \includegraphics[width=.075\textwidth]{img/gear} &
        &
        \only<1>{\includegraphics[width=.075\textwidth]{img/gear}}\only<2>{\includegraphics[width=.075\textwidth]{img/gear_alert}}
        & \\
        \includegraphics[width=.15\textwidth]{img/database}
        & \includegraphics[width=.15\textwidth]{img/pointer}
        & \includegraphics[width=.15\textwidth]{img/paper}
        & \includegraphics[width=.15\textwidth]{img/pointer}
        & \includegraphics[width=.15\textwidth]{img/database2}\\
        \includegraphics[width=.075\textwidth]{img/pointer_-135}
        & \includegraphics[width=.075\textwidth]{img/fellowship}
        & \includegraphics[width=.075\textwidth]{img/pointer_180}
        & \includegraphics[width=.075\textwidth]{img/fellowship}
        & \includegraphics[width=.075\textwidth]{img/pointer_135}\\
        Raw data & Pre-process & Data & Extraction & Patterns
      \end{tabular}
  \end{center}

  \vfill

  \begin{block}{\tiny \copyright 2005 Tim Morgan (from
      flickr$^{\text{\textregistered}}$)}
    \tiny \includegraphics[scale=.15]{img/licenses/cc-by}\hskip1pt
    These icons are licensed under the Creative Commons Attribution
    2.0 License.
  \end{block}
\end{frame}

\begin{frame}
  \frametitle{Classical data structure}
  Most datasets can be represented as tables that describe objects
  (the rows, whose order is meaningless) with attributes (the columns,
  whose order is meaningless):
  \begin{displaymath}
    \begin{array}{c|cccc}
      & a_1 & a_2 & \dots & a_n\\
      \hline
      o_1 & d_{1, 1} & d_{1, 2} & \dots & d_{1, n}\\
      o_2 & d_{2, 1} & d_{2, 2} & \dots & d_{2, n}\\
      \vdots & \vdots & \vdots & \ddots & \vdots\\
      o_m & d_{m, 1} & d_{m, 2} & \dots & d_{m, n}
    \end{array}
  \end{displaymath}

  \vfill

  $m$ is called size of the dataset; $n$ its dimensionality.
\end{frame}

\begin{frame}
  \frametitle{Outline}
  \tableofcontents
\end{frame}

\section{Clustering}

\begin{frame}
  \frametitle{Clustering}
  \begin{definition}
    Partitioning the objects into clusters so that each cluster
    contains \emph{similar} objects and objects in different clusters
    are \emph{dissimilar}.
  \end{definition}
  \vfill

  \only<1>
  {
    Input:\\
    \begin{displaymath}
      \begin{array}{c|cccc}
        & a_1 & a_2 & \dots & a_n\\
        \hline
        o_1 & d_{1, 1} & d_{1, 2} & \dots & d_{1, n}\\
        o_2 & d_{2, 1} & d_{2, 2} & \dots & d_{2, n}\\
        \vdots & \vdots & \vdots & \ddots & \vdots\\
        o_m & d_{m, 1} & d_{m, 2} & \dots & d_{m, n}
      \end{array}
    \end{displaymath}
  }\only<2>
  {
    Output:\\
    \begin{displaymath}
      \begin{array}{c|ccccc}
        & a_1 & a_2 & \dots & a_n & \alert{\text{cluster}}\\
        \hline
        o_1 & d_{1, 1} & d_{1, 2} & \dots & d_{1, n} & \alert{c_1}\\
        o_2 & d_{2, 1} & d_{2, 2} & \dots & d_{2, n} & \alert{c_2}\\
        \vdots & \vdots & \vdots & \ddots & \vdots & \vdots\\
        o_m & d_{m, 1} & d_{m, 2} & \dots & d_{m, n} & \alert{c_m}
      \end{array}
    \end{displaymath}
  }
\end{frame}

\begin{frame}
  \frametitle{Clustering: illustration}
  Clustering objects, described with two attributes of the interval
  type, using the Euclidean distance.
  \begin{columns}
    \begin{column}{.33\linewidth}
      \begin{displaymath}
        \begin{array}{c|cc}
          & x & y\\
          \hline
          \only<3->{\color{yellow}} o_1 & 91 & 70\\
          \only<3->{\color{yellow}} o_2 & 129 & 91\\
          \only<3->{\color{red}} o_3 & 359 & 243\\
          \only<3->{\color{red}} o_4 & 322 & 254\\
          \only<3->{\color{yellow}} o_5 & 100 & 104\\
          \only<3->{\color{blue}} o_6 & 464 & 113\\
          \only<3->{\color{red}} o_7 & 342 & 297\\
          \only<3->{\color{blue}} o_8 & 410 & 65\\
          \only<3->{\color{red}} o_9 & 334 & 329\\
          \vdots & \vdots & \vdots
        \end{array}
      \end{displaymath}
    \end{column}
    \begin{column}{.66\linewidth}
      \only<2>{\includegraphics[width=\linewidth]{img/clustering_small_bw}}\only<3>{\includegraphics[width=\linewidth]{img/clustering_small}}\only<4>{\includegraphics[width=\linewidth]{img/clustering}}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{Before clustering: selecting attributes}
  Using more than $\approx 10$ attributes leads to nothing because of
  the ``curse of dimensionality'' (when the dimensionality goes to
  infinity, the similarity between any two objects becomes the same).

  \vfill
  \pause

  Selecting highly correlated attributes is taking into account
  several times the same information.

  \vfill
  \pause

  Dimension reduction techniques may help.  If they create new
  attributes (\ie, unlike feature selection), the discovered
  clustering is harder to interpret.
\end{frame}

\begin{frame}
  \frametitle{Before clustering: scaling}
  When a similarity aggregates differences over attributes of the
  interval type, these attributes must first be \emph{scaled} so that
  they all equally contribute to the measure.

  \vfill
  \pause

  Multiplying a scaled attribute by a constant greater (resp. smaller)
  than 1 gives it more (resp. less) weight.
\end{frame}

\begin{frame}
  \frametitle{Supervised vs. unsupervised learning}
  Clustering aims to discover a \emph{hidden} organization of the
  objects: it is \emph{unsupervised}.

  \vfill
  \pause

  In contrast, \emph{supervised} learning aims to explain a
  \emph{given} organization of the objects (the ``ground truth'') from
  the other attributes.  Applying the learned function to an object
  described with those attributes predicts where it would fit in the
  organization.
\end{frame}

\section{Classifying}

\begin{frame}
  \frametitle{Learning a classifier}
  \begin{definition}
    Learning from a set of objects how to predict the value of
    a nominal attribute.
  \end{definition}

  \vfill

  \only<1>
  {
    Input:\\
    \begin{columns}
      \begin{column}{.5\linewidth}
        \begin{displaymath}
          \begin{array}{c|cccc}
            & a_1 & \dots & a_n & \alert{\text{class}}\\
            \hline
            o_1 & d_{1, 1} & \dots & d_{1, n} & \alert{c_1}\\
            o_2 & d_{2, 1} & \dots & d_{2, n} & \alert{c_2}\\
            \vdots & \vdots & \ddots & \vdots & \alert{\vdots}\\
            o_m & d_{m, 1} & \dots & d_{m, n} & \alert{c_m}
          \end{array}
        \end{displaymath}
      \end{column}
      \begin{column}{.5\linewidth}
        A parametric \emph{classification model}, that takes the
        values of the attributes $a_1$, \dots, $a_n$ at input and
        returns a value for the \emph{class}.
      \end{column}
    \end{columns}
  }\only<2->
  {
    Output:\\

    \vfill

    Estimates of the parameters of the classification model.  The
    classification model with its parameters substituted by their
    estimates is the \emph{classification function} aka
    \emph{classifier}.

    \vfill

    \uncover<3>{If the model is \emph{interpretable}, the classifier
      provides an understanding of the relationships between $a_1$,
      \dots, $a_n$ and the class, \ie, of how the attributes explain
      the class structure.}
  }
\end{frame}

\begin{frame}
  \frametitle{Making predictions}
  Applying a classifier to an object, with the value of the class
  missing, predicts it.

  \vfill

  \only<1>{In}\only<2>{Out}put:\\
  \begin{displaymath}
    \begin{array}{c|cccc}
      & a_1 & \dots & a_n & \alert<2>{\text{class}}\\
      \hline
      o_{m + 1} & d_{m + 1, 1} & \dots & d_{m + 1, n} &
      \uncover<2>{\alert{c_{m + 1}}}\\
      o_{m + 2} & d_{m + 2, 1} & \dots & d_{m + 2, n} &
      \uncover<2>{\alert{c_{m + 2}}}\\
      \vdots & \vdots & \ddots & \vdots &
      \uncover<2>{\alert{\vdots}}\\
      o_p & d_{p, 1} & \dots & d_{p, n} & \uncover<2>{\alert{c_p}}
    \end{array}
  \end{displaymath}
\end{frame}

\begin{frame}
  \frametitle{Classification: illustration}
  \only<-2>{Explain}\only<3>{Predict}ing the class of objects
  described with two attributes of the interval type.
  \begin{columns}
    \begin{column}{.33\linewidth}
      \only<1>
      {
        \begin{displaymath}
          \begin{array}{c|cc}
            & x & y\\
            \hline
            \color{yellow} o_1 & 147 & 155\\
            \color{yellow} o_2 & 176 & 145\\
            \color{red} o_3 & 301 & 326\\
            \color{red} o_4 & 372 & 270\\
            \color{yellow} o_5 & 129 & 274\\
            \color{blue} o_6 & 455 & 320\\
            \color{red} o_7 & 475 & 135\\
            \color{blue} o_8 & 395 & 95\\
            \color{red} o_9 & 343 & 65\\
            \vdots & \vdots & \vdots
          \end{array}
        \end{displaymath}
      }\only<2->
      {
        \begin{displaymath}
          \begin{array}{c|cc}
            & x & y\\
            \hline
            \only<3>{\color{yellow}} o_{10} & 150 & 66\\
            \only<3>{\color{yellow}} o_{11} & 154 & 105\\
            \only<3>{\color{blue}} o_{12} & 466 & 89\\
            \only<3>{\color{red}} o_{13} & 271 & 143\\
            \only<3>{\color{yellow}} o_{14} & 186 & 155\\
            \only<3>{\color{red}} o_{15} & 334 & 329\\
            \only<3>{\color{blue}} o_{16} & 464 & 113\\
            \only<3>{\color{blue}} o_{17} & 417 & 123\\
            \only<3>{\color{blue}} o_{18} & 439 & 67\\
            \vdots & \vdots & \vdots
          \end{array}
        \end{displaymath}
      }
    \end{column}
    \begin{column}{.66\linewidth}
      \only<1>{\includegraphics[width=\linewidth]{img/learning_data}}\only<2>{\includegraphics[width=\linewidth]{img/all_data}}\only<3>{\includegraphics[width=\linewidth]{img/classified_data}}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{Link with regression}
  Both regression and supervised classification aim to \emph{explain}
  one attribute from other attributes.

  \vfill
  \pause

  The explained attribute is of the interval type in the case of
  regression, \emph{nominal} in the case of classification.
\end{frame}

\begin{frame}
  \frametitle{Over-fitting and over-generalizing}
  More parameters in the classification model entail a better fit.
  However, having too many parameters may be bad: the classifier
  over-fits the data and its predictions are inaccurate.

  \vfill

  \begin{description}[<+->]
  \item[Over-fitting] Fitting too much the classified objects is
    learning the noise; the classifier poorly generalizes to new
    objects;
  \item[Over-generalizing] Not fitting enough the classified objects
    is missing important details.
  \end{description}
\end{frame}

\begin{frame}
  \frametitle{Over-fitting: illustration}
  \begin{center}
    \only<1>{\includegraphics[width=.5\linewidth]{img/overfitting1}}\only<2>{\includegraphics[width=.5\linewidth]{img/overfitting2}}\only<3>{\includegraphics[width=.5\linewidth]{img/overfitting3}}
  \end{center}

  \vfill

  \begin{block}{\tiny \copyright 2008 Chabacano (from
      Wikimedia Commons)}
    \tiny \includegraphics[scale=.15]{img/licenses/cc-by-sa}\hskip1pt
    This diagram is licensed under the Creative Commons
    Attribution-Share Alike 4.0 International License.
  \end{block}
\end{frame}

\begin{frame}
  \frametitle{Global vs. local patterns}
  Estimating the parameters of a clustering or a classification model
  is \emph{globally} modeling the data.  Since every object influences
  the output, the optimal estimates are usually unreachable within a
  reasonable time and those problems are \emph{inexactly} solved.

  \vfill
  \pause

  In contrast, \emph{local} patterns deal with parts of the data.
  Often, the subdatasets satisfying a given definition can be
  \emph{completely} listed.
\end{frame}

\section{Frequent itemset mining}

\begin{frame}
  \frametitle{Frequent itemset mining}
  \begin{definition}
    Given objects described with Boolean attributes, listing the
    subsets of attributes whose values are all ``true'' for many
    objects.
  \end{definition}

  \vfill

  \only<1>
  {
    Input:\\
    \begin{columns}
      \begin{column}{.5\linewidth}
        \begin{displaymath}
          \begin{array}{c|cccc}
            & a_1 & a_2 & \dots & a_n\\
            \hline
            o_1 & d_{1, 1} & d_{1, 2} & \dots & d_{1, n}\\
            o_2 & d_{2, 1} & d_{2, 2} & \dots & d_{2, n}\\
            \vdots & \vdots & \vdots & \ddots & \vdots\\
            o_m & d_{m, 1} & d_{m, 2} & \dots & d_{m, n}
          \end{array}
        \end{displaymath}
        where every $d_{i, j} \in \{$true$, $false$\}$
      \end{column}
      \begin{column}{.5\linewidth}
        and a frequency threshold $\mu \in \mathbb{N}$.
      \end{column}
    \end{columns}
  }\only<2>
  {
    Output: \emph{every} $X \subseteq \{a_1, a_2, \dots, a_n\}$ such
    that at least $\mu$ objects have ``true'' values for all
    attributes in $X$.
  }
\end{frame}

\begin{frame}
  \frametitle{Frequent itemset mining: illustration}
  Specifying a minimal frequency $\mu = 2$.

  \vfill

  \begin{columns}
    \begin{column}{.33\linewidth}
      \begin{displaymath}
        \begin{array}{c|ccc}
          & a_1 & a_2 & a_3\\
          \hline
          o_1 & \times & \times & \times\\
          o_2 & \times & \times & \\
          o_3 & & \times & \\
          o_4 & & & \times
        \end{array}
      \end{displaymath}
    \end{column}
    \begin{column}{.66\linewidth}
      \only<2>
      {
        The frequent itemsets are: $\emptyset$ (4), $\{a_1\}$
        (2), $\{a_2\}$ (3), $\{a_3\}$ (2) and $\{a_1, a_2\}$ (2).
      }
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{Link with correlation}
  A frequent itemset reveals some kind of correlation between
  \emph{all} its Boolean attributes.

  \vfill
  \pause

  Divided by the size of the dataset, the frequency of an itemset is
  the joint probability of its attributes being ``true''.  Other
  measures, such as the \emph{lift}, are closer to a correlation.
\end{frame}

\section{Dimensionality reduction}

\begin{frame}
  \frametitle{Dimensionality reduction}
  \begin{definition}
    Reducing objects described with many attributes to objects
    described with fewer attributes.
  \end{definition}

  \vfill

  \only<1>
  {
    Input:\\
    \begin{columns}
      \begin{column}{.5\linewidth}
        \begin{displaymath}
          \begin{array}{c|cccc}
            & a_1 & a_2 & \dots & a_n\\
            \hline
            o_1 & d_{1, 1} & d_{1, 2} & \dots & d_{1, n}\\
            o_2 & d_{2, 1} & d_{2, 2} & \dots & d_{2, n}\\
            \vdots & \vdots & \vdots & \ddots & \vdots\\
            o_m & d_{m, 1} & d_{m, 2} & \dots & d_{m, n}
          \end{array}
        \end{displaymath}
      \end{column}
      \begin{column}{.5\linewidth}
        and a number of attributes.
      \end{column}
    \end{columns}
  }\only<2->
  {
    Output:\\
    \begin{columns}
      \begin{column}{.33\linewidth}
        \begin{displaymath}
          \begin{array}{c|cc}
            & b_1 & b_2\\
            \hline
            o_1 & e_{1, 1} & e_{1, 2}\\
            o_2 & e_{2, 1} & e_{2, 2}\\
            \vdots & \vdots & \vdots\\
            o_m & e_{m, 1} & e_{m, 2}
          \end{array}
        \end{displaymath}
      \end{column}
      \begin{column}{.66\linewidth}
        \begin{center}
          \uncover<3>{\includegraphics[width=.5\linewidth]{img/clustering_bw}}
        \end{center}
      \end{column}
    \end{columns}
  }
\end{frame}

\begin{frame}
  \frametitle{Information loss}
  \begin{center}
    \only<1>{\includegraphics[scale=.4]{img/projection}}\only<2>{\includegraphics[scale=.4]{img/original}}
  \end{center}
\end{frame}

\begin{frame}
  \frametitle{Various techniques}
  \begin{description}[<+->]
  \item[Feature selection] Selecting the most relevant attributes.
  \item[Feature extraction] Constructing more relevant attributes as
    combinations of the original attributes.
  \item[Multidimensional scaling] Feature extraction, preserving, as
    much as possible, the distances between the objects.
  \end{description}

  \vfill

  \uncover<4>{Multidimensional scaling only makes sense if the
    original attributes are not too numerous (curse of
    dimensionality).}
\end{frame}

\begin{frame}
  \frametitle{Various uses}
  Processing a dataset with a reduced dimensionality is faster.

  \vfill
  \pause

  Multidimensional scaling is often used to then visualize the
  (approximate) distances between the objects in a scatter plot.

  \vfill
  \pause

  Feature selection/extraction can be supervised: the output
  attributes are good to predict a class or a dependent attribute.

  \vfill
  \pause

  Feature selection/extraction can be unsupervised: the output
  attributes, ordered by decreasing variance, show little or even no
  correlation, to discover complementary (combinations of) attributes
  whose values are much dispersed.  The curse of dimensionality is
  alleviated.
\end{frame}

\section{About the exam}

\begin{frame}
  \frametitle{Exam on text processing commands}
  \begin{itemize}[<+->]
  \item 20 points;
  \item A new dataset;
  \item Exercises that are similar to those in the slides;
  \item No focus on performance but some questions specifically ask
    not to use \texttt{sed} or \texttt{awk};
  \item One-point penalty for using \texttt{cat file |}, \texttt{shuf
      | head}, \texttt{sort | uniq} or \texttt{grep regexp | wc -l};
  \item Use of the computers in this room;
  \item No communication, hence no Internet connection...
  \item ... but any material is allowed: the slides, Web pages, books,
    etc..
  \end{itemize}
\end{frame}

\section*{}

\begin{frame}
  \frametitle{License}
  \begin{block}{\copyright 2012--2025 Loïc Cerf}
    \includegraphics[height=1.5ex]{img/licenses/cc-by-sa}\hskip1pt
    These slides are licensed under the Creative Commons
    Attribution-ShareAlike 4.0 International License.
  \end{block}
\end{frame}

\end{document}