## Predictive model

Random forest is an ensemble of trees. Therefore, the prediction of the random forest is based on the collective wisdom of the trees that make up the forest.

#### Classification

In the classification setting, the prediction of the random forest is the most dominant class among predictions by individual trees.
If there are \( T \) trees in the forest, then the number of *votes* received by a class \( \nclasssmall \) is

$$ v_{\nclasssmall} = \sum_{t=1}^T \indicator{\yhat_t == \nclasssmall} $$

where, \( \yhat_t \) is the prediction of the \( t\)-th tree on a particular instance. The indicator function \( \indicator{\yhat_t == \nclasssmall} \) takesn on the value \( 1 \) if the condition is met, else it is zero.

Given these votes, the final prediction of the random forest is the class with the most votes

\begin{equation}
\yhat = \argmax_{\nclasssmall \in \set{1,\ldots,\nclass}} v_{\nclasssmall}
\label{eqn:class-pred}
\end{equation}

#### Regression

In the regression setting, the prediction of the random forest is the average of the predictions made by the individual trees.
If there are \( T \) trees in the forest, each making a prediction \( \yhat_t \), the final prediction \( \yhat \) is

\begin{equation}
\yhat = \frac{1}{T} \sum_{t=1}^{T} \yhat_t
\label{eqn:reg-pred}
\end{equation}