\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{Association Rule Mining}

\author{Loïc Cerf}

\date{May 26th 2025}

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

\subject{Association Rule Mining}

\keywords{association rule, frequency, confidence, binarization}

\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}
  \tableofcontents
\end{frame}

\section{Turning an attribute Boolean}

\begin{frame}
  \frametitle{From Boolean to Boolean}
  Being in the support of an itemset is ``having true values for all
  its attributes'', a conjunction of satisfied properties.

  \vfill

  Negations of some Boolean attributes, disjunctions between some of
  them, etc. may be relevant too.  The KNIME node ``Set Operator''
  performs such operations.
\end{frame}

\begin{frame}
  \frametitle{From nominal to Boolean}
  A nominal attribute with $c \in \mathbb{N}$ categories can be turned
  into $c$ Boolean attributes ``being in the category''. The KNIME
  node ``One to Many'' does that.

  \vfill
  \pause

  The categories being exclusive, there cannot be more than one
  category per itemset.
\end{frame}

\begin{frame}
  \frametitle{From ordinal to Boolean}
  Partitioning the range of an ordinal attribute (numeric or not) into
  $c \in \mathbb{N}$ intervals turns the attribute nominal.  It can
  then be turned into $c$ Boolean attributes. The KNIME node ``Numeric
  Binner'' defines the partitioning.

  \vfill
  \pause

  When $c = 2$, those categories are ``being below/above a chosen
  threshold $\alpha$'', \ie, an \emph{Heaviside step function} is
  used:
  \begin{displaymath}
    H_{\alpha}: x \mapsto \begin{cases}
      0\text{ if }x < \alpha\\
      1\text{ if }x \geq \alpha
    \end{cases} \enspace .
  \end{displaymath}

  \vfill
  \pause

  $\alpha$ may differ from an object to another (per-object
  normalization).
\end{frame}

\begin{frame}
  \frametitle{Discretization: plot}
  \begin{center}
    \includegraphics[width=.67\linewidth]{img/heaviside}
  \end{center}

  \vfill

  $\alpha$ is the boundary between the two categories.
\end{frame}

\begin{frame}
  \frametitle{Discretization: information loss}
  Discretizing is losing information: the values in a same interval
  are mapped to the same category and become indistinguishable.

  \vfill
  \pause

  A real necessity \emph{must} justify a discretization.  Mining
  itemsets is a valid justification.
\end{frame}

\begin{frame}
  \frametitle{From interval-scaled to fuzzy}
  To not lose information, a bijection is needed.  It gives a degree
  of membership, in $[0, 1]$, to the category instead of a crisp
  membership, in $\{0, 1\}$.  A few algorithms (\eg,
  \texttt{multidupehack}) mine itemset-like patterns in fuzzy data.

  \vfill
  \pause

  \emph{Sigmoid functions} generalize Heaviside step functions:
  \begin{displaymath}
    P_{\alpha, k}: x \mapsto \frac{1}{1 + e^{k(\alpha - x)}} \enspace .
  \end{displaymath}
\end{frame}

\begin{frame}
  \frametitle{Sigmoid curve}
  \begin{center}
    \includegraphics[width=.67\linewidth]{img/logistic}
  \end{center}

  \vfill

  In addition to a boundary $\alpha$ (mapped to $0.5$), a ``growth
  rate'' $k$ defines how sharp the transition between the two
  categories.
\end{frame}

\section{Association rule mining}

\begin{frame}
  \frametitle{Association rule: definition}
  \begin{definition}
    Given a set of Boolean attributes $\mathcal{A}$, an
    \emph{association rule} is an ordered pair of itemsets
    $(X, Y) \in 2^{\mathcal{A}} \times 2^{\mathcal{A}}$\only<2>{
      \alert{such that $X \cap Y = \emptyset$}}.
  \end{definition}

  \vfill
  \uncover<3>{The association rule $(X, Y) \in 2^{\mathcal{A}} \times
    2^{\mathcal{A}}$ is usually denoted $X \rightarrow Y$.}
\end{frame}

\begin{frame}
  \frametitle{Frequency and confidence: definitions}
  Let $\mathcal{D}$, a set of objects $\mathcal{O}$ described with
  Boolean attributes in $\mathcal{A}$, and
  $(X, Y) \in 2^{\mathcal{A}} \times 2^{\mathcal{A}}$.

  \vfill

  \begin{block}{Frequency}
    The \emph{frequency} of $X \rightarrow Y$ in $\mathcal{D}$ is
    \only<1>{the frequency of $X \cup Y$ in
      $\mathcal{D}$}\only<2->{\alert<2>{$f(X \cup Y, \mathcal{D})$}}.
  \end{block}

  \vfill
  \uncover<3->
  {
    \begin{block}{Confidence}
      The \emph{confidence} of $X \rightarrow Y$ in $\mathcal{D}$ is
      $\frac{f(X \cup Y, \mathcal{D})}{f(X, \mathcal{D})}$.
    \end{block}
  }\uncover<4>{The confidence of the association rule $X \rightarrow
    Y$ is the estimated conditional probability of having all
    attributes in $Y$ given that the object has all attributes in
    $X$.}
\end{frame}

\begin{frame}
  \frametitle{Association rule mining}
  \begin{definition}
    Given $\mathcal{D}$, a set of objects described with Boolean
    attributes in $\mathcal{A}$, $\mu \in \mathbb{N}$ and $\nu \in [0,
    1]$, listing every association rule whose frequency is at least
    $\mu$ and whose confidence is at least $\nu$.
  \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 minimal frequency $\mu \in \mathbb{N}$, a minimal
        confidence $\nu \in [0, 1]$.
      \end{column}
    \end{columns}
  }\only<2->
  {
    Output: \emph{every} $(X, Y) \in 2^{\mathcal{A}} \times
    2^{\mathcal{A}}$ such that:
    \begin{itemize}
    \item $X \cap Y = \emptyset$;
    \item at least $\mu$ objects have ``true'' values for all
      attributes in $X \cup Y$;
    \item at most $\frac{1}{\nu}$ times more objects have ``true''
      values for all attributes in $X$.
    \end{itemize}
  }
\end{frame}

\begin{frame}
  \frametitle{Association rule mining: illustration}
  Let $2$ the minimal absolute frequency or, equivalently, 50\% the
  minimal relative frequency, and $\frac{2}{3}$ the minimal
  confidence.

  \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}
      The association rules are:
      \begin{itemize}
      \item<2-> the frequent itemsets implying the empty set:
        $\emptyset \rightarrow \emptyset$ (4, 1), $\{a_1\} \rightarrow
        \emptyset$ (2, 1), $\{a_2\} \rightarrow \emptyset$ (3, 1),
        $\{a_3\} \rightarrow \emptyset$ (2, 1) and $\{a_1, a_2\}
        \rightarrow \emptyset$ (2, 1);
      \item<3> but also \uncover<3>{$\emptyset \rightarrow \{a_2\}$
          (3, 3/4), $\{a_1\} \rightarrow \{a_2\}$ (2, 1) and $\{a_2\}
          \rightarrow \{a_1\}$ (2, 2/3).}
      \end{itemize}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{Lift}
  The \emph{lift} quantifies how expected (lift close to $1$) or
  unexpected (lift significantly different from $1$) the frequency of
  an association rule $X \rightarrow Y$ given the frequencies of $X$
  and $Y$. It is the ratio between the relative frequency of the
  association rule and its expected relative frequency under the
  assumption that the events ``having all attributes in $X$'' and
  ``having all attributes in $Y$'' are independent.

  \vfill
  \pause

  \begin{block}{Definition}
    Given $\mathcal{D}$, a set of objects $\mathcal{O}$ described with
    Boolean attributes, the \emph{lift} of an association rule
    $X \rightarrow Y$ in $\mathcal{D}$ is
    $\frac{|\mathcal{O}|f(X \cup Y, \mathcal{D})}{f(X, \mathcal{D})
      f(Y, \mathcal{D})}$.
  \end{block}

  \vfill
  \pause

  \emph{Frequent} association rule mining can only discover
  association rules with high lifts indicating
  \emph{positively}-correlated itemsets.
\end{frame}

\begin{frame}
  \frametitle{Lift: illustration}
  Specifying a minimal absolute frequency $\mu = 2$ objects (or,
  equivalently, a minimal relative frequency of 50\%) and a minimal
  confidence of $\nu = \frac{2}{3}$.

  \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}
      The lift of:
      \begin{itemize}
      \item $\emptyset \rightarrow \{a_2\}$ is\uncover<2->{ 1;}
      \item $\{a_1\} \rightarrow \{a_2\}$ is\uncover<3->{ 1.33;}
      \item $\{a_2\} \rightarrow \{a_1\}$ is\uncover<4->{ 1.33;}
      \item $X \rightarrow \emptyset$ is\uncover<5>{ 1.}
      \end{itemize}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{Support equivalence classes}
  \includegraphics[width=\linewidth]{img/equivalence}
\end{frame}

\begin{frame}
  \frametitle{Condensed representation}
  Given $\mathcal{D}$, a set of objects described with Boolean
  attributes, the frequent and confident association rule
  $X \rightarrow Y$ is among the most informative ones if and only if:
  \begin{itemize}[<+->]
  \item $X \cup Y$ is a closed itemset;
  \item $X$ is ``minimal'' (a \emph{free itemset}), \ie, $\forall X'
    \subset X$, $f(X', \mathcal{D}) \neq f(X, \mathcal{D})$.
  \end{itemize}

  \vfill

  \uncover<3>{The association rules satisfying those additional
    constraints are a condensed representation of all association
    rules with their frequencies, their confidences, and any other
    measures that solely depend on $f(X, \mathcal{D})$ and
    $f(X \cup Y, \mathcal{D})$.}
\end{frame}

\begin{frame}
  \frametitle{From local patterns to global models}
  Local patterns, seen as an intermediary representation of the data,
  can be post-processed to learn a clustering or a classifier.

  \vfill
  \pause

  In particular, associative classifiers are sets of
  \emph{classification rules}, \ie, association rules concluding on
  ``being in a class''. They are easy to interpret. The selected rules
  must discriminate a class (tens of measures exist, including the
  confidence) and their supports should involve every object about the
  same number of times.
\end{frame}

\section{Mining itemsets with or without KNIME}

\begin{frame}
  \frametitle{Mining association rules in KNIME}
  The KNIME node ``Association Rule Learner'' mines frequent
  (maximal/closed) itemsets or association rules with single-attribute
  consequents. It processes a \emph{Collection} or a \emph{Bit
    Vector}, a column that the node ``Create Collection Column'' or
  ``Create Bit Vector'' creates, from attributes of any type.  If
  numeric, ``Create Bit Vector'' can encode the attribute ``being
  above a threshold''.

  \vfill
  \pause

  The node ``Subset Matcher'' computes (noise-tolerant) supports.

  \vfill
  \pause

  In KNIME or any other graphical platform, local pattern mining is
  limited and cumbersome. In particular, it is hard to post-process
  the patterns.
\end{frame}

\begin{frame}
  \frametitle{Mining itemsets with command lines}
  \begin{block}{\texttt{LCM}}
    Often considered the most efficient (maximal/closed) frequent
    itemset miner.
  \end{block}

  \vfill
  \pause

  \begin{block}{\texttt{d-peeler}}
    Constrained (using minimal sizes or a minimal area, clique mining,
    almost-contiguity, group cover, etc.) \emph{closed} pattern mining
    in Boolean tensors (\ie, $n$-ary relations).
  \end{block}

  \vfill
  \pause

  \begin{block}{\texttt{multidupehack}}
    Constrained (as above) \emph{noise-tolerant} (closed) pattern
    mining in fuzzy tensors.
  \end{block}
\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}