# Feature Optimization for Gait Phase Estimation with a Genetic Algorithm and Bayesian Optimization
## 3 Gait Phase Estimation Model
### Optimization Algorithms
#### 3.2.1 Binary Genetic Algorithm for Feature Selection  
A BGA was used to select an optimal feature set for the target subject. The BGA generates different populations iteratively to create binary-type genes, each of which corresponds to one of the TD features. The BGA can be implemented using the following procedure. First, an initial population is generated. Then, the objective function value is calculated for each chromosome; the objective function is described in Section 3.2.2. The chromosome is a vector consisting of binary values, and each binary value implies the presence of a designated TD feature. Next, a new population is created by applying crossover and mutation to the chromosomes. Finally, the objective functions of the new population are evaluated. This procedure can be repeated until the generation number reaches a predefined value.  
A feature pool for the BGA was constructed with 12 TD features: minimum, maximum, mean (\(\mu\)), standard deviation (\(\sigma\)), initial (\(t_{i}\)), and final (\(t_{f}\)) values for the thigh angle and angular velocity. Specifically, the feature pool was constructed as (\(\theta_{\text{min}}\), \(\theta_{\text{max}}\), \(\mu_{\theta}\), \(\sigma_{\theta}\), \(\theta_{(t_{f})}\), \(\theta_{(t_{f})}\), \(\hat{\theta}_{\text{max}}\), \(\hat{\theta}_{\text{min}}\), \(\mu_{\hat{\theta}}\), \(\sigma_{\hat{\theta}}\), \(\theta_{(t_{i})}\), \(\hat{\theta}_{(t_{f})}\)). If zero is allocated to a gene, the corresponding feature is not used in the gait phase estimation. If unity is allocated to a gene, the corresponding feature is used in the estimation. All features are composed of the values for the left and right thighs. For example, if \(\mu_{\theta}\) is selected as a feature, then the mean values of both the left and right thigh angles (i.e., \(\mu_{\text{L},\theta}\) and \(\mu_{\text{R},\theta}\)) are used in the gait phase estimation, as shown in Figure 5.  
In this study, the population size for each generation was fixed at 15, the maximum number of generations at 20, the crossover rate at 0.5, and the mutation rate at 0.05. Although [PERSON] et al. (2018) suggested using 50 initial populations, this study selected  
Figure 5: TD feature selection in the BGA. TD features in the feature pool are selected or rejected when the binary values in the chromosome are determined. For example, if the “1” is allocated in the second element of the chromosome, \(\theta_{\text{max}}\) is used as the feature. Then, \(\theta_{\text{max}}\) of both the right thigh and left thigh motion are used for gait phase estimation.  
15 initial populations considering the small dimension of the feature pool. Consequently, the other parameters were adjusted based on [40]. Additionally, roulette-wheel crossover and bit-flip mutation were applied to the crossover and mutation methods, respectively. The roulette wheel is a widely used stochastic selection method in which the probability of an individual being selected is proportional to its fitness value [41]. This strategy enables the delivery of valuable individuals to the next generation with a high probability. The bit-flip mutation flips the binary value of an individual to generate a mutated chromosome [42]. Finally, one elite chromosome for each generation was preserved and passed to the next generation.