## 3 Methods
### BHOA for Feature Selection  
The BHOA is adapted for feature selection, such that the positions are represented by arrays of \(0^{\prime}\)s and \(1^{\prime}\)s, where the number of \(1^{\prime}\)s is at least two to avoid exceptional cases when the classifiers cannot be applied to data samples with one feature or no features. The function which is used for converting the continuous values in binary values is:  
\[S(x)=\left\{ \begin{array}{rl}1,&rand<\left|\frac{x}{\sqrt{1+x^{2}}}\right|\\ &0,&\text{otherwise}\end{array} \right., \tag{6}\]  
where the function \(rand\) returns random values from \([0,\ 1]\). The pseudo-code of the BHOA for feature selection is presented next (see Algorithm 1). ```
1:Input \(I\), \(D\), \(N\), \(M\), \(DSP\), \(HDR\), \(HMP\), \(SSP\), \(OF\)
2:Output \(h_{gbest}\)
3: initialize a population of \(N\) horses in the \(D\)-dimensional space
4: adjust the positions of the horses
5: apply \(OF\) to compute the fitness values of the horses and update \(h_{gbest}\)
6:for\(iteration=0\) to \(I-1\)do
7:if\(iteration\) mod \(M==0\)then
8: the best \(N\times DSP\) horses are leaders of herds from \(T\)
9: the next best \(N\times SSP\) horses represent set \(S\)
10: the remaining horses are distributed randomly to herds from \(T\)
11: the worst \(N\times HDR\) horses are positioned randomly
12:end if
13: compute the horse ranks and the left of each herd from \(T\)
14:for each horse do
15: update the gait
16:if single then
17: update the velocity using Formula (1)
18:else
19: update the velocity using Formula (2)
20:endif
21: update the position by applying the Formula (6) to the velocity and adjust it
22: update the \(HMP\)-dimensional memory using the Formulas (4)-(6) and adjust it
23: update the new fitness value, the position, and \(h_{gbest}\)
24:endfor
25: compute the horse ranks and the left of each herd from \(T\)
26: swapping stallions operations
27:endfor
28:return\(h_{gbest}\)
```  
**Algorithm 1** BHOA for feature selection. The inputs of the BHOA (line 1) are the same as in the case of the HOA, where \(OF\) is the objective function. The output is the position of the best horse, \(h_{gbest}\) (line 2). The population of \(N\) horses is initialized in the \(D\)-dimensional search space (line 3) with binary values. The position of each horse is adjusted in line 4 such that if it contains less than two \(1^{\prime}\)s and the rest are only \(0^{\prime}\)s, then the position is updated to a new array with two \(1^{\prime}\)s selected at random positions, the rest of the elements of the array being filled with \(0^{\prime}\)s. \(OF\) is applied in line 5 to compute the fitness of the horses and \(h_{gbest}\) is updated to the position of the horse with the best fitness value. The instructions which correspond to lines 7-26 are performed \(I\) times. If \(iteration\) is divisible by \(M\) (line 7), then the horses are reorganized as follows: the best \(N\times DSP\)horses are leaders of herds from the set \(T\) (line 8), the next \(N\times SSP\) horses compose the set \(S\) (line 9), and the remaining horses are assigned randomly to herds from \(T\) (line 10). In line 11, the worst \(N\times HDR\) horses in terms of fitness value are positioned randomly in the \(D\)-dimensional search space such that their positions are represented by new arrays of \(0^{\prime}\)s and \(1^{\prime}\)s initialized randomly. The new positions are adjusted such that the number of \(1^{\prime}\)s is at least two for each position. The new fitness values of the worst horses are computed using \(OF\) and \(h_{gbest}\) is updated accordingly. The horse ranks and the center of each herd from the set \(T\) are evaluated in line 13. The instructions from lines 15-23 are performed for each horse. The gait is updated to a random number from \([1,\ 2]\) (line 15). If the horse is single (line 16), then it updates its velocity using Formula (1), otherwise it updates its velocity using Formula (2). Formula (6) is applied in (line 21) to the velocity value to calculate the new value of the position.