Algorithm 1 Searching the optimal number of features |
Given a set of features F of n elements with gain ratio values F0, F1, F2, …, Fn−1 sorted such that F0 > F1 > F2 … > Fn−1, and the accuracym being the correctness classifying the dataset using the first m features. The following algorithm is based on the binary search to find the index m in F that corresponds to the minimum index to classify the dataset properly.
Set L to 0 and R to n − 1
Set m = R, mold = m
If accuracym < 99%, stop, the classifier must use the all features
Set m (the middle position) to the floor of
If accuracym > 99%, set R to m
If accuracym < 99%, set L to m
If abs(m − mold) > 0, mold = m, goto 4
Stop, the classifier must use the first m + 1 features
|