2.5 KiB
Algorithm
-
// notation
-
n
features{\cal{X}} = \{X_1, \dots, X_n\}
and the classY
-
m
instances. -
D = \{ (x_1^i, \dots, x_n^i, y^i) \}_{i=1}^{m}
-
W
a weights vector.W_0
are the initial weights. -
D[W]
dataset with weightsW
for the instances.
-
// initialization
-
W_0 \leftarrow (w_1, \dots, w_m) \leftarrow 1/m
-
W \leftarrow W_0
-
Vars \leftarrow {\cal{X}}
-
\delta \leftarrow 10^{-4}
-
convergence \leftarrow True
// hyperparameter -
maxTolerancia \leftarrow 3
// hyperparameter -
bisection \leftarrow False
// hyperparameter -
finished \leftarrow False
-
AODE \leftarrow \emptyset
// the ensemble -
tolerance \leftarrow 0
-
numModelsInPack \leftarrow 0
-
maxAccuracy \leftarrow -1
-
// main loop
-
While
(\lnot finished)
-
\pi \leftarrow SortFeatures(Vars, criterio, D[W])
-
k \leftarrow 2^{tolerance}
-
if (
tolerance == 0
)numItemsPack \leftarrow0
-
P \leftarrow Head(\pi,k)
// first k features in order -
spodes \leftarrow \emptyset
-
i \leftarrow 0
-
While (
i < size(P)
)-
X \leftarrow P[i]
-
i \leftarrow i + 1
-
numItemsPack \leftarrow numItemsPack + 1
-
Vars.remove(X)
-
spode \leftarrow BuildSpode(X, {\cal{X}}, D[W])
-
\hat{y}[] \leftarrow spode.Predict(D)
-
\epsilon \leftarrow error(\hat{y}[], y[])
-
\alpha \leftarrow \frac{1}{2} ln \left ( \frac{1-\epsilon}{\epsilon} \right )
-
if (
\epsilon > 0.5
)-
finished \leftarrow True
-
break
-
-
spodes.add( (spode,\alpha_t) )
-
W \leftarrow UpdateWeights(W,\alpha,y[],\hat{y}[])
-
-
AODE.add( spodes )
-
if (
convergence \land \lnot finished
)-
\hat{y}[] \leftarrow AODE.Predict(D)
-
actualAccuracy \leftarrow accuracy(\hat{y}[], y[])
-
if (maxAccuracy == -1)\; maxAccuracy \leftarrow actualAccuracy
-
if
((accuracy - maxAccuracy) < \delta)
// result doesn't improve enoughtolerance \leftarrow tolerance + 1
-
else
-
tolerance \leftarrow 0
-
numItemsPack \leftarrow 0
-
-
-
If
(Vars == \emptyset \lor tolerance>maxTolerance) \; finished \leftarrow True
-
lastAccuracy \leftarrow max(lastAccuracy, actualAccuracy)
-
-
if (
tolerance > maxTolerance
) // algorithm finished because of lack of convergenceremoveModels(AODE, numItemsPack)
-
Return
AODE