\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{float}
\usepackage{dsfont}
\usepackage{amsmath}
\usepackage{todonotes}
\input{math_commands.tex}

\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}


\algnewcommand\algorithmicforeach{\textbf{for each}}
\algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}

\makeatletter
\renewcommand{\ALG@beginalgorithmic}{\small}
\makeatother

\def\rvalpha{{\boldsymbol{\alpha}}}

\title{bolsonaro}
\date{September 2019}

\begin{document}

\maketitle

\section{Introduction}
introduire le pb et les motivation ...
\subsection{Notation}

Let $ \textbf{X} \in \mathbb{R}^{n \times d}$ \todo{est-ce-que le non-gras majuscule est fréquent pour les matrices?} be the matrix data and $\textbf{y} \in \mathbb{R}^{n}$ be the labels vector associated to the matrix $\textbf{X}$, where for each $i$, $y_i \in {\mathcal Y}$. \\

A random forest $F_{T_1, \dots, T_l}$  is a classifier  made of a collection of $l$ trees ${T_1, \dots, T_l}$. A single tree and a forest can both be seen as functions. To define this tools, let us introduce ${\cal H}$ as the set of all possible trees:
\todo[inline]{confusion possible notation: majuscule non gras: fonction ou matrice? les deux, à éclaircir}
%
$$ {\cal H} = \{T \ | \ T :\ \mathbb{R}^{n \times d} \ \to \ \cal{Y}\}.$$
%
In this case, a forest can be noted as:
%
$$\begin{array}{ccccc}
F_{T_1, \dots, T_l} & : & \cal{X} & \to & \cal{Y} \\
 & & \textbf{x} & \mapsto & F_{T_1, \dots, T_l}(\textbf{x}) = H(\{T_1, \dots, T_l\} , \textbf{x}) \\
\end{array}$$
%
where $H$ is a function which depend on the task\todo{f unclear: why to introduce it?}. In a regression setup, where ${\cal Y} = \mathbb{R}$\todo{I don't think it is usefull}, this function can be defined as: 
%
$$H(\{T_1, \dots, T_l \} , \textbf{x}) = \sum_{i = 1}^{l} \alpha_i T_i(x) \ \text{ where } \alpha_i \in \mathbb{R},$$
%
while in a classification setup, in which ${\cal Y} = \{ c_1, \dots, c_m \}$, $H$ will be a majority vote function:
%
$$H(\{T_1, \dots, T_l \} , \textbf{x}) = \argmax_{c \in {\cal Y}} \sum_{i = 1}^{l}  \mathds{1}(T_i(\textbf{x}) = c),$$
where $\mathds{1}$ is the indicator function which return $1$ if its argument is correct, and $0$ otherwise.
%
\todo{$\mathds{1}$ not defined}We \todo{no we}will need to define the vector prediction of a forest for all the data matrix: $F_{t_1, \dots, t_l}(\textbf{X})  = \begin{pmatrix}
   F_{T_1, \dots, T_l}(\textbf{x}_1) \\
   \dots \\
   F_{T_1, \dots, T_l}(\textbf{x}_n) 
\end{pmatrix}.$\\
%
%
%
All these notations can be summarized in Table \ref{table: notation}:\\
\begin{table}

\begin{tabular}{ l c }     
  lowercase &  integer \\
  bold lowercase&   vector \\
  bold capital &  matrix \\
  calligraphic letters & vector space \\
  $F_{T_1, \dots, T_l}$ & a forest of $l$ trees \\
  $F_{T_1, \dots, T_l}(\textbf{x}) \in {\cal Y}$ & the predicted label of \textbf{x} by the forest $F_{T_1, \dots, T_l}$ \\
  $F_{T_1, \dots, T_l}(\textbf{X}) \in {\cal Y}^n$ & the predicted label of all the data of $\textbf{X}$ by the forest $F_{T_1, \dots, T_l}$\\  
  $n$ & the number of data \\
  $d$ & the data dimension \\
  $l$ & the initial forest size \\
  $k$ & the desired (pruned) forest size \\
\end{tabular} 
\caption{Notations used in this paper} 
\label{table: notation}
\end{table}\todo[inline]{ajouter les codifications des notations: bold minuscule: vecteur; non-bold majuscule: matrix, etc..}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Orthogonal Matching Pursuit (OMP)}
Given a matrix $D = [d_1, \dots , d_l] \in \mathbb{R}^{n\times l}$ \todo{l undefined in text} (also called a dictionary) and a signal $\textbf{y}\in \mathbb{R}^n$, finding a $k$-sparse vector $\textbf{w} \in \mathbb{R}^l$ (i.e. $|| \textbf{w} ||_0 \leq k$) that minimize $|| X\textbf{w} - \textbf{y}||$ is an NP-hard problem \todo{(ref np-hardness)}.
The Orthogonal Matching Pursuit (OMP) algorithm is a greedy algorithm that aim to give an approximate solution of this problem.
The approximation of $\textbf{y}$ is built one term at a time. Noting $\textbf{y}_k$ the current
 approximation and $r_k = \textbf{y} - \textbf{y}_k$ the so-called residual, we select at each time step the atom (i.e. the column of $X$) which has the largest inner product with $r_k$, and update the approximation. 
This step is repeated until a satisfactory approximation. This can be summarized in Algorithm \ref{algo: OMP}



%$y \in \mathbb{R}^n$ a signal. $D \in \mathbb{R}^{n \times d}$ a dictionnary with $d_j \in \mathbb{R^n}$. Goal: find $w \in \mathbb{R}^d$, such that $y = Dw$ and $||w||_0 < k$. $\text{span}(\{v_1, \dots, v_n\}) \{u : u = \sum^n_{i=1} \alpha_i v_i \ | \ \alpha_i \in \mathbb{R}\}$.

\begin{algorithm}[htb]
    \caption{Orthogonal Matching Pursuit}\label{algo: OMP}
    \begin{algorithmic}[1]
        \State $w_0 \gets 0$
        \State $r_0 \gets \textbf{y}$
        \State $\lambda \gets \emptyset$
        \ForEach {$k \in \{0, \dots, K\}$}
            \State $d^* \gets \underset{d \in \{d_1, \dots, d_l\}}{\text{argmax}} \ |<d, r_k>|$
            \State $\lambda \gets \lambda \cup \{d^*\}$
            \State $\rvw_{k+1} \gets \underset{\substack{\rvalpha \in \mathbb{R}^n \text{ s.t. } \\ D\rvalpha \ \in \ \text{span}(\lambda)}}{\text{argmin}} \ ||\textbf{y} - D\rvalpha||^2_2$
            \State $r_{k + 1} \rightarrow \textbf{y} - D \rvw_{k+1}$
        \EndFor
    \end{algorithmic}
\end{algorithm}
%
In general, the OMP algorithm can be seen as an algorithm that 'summarize' \todo{summarize: unclear}the most useful column of the dictionary for expressing the signal \textbf{y}.
In this paper, we use this algorithm to reduce the forest's size by selecting the most informative trees in the forest (see Section \ref{sec: forest pruning} for more details). 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Related Work}
\todo[inline]{réduire: sélectionner l'essentiel, regrouper en catégorie d'algorithmes et se positionner (forward vs backward selection, etc.)}
\begin{itemize}
\item \cite{Yang2012}: once the forest $(F = t_1, \dots, t_n)$\todo{inconsistent notations} is built, he \todo{who?} gives each tree a score (which measures the importance of the tree in the forest). The tree with the lowest score is removed from the forest. To eliminate the next tree, all the scores are recomputed, and the tree with the lowest score is removed... \todo{and so forth and so on}\\
They present in this paper 4 \todo{numbers} different tree's score. For each tree $t_i$, we compute:
\begin{itemize}
\item $score_1 = mean_{(x,y) \in train}( margin((x,y), F) - margin((x,y),F\backslash t_i))$
\item $score_2 = min_{(x,y) \in train}( margin((x,y), F) - min_{(x,y) \in train} (margin(F\backslash t_i)))$
%\item $score_3 = min_{(x,y) \in train}( margin((x,y), F) - min_{(x,y) \in train} (margin(F\backslash t_i)))$
\end{itemize}
where:
$$ margin((x, y), F) = \frac{1}{|F|} \sum_{i = 1}^{|F|} I(t_i(x) = y) - \sum_{i = 1}^{|F|} \max_{l \neq y} I(t_i(x) = l)$$
They compute some experiments in several classification (most of them are binary classification) UCI data set, with different number of attribute (from 5 to 61): Diabetes, Heart, Hearts, Iris, Ionosphere, Monks, Sonar, Steel, Tic, Wine.
They construct a random forest model of size 100, then prune it with their Algorithm and obtain a smaller forest with size ranging from 99 to 20. The performances of their algorithms are compared with random forest models with the corresponding sizes (i.e. forest directly constructed with size 99 to 20). 
On all the data sets except colon and diabetes data sets, the more the number of trees pruned, the better the performance.
They does not show the variance of the models. They also compare their method with similarity based pruning ( Sim-P) and  distance minimization(MarDistM) . Except for diabetes, their method outperforms the other two algorithms.
%
\item \cite{Zhang}: This paper present 3 measures to determine the importance of a tree in a forest. Trees with less importance will be removed from the forest.
\begin{itemize}
\item $measure_1$ focuses on the prediction. A tree can be removed if its removal from the forest have the smallest impact in the prediction accuracy. Let $F = (t_1, \dots, t_n)$ a forest. For every tree $t_i$, we calculate importance score $\Delta_{T \backslash t_i}$ which is the difference between the prediction accuracy of $F$ and $F \backslash t_i$:
$$ \Delta_{T \backslash t_i} =  predictAccuracy(F) - predictAccuracy(F \backslash t_i) $$
The tree that will be removed is $t = argmin_{t \in F} ( \Delta_{T \backslash t})$.
\item $measure_2$ will try to remove a tree if it is similar to others trees in the forest. The measure of similarity between the tree $t_i$ and the forest is noted by:
$$\rho_{t_i} = \frac{1}{|F|} \sum_{t \in F; \ t \neq t_i} cor_{t_i, t}$$
where: $cor_{t_i, t_j} = correltion(predict_{t_i}, predict_{t_j} ) $ is the correlation between the prediction of the tree $t_i$ and the tree $t_j$. In this method, the deleted tree is the one that minimize $\rho$.
\item $measure_3$ 
\end{itemize}
For the experiments, they use breast cancer prognosis. They reduce the size of a forest of 100 trees to a forest of on average 26 trees keeping the same error rate.

\item \cite{Fawagreh2015}: The goal is to get a much smaller forest while staying accurate and diverse. To do so, they used a clustering algorithm. Let $C(t_i, T) = \{c_{i1}, \dots, c_{im}\}$ denotes a vector of class labels obtained after having $t_i$ classify the training set $T$ of size $m$, with $t_i \in F$, $F$ the forest of size $n$. Let $\mathcal{C} = \bigcup^n_{i=1} C(t_i, T)$ be the super vector of all class vectors classified by each tree $t_i$. They then applied a clustering algorithm on $\mathcal{C}$ to find $k = \sqrt{\frac{n}{2}}$ clusters. Finally, the final forest $F'$ is composed on the union of each tree that is the most representative per cluster, for each cluster. So if you have 100 trees and 7 clusters, the final number of trees will be 7. They obtained at least similar performances as with regular RF algorithm.
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Forest pruning}\label{sec: forest pruning}
In this section, we will describe our method for pruning the forest, and thus reduce its size. \\
Consider a forest $F_{t_1, \dots, t_l}$ of $l = 100$ \todo{trop concret}trees, trained using the training data set, witch consist of the 60\% of the data. For every $i \in \{ 1, \dots , l\}$, we note the vector of prediction of the tree $t_i$ in all the $n$ data by:
$$\textbf{y}_i =  \begin{pmatrix}
   t_1(\textbf{x}_1) \\
   \dots \\
   t_1(\textbf{x}_n)
\end{pmatrix},$$
and the matrix of all the forest prediction in all the data by:
$$Y =  [\textbf{y}_1 , \dots , \textbf{y}_l ] \in \mathbb{R}^{n \times l}.$$
We apply the OMP algorithm to the $Y$ matrix and to the reals labels vector $\textbf{y}$. Thus, we will look for the $k$ most informative trees to predict the true labels. \todo{détailler plus comment est utilisé OMP}\todo{ajouter l'algorithme} 
 
 \section{Reference}

\nocite{*}
\bibliographystyle{plain}
\bibliography{bolsonaro_biblio}
\end{document}
