## 2 Methodology
### State Recognition Method
The classification formula for kNN is:  
\[y=\operatorname*{argmax}_{c_{j}}\sum_{i=1}^{k}w_{i,j}[y_{i}=c_{j}], \tag{10}\]  
where \(y\) is the class label assigned to the test sample, \(c_{j}\) is the \(j\)-th class label, \(w_{i,j}\) is the weight assigned to the \(i\)-th nearest neighbor of the test sample that belongs to class \(c_{j}\), and \(\left[y_{i}=c_{j}\right]\) is the indicator function that is equal to 1 if \(y_{i}=c_{j}\), and 0 otherwise. The optimal value of \(k\), a hyperparameter, can be determined through cross-validation. In the real-time recognition step, the HBM monitoring system collects a segment of the acceleration data in the time-domain of duration \(\Delta t\). Based on the above steps, the current acceleration signal \(R_{c}\) and the current feature vector \(F_{c}\) were obtained. The kNN classifier was employed for real-time comparison to output the results of the A, B, C, and D states for \(R_{c}\). To enhance the reliability of state recognition, a conditional output step, grounded in the actual working condition of the HBM, was incorporated into the process (see Figure 5). A time length, \(\Delta T\), was established such that \(\Delta T>\Delta t\). If the counts of state A, B, C, and D identified within the time period \(\Delta T\) are \(N_{\text{SA}}\), \(N_{\text{SB}}\), \(N_{\text{SC}}\), and \(N_{\text{SD}}\), respectively, the working state of the HBM during this \(\Delta T\) period can be determined. This determination is based on the actual working process of the HBM and the conditional relationships among \(N_{\text{SA}}\), \(N_{\text{SB}}\), \(N_{\text{SC}}\), and \(N_{\text{SD}}\). In Figure 5, \(N\) represents the total number of recognized results during the \(\Delta T\) period, which is the sum of \(N_{\text{SA}}\), \(N_{\text{SB}}\), \(N_{\text{SC}}\), and \(N_{\text{SD}}\). The scaling factor of the number of recognized results is represented by \(b\), with \(b\) (0,1]. The value of \(b\) can be adjusted according to the actual conditions at the project site. In the final state output, an additional state, state E (the error state), was introduced to account for conditions that are not possible during the actual operation process of the HBM. \[\overline{R}=\frac{1}{m}{\sum_{i=1}^{m}R_{i}} \tag{2}\]0 Offset axis crossing count diagram. For instance, the climbing and pumping states of HBM are mutually exclusive and cannot occur simultaneously in a short time span. Therefore, if the climbing and pumping states are identified within the \(\Delta T\) period (i.e., \(N_{\text{SA}}>0\) and \(N_{\text{SC}}>0\)), the output result should be state E. Furthermore, considering the continuity of the HBM states, transitions between various states are relatively smooth. As a result, if the recognition outcome during the current \(\Delta T\) period does not correspond to any of the five states A, B, C, D, or E, as delineated in Figure 5, the system outputs the recognition result from the preceding period. When the output results in state E, it is critical to provide clear and understandable error messages in order to increase the availability of the HBM and reduce downtime. In this case, a simple text description can be used to describe the nature of the error, e.g., \"Error: Climbing and pumping statuses at the same time.\" This will enable managers to quickly understand what the problem is and take appropriate action to resolve it, thus improving the user experience and the overall efficiency of the HBM's work.