BayesNet/docs/algorithm.tex

69 lines
2.6 KiB
TeX

\begin{enumerate}
\item[] // initialization
\item $W_0 \leftarrow (w_1, \dots, w_m) \leftarrow 1/m$
\item $W \leftarrow W_0$
\item $Vars \leftarrow {\cal{X}}$
\item $\delta \leftarrow 10^{-4}$
\item $convergence \leftarrow True$
\item $maxTolerancia \leftarrow 3$
\item $bisection \leftarrow False$
\item $error \leftarrow \inf$
\item $finished \leftarrow False$
\item $AODE \leftarrow \emptyset$ \hspace*{2cm} // the ensemble
\item $tolerance \leftarrow 0$
\item $numModelsInPack \leftarrow 0$
\item[]
\newpage
\item[] // main loop
\item While (!finished)
\begin{enumerate}
\item $\pi \leftarrow SortFeatures(Vars, criterio, D[W])$
\item if $(bisection) \; k \leftarrow 2^{tolerance} \;$ else $k \leftarrow 1$
\item if ($k tolerance == 0$) $W_B \leftarrow W$; $numItemsPack \leftarrow0$
\item $P \leftarrow Head(\pi,k)$ \hspace*{2cm} // first k features in order
\item $spodes \leftarrow \emptyset$
\item $i \leftarrow 0$
\item While ($ i < size(P)$)
\begin{enumerate}
\item $X \leftarrow P[i]$
\item $i \leftarrow i + 1$
\item $numItemsPack \leftarrow numItemsPack + 1$
\item $Vars.remove(X)$
\item $spode \leftarrow BuildSpode(X, {\cal{X}}, D[W])$
\item $\hat{y}[] \leftarrow spode.Predict(D[W])$
\item $e \leftarrow error(\hat{y}[], y[])$
\item $\alpha \leftarrow \frac{1}{2} ln \left ( \frac{1-e}{e} \right )$
\item if ($\alpha > 0.5$)
\begin{enumerate}
\item $finished \leftarrow True$
\item break
\end{enumerate}
\item $spodes.add( (spode,\alpha_t) )$
\item $W \leftarrow UpdateWeights(D[W],\alpha,y[],\hat{y}[])$
\end{enumerate}
\item $AODE.add( spodes )$
\item if ($convergence \And ! finished$)
\begin{enumerate}
\item $\hat{y}[] \leftarrow Predict(D,spodes)$
\item $e \leftarrow error(\hat{y}[], y[])$
\item if $(e > (error+\delta))$ \hspace*{2cm} // result doesn't improve
\begin{enumerate}
\item if $(tolerance == maxTolerance) \;\; finished\leftarrow True$
\item else $tolerance \leftarrow tolerance+1$
\end{enumerate}
\item else
\begin{enumerate}
\item $tolerance \leftarrow 0$
\item $error \leftarrow min(error,e)$
\end{enumerate}
\end{enumerate}
\item If $(Vars == \emptyset) \; finished \leftarrow True$
\end{enumerate}
\item if ($tolerance == maxTolerance$) // algorithm finished because of lack of convergence
\begin{enumerate}
\item $removeModels(AODE, numItemsPack)$
\item $W \leftarrow W_B$
\end{enumerate}
\item Return $AODE$
\end{enumerate}