\section{Clustering}

\begin{frame}{Clustering algorithm}
    \centering
    \vspace{0.25\baselineskip}
    \begin{tikzpicture}[scale=0.85]
        \input{tikz/clustering.tex}
    \end{tikzpicture}
    \[
        D_{\mathcal{M}}(m,m') = \sum_{q = 1}^{Q_1} \sum_{r = 1}^{Q_2} \max(\widetilde{\pi}_{q}^{m}, \widetilde{\pi}_{q}^{m'}) \left( \widetilde{\alpha}_{qr}^{m} - \widetilde{\alpha}_{qr}^{m'}\right)^{2} \max(\widetilde{\rho}_{r}^{m}, \widetilde{\rho}_{r}^{m'})
    \]
\end{frame}

\section{VEM}

\begin{frame}{Developed formula of variational EM}
    \begin{multline*}
        \ell (\bm{Y};\theta) \geq \color{red}\sum_{m=1}^{M} \bigg( \color{black} \sum_{i = 1}^{n_1^m}\sum_{j=1}^{n_2^m}\sum_{q \in \mathcal{Q}_{1,m}} \sum_{r \in \mathcal{Q}_{2,m}} \tau^{1,m}_{i,q} \tau^{2,m}_{j,r} \log f(Y^{m}_{ij}; \alpha_{qr}) \\
        + \sum_{i=1}^{n_1^m} \sum_{q \in \mathcal{Q}_{1,m}} \tau^{1,m}_{i,q} \log \pi_{\color{black}q}^{\color{gray}m} + \sum_{j=1}^{n_2^m} \sum_{r \in \mathcal{Q}_{2,m}} \tau^{2,m}_{j,r} \log \rho_{\color{black}r}^{\color{gray}m} \\
        - \sum_{i=1}^{n_1} \tau^{1,m}_{i,q} \log \tau^{1,m}_{i,q} - \sum_{j=1}^{n_2} \tau^{2,m}_{j,r} \log \tau^{2,m}_{j,r} \color{red}\bigg) \color{black} \eqcolon
        \mathcal{J}(\tau;\theta),
    \end{multline*}

    \begin{block}{Variational approximation}
        $\tau_{iq}^{1,m} = \mathcal{R}^1_{Y^m,\tau}(Z_{iq}^m = 1)$
        and $\tau_{jr}^{2,m} = \mathcal{R}^2_{Y^m,\tau}(W_{jr}^m = 1)$
    \end{block}
\end{frame}

\begin{frame}{\emph{Variational Expectation} Step}
    \[
        \widehat{\tau}^{(t+1)} = \arg \max_{\tau}
        \mathcal{J}(\mathcal{\tau},\bm{\widehat{\theta}}^{(t)})
        \Leftrightarrow \arg\min_{\tau\in\mathcal{T}} \mathbf{KL}[\mathcal{R}_{\mathbf{Y},\tau}, \mathbb{P}(.|\mathbf{Y})]
    \]

    \begin{equation*}
        \begin{cases}
            \widehat{\tau}_{iq}^{1,m} \propto \widehat{\pi}_{q}^{m(t)} \prod_{j=1}^{n_2^m}\prod_{r\in\mathcal{Q}_2^m} f(Y_{ij}^m;\widehat{\alpha}_{qr}^{(t)})^{\widehat{\tau}_{jr}^{2,m(t+1)}}  & \forall i = 1, \dots , n_1^m, q \in \mathcal{Q}_1^m \\
            \widehat{\tau}_{jr}^{2,m} \propto \widehat{\rho}_{r}^{m(t)} \prod_{i=1}^{n_1^m}\prod_{q\in\mathcal{Q}_1^m} f(Y_{ij}^m;\widehat{\alpha}_{qr}^{(t)})^{\widehat{\tau}_{iq}^{1,m(t+1)}} & \forall j = 1, \dots , n_2^m, r \in \mathcal{Q}_2^m
        \end{cases}
    \end{equation*}
    \footnotetext[2]{Initialization of $\widehat{\tau}$ with a
        \emph{spectral clustering} on the networks.}
\end{frame}

\begin{frame}{\emph{Maximization} Step}
    \[
        \widehat{\theta}^{(t+1)} = \arg \max_{\theta} \mathcal{J}(\mathcal{\bm{\widehat{\tau}}}^{(t+1)},\theta)
    \]

    \begin{block}{Connectivity parameters}
        \begin{align*}
            \widehat{\alpha}_{qr} = \frac{\sum_{m=1}^{M} \sum_{i=1}^{n_1^m} \sum_{j=1}^{n_2^m} \tau_{iq}^{1,m} \tau_{jr}^{2,m} \alert<2>{Y_{ij}^m}}{\sum_{m=1}^{M} \sum_{i=1}^{n_1^m} \sum_{j=1}^{n_2^m} \tau_{iq}^{1,m} \tau_{jr}^{2,m}}
        \end{align*}
    \end{block}
    \only<1>{
        \begin{block}{Proportions for \emph{iid}}
            \begin{align*}
                \widehat{\pi}_q = \frac{\sum_{m=1}^{M} \sum_{i=1}^{n_1^m} \tau_{iq}^{1,m}}{\sum_{m=1}^{M} n_1^m} &  &
                \widehat{\rho}_r = \frac{\sum_{m=1}^{M} \sum_{j=1}^{n_2^m} \tau_{jr}^{2,m}}{\sum_{m=1}^{M} n_2^m}
            \end{align*}
        \end{block}
    }
    \only<2>{
        \begin{block}{Proportions for $\pi\rho$}
            \begin{align*}
                \widehat{\pi}^{\color{red}m}_q = \frac{\sum_{i=1}^{n_1^m} \tau_{iq}^{1,m}}{n_1^m} &  &
                \widehat{\rho}^{\color{red}m}_r = \frac{\sum_{j=1}^{n_2^m} \tau_{jr}^{2,m}}{n_2^m}
            \end{align*}
        \end{block}
    }

\end{frame}

\begin{frame}
    \frametitle{Why does VE minimizes KL ?}
    \begin{align*}
        \ell_c(\bY,\bZ,\bW;\theta)                               & = \log \Prob(\bZ, \bW|\bY;\theta) + \ell(\bY;\theta)                                    \\
        \Leftrightarrow            \ell(\bY;\theta)              & = \ell_c(\bY,\bZ,\bW;\theta) - \log \Prob(\bZ, \bW|\bY;\theta)                          \\
        \Leftrightarrow            \Esp_{\Ryt}[\ell(\bY;\theta)] & = \Esp_{\Ryt}[\ell_c(\bY,\bZ,\bW;\theta)] - \Esp_{\Ryt}[\log \Prob(\bZ,\bW|\bY;\theta)] \\
        \Leftrightarrow            \ell(\bY;\theta)              & = \Esp_{\Ryt}[\ell_c(\bY,\bZ,\bW;\theta)] - \Esp_{\Ryt}[\log \Prob(\bZ,\bW|\bY;\theta)] \\
    \end{align*}
    \begin{align*}
        \text{But }\KL{\Ryt}{\log \Prob(\bZ,\bW|\bY;\theta)}                        & = - \Esp_{\Ryt} [\log \frac{\Prob(\bZ,\bW|\bY;\theta)}{\Ryt}] \\
        = - \Esp_{\Ryt} [\log \Prob(\bZ,\bW|\bY;\theta)] +                          & \underbrace{\Esp_{\Ryt[\log \Ryt]}}_{-\Hshannon(\Ryt)}        \\
        \Leftrightarrow \KL{\Ryt}{\log \Prob(\bZ,\bW|\bY;\theta)} + \Hshannon(\Ryt) & = - \Esp_{\Ryt} [\log \Prob(\bZ,\bW|\bY;\theta)]
    \end{align*}
    Thus $\ell(\bY;\theta) - \KL{\Ryt}{\log \Prob(\bZ,\bW|\bY;\theta)} = \mathcal{J}(\tau;\theta) \qed$
\end{frame}
\section{Model selection}

\begin{frame}
    \frametitle{On the BIC-L}
    % Raconter l'histoire dans l'ordre suivant :
    % \begin{itemize}
    %     \item ICL = Méthode BIC (approx Laplace) sur la log complète, fait apparaître la
    %           pénalité de complexité et pénalise l'entropie
    %     \item ICLv = ICL mais avec les paramètres variationnels et l'entropie variationnelle
    %     \item BIC-L = ICLv mais sans la pénalité sur l'entropie et la rajoutant à la fin
    % \end{itemize}
    \begin{align*}
        % \text{BIC}(\hat{\theta})               & = \log p(\mathbf{Y};\hat{\theta}) - \frac{1}{2} \text{pen}(\dots)                                                                                                                                                                                          \\
        %                                        & = \Esp_{\mathbf{Z}, \mathbf{W}|\mathbf{Y}} [\underbrace{\log p(\mathbf{Y},\mathbf{Z},\mathbf{W};\hat{\theta})}_{\ell_c(\mathbf{Y},\mathbf{Z},\mathbf{W};\hat{\theta})}] + \mathcal{H}(p(\mathbf{Z},\mathbf{W}|\mathbf{Y})) - \frac{1}{2} \text{pen}(\dots) \\
        \text{ICL}(\hat{\theta})                                                                                              & = \Esp_{\mathbf{Z}, \mathbf{W}|\mathbf{Y}} [\ell_c(\mathbf{Y},\mathbf{Z},\mathbf{W};\hat{\theta})] - \frac{1}{2} \text{pen}(\dots) \\
        \Esp_{\mathbf{Z},                       \mathbf{W}|\mathbf{Y}}[\ell_c(\mathbf{Y},\mathbf{Z},\mathbf{W};\hat{\theta})] & =  \log p(\mathbf{Y};\hat{\theta}) - \mathcal{H}(p(\mathbf{Z},\mathbf{W}|\mathbf{Y}))                                              \\
        \text{And thus,}~\text{ICL}(\hat{\theta})                                                                             & = \log p(\mathbf{Y};\hat{\theta}) - \mathcal{H}(p(\mathbf{Z},\mathbf{W}|\mathbf{Y})) - \frac{1}{2} \text{pen}(\dots)
    \end{align*}
    Recalling that $\mathbf{Z,W|Y}$ is inaccessible, we use the \emph{variational approximation} $\mathcal{R}_{\mathbf{Y},\hat{\tau}}$ and not penalizing the entropy of the distribution we derive the BIC-Like criterion:
    \[        \text{BIC-L}(\hat{\theta}, \hat{\tau})= \Esp_{\mathcal{R}_{\mathbf{Y}, \hat{\tau}}}[\ell_c(\mathbf{Y},\mathbf{Z},\mathbf{W};\hat{\theta}^{\text{var}})] + \mathcal{H}(\mathcal{R}_{\mathbf{Y}, \hat{\tau}}) - \frac{1}{2} \text{pen}(\dots)
    \]
\end{frame}

\begin{frame}
    \frametitle{Choice of $(Q_1,Q_2)$ - Greedy approach}
    \begin{columns}
        \begin{column}{0.5\linewidth}
            \begin{tikzpicture}
                \input{tikz/greedy-exploration.tex}
            \end{tikzpicture}
        \end{column}
        \begin{column}{0.35\linewidth}
            \begin{itemize}
                \item Initial model~: \\ \vspace{0.125\baselineskip}
                      \begin{tikzpicture}
                          \draw[fill=gray, draw=gray] circle [radius=0.225cm];
                      \end{tikzpicture}
                      \onslide<2->{
                \item Model after \emph{split}~:
                      \begin{tikzpicture}
                          \draw[fill=blueind, draw=blueind] circle [radius=0.225cm];
                      \end{tikzpicture}
                \item Model maximizing the criterion~:\\ \vspace{0.125\baselineskip}
                      \begin{tikzpicture}
                          \draw[fill=white, draw=green, very thick] circle [radius=0.225cm];
                      \end{tikzpicture}
                      }
                      \onslide<3->{
                \item Model after \emph{merge}~:
                      \begin{tikzpicture}
                          \draw[fill=red, draw=red] circle [radius=0.225cm];
                      \end{tikzpicture}
                      }
            \end{itemize}
        \end{column}
    \end{columns}
\end{frame}

\begin{frame}
    \frametitle{Choice of $(Q_1,Q_2)$ - Sliding window}
    \begin{columns}
        \begin{column}{0.6\textwidth}
            \begin{figure}
                \input{tikz/moving-window}
                \caption{Sliding window}
            \end{figure}
        \end{column}
        \begin{column}{0.4\textwidth}
            \only<3>{\begin{block}{}
                    Initialization of the model if necessary
                \end{block}}
            \only<9>{\begin{block}{}
                    Localization of the new mode
                \end{block}}
            \only<10>{\begin{block}{}
                    Move to the new mode then iterate
                \end{block}}
        \end{column}
    \end{columns}
\end{frame}