## 3 Heterogeneous Ensemble Learning by SQGA
### Weight Optimization by SQGA  
On the basis of obtaining the output of multiple base classifiers, it is necessary to fuse these outputs to get the final detection result. Because fatigue detection is a binary classification problem, we set the output results of each base classifier to +1 and \(-1\), respectively, indicating normal and fatigue detection. Suppose there are n base classifiers, the detection result of the \(i\)-th base classifier is \(y_{i}\) and the weight of fusion is \(x_{i}\), then the final detection result is:  
\[y=\text{sgn}(\sum_{i=1}^{n}x_{i}y_{i}). \tag{9}\]  
We need to find the optimal \(\mathbf{x}\) to ensure the highest detection accuracy of the model, the optimization objective function should be:  
\[f(\mathbf{x})=\text{max}(acc),0<\mathbf{x}<1. \tag{10}\]  
Among them, _acc_ represents the test accuracy of the whole ensembled model under different weights, vector \(\mathbf{x}\). In order to solve this problem, we choose quantum genetic algorithm (QGA) to solve it. QGA is an optimization method combining quantum computing with a genetic algorithm [28], which has the advantages of fast convergence speed and strong global optimization ability. The difference between quantum genetic algorithm and traditional genetic algorithm is mainly reflected in two aspects:  
(1) chromosome is represented by qubit code, and gene is expressed in the form of probability amplitude. The m-bit qubit code can be expressed as:  
\[\left[ \begin{array}{cccc}\alpha_{1}&\alpha_{2}&\cdots&\alpha_{m}\\ \beta_{1}&\beta_{2}&\cdots&\beta_{m}\\ \end{array} \right]; \tag{11}\]  
where (\(\alpha_{i}\), \(\beta_{i}\)) is the \(i\)-th qubit in the chromosome, which is a pair of complex numbers, representing the probability amplitude of the corresponding bit, and satisfying \(|\alpha|^{2}+|\beta|^{2}\)= 1, \(|0\rangle\) and \(|1\rangle\) represent two different bit states. When the qubit is not observed, the qubit is in the basic state. After observing the qubit, the qubit will collapse to 0 or 1 with the probability of \(|\alpha|^{2}\) or \(|\beta|^{2}\). (2) The quantum rotation gate is used to replace the selection, crossover and mutation operations, and the population is updated by changing the quantum rotation angle. The qubit is updated to  
\[\left| \begin{array}{c}{\alpha_{i}}^{\prime}\\ {\beta_{i}}^{\prime}\end{array} \right|=\left|\begin{array}{cc}\cos\Delta\theta _{i}-\sin\Delta\theta_{i}&\left| \begin{array}{c}{\alpha_{i}}\\ {\sin\Delta\theta_{i}}\end{array} \right|&\left| \begin{array}{c}{\alpha_{i}} \\ {\beta_{i}}\end{array} \right|. \tag{12}\]  
where: (\(\alpha_{i}^{\prime},\beta_{i}^{\prime}\)) denotes the updated \(i\)-qubit; \(\Delta\theta_{i}\) is the quantum rotation angle. A Quantum genetic algorithm has the characteristics of fast convergence speed and strong global optimization ability; however, the quantum angle rotation strategy can only rotate at a fixed size, it is easy to fall into local optimization. In this paper, we use adaptive adjustment of quantum rotation angle to improve the quantum genetic algorithm. When the individual fitness approaches the optimal individual, the quantum rotation angle decreases, which makes the individual evolve in a good direction; when the individual fitness is far away from the optimal individual, the quantum rotation angle increases, expands the search space and jumps out of the local optimum. In the process of quantum gate rotation and update, it cannot reach the global optimal solution with probability \"1\", which can easily fall into premature convergence. Therefore, this paper introduces crossover and mutation operations in traditional GA to increase the search space and avoid falling into the local optimal solution. The selection of crossover probability and mutation probability in the genetic algorithm is the key to affecting the behavior and performance of the genetic algorithm.