## 5 Experiment and Analysis
### Computation and Results Analysis
#### 5.2.2 The k-Nearest Neighbor and Artificial Neural Network with Back Propagation  
(1) KNN  
The KNN [45] is a classification method based on statistics. It was first proposed by [PERSON] and [PERSON] in 1968. As the simplest machine learning method, the algorithm is relatively theoretically mature and is widely used in classification tasks [46]. This algorithm performs the following operations on each unknown category in the dataset:  
**Step 1. ** The distance between the point of the dataset with a known class and the current point is calculated;  
**Step 2. ** The distances are sorted according to increasing order of distance;  
**Step 3. **\(k\) points with the minimum distance are selected from the current point;  
**Step 4. ** The occurrence frequency of the category of the previous \(k\) points is determined;  
**Step 5. ** The class with the highest frequency of the previous \(k\) points is selected as the pre-classification of the current point. In Step 1, computing the distance includes the Euclidean distance, Manhattan distance, etc. (the latter one is utilized in this paper). The eigenspace \(\chi\) is an \(n\) dimensional real vector space \(\mathbf{R}^{n}\), where \(x_{i},x_{j}\in\chi\), \(x_{i}=\left({x_{i}}^{(1)},{x_{i}}^{(2)},\cdot\cdot\cdot,{x_{i}}^{(n)}\right)^ {\mathrm{T}}\), \(x_{j}=\left({x_{j}}^{(1)},{x_{j}}^{(2)},\cdot\cdot\cdot,{x_{j}}^{(n)}\right)^ {\mathrm{T}}\). The Manhattan distance of \(x_{i},x_{j}\) is:  
\[L_{1}(x_{i},x_{j})=\sum_{l=1}^{n}\left|x_{i}^{(l)}-x_{j}^{(l)}\right| \tag{13}\]  
In practical applications, the choice of the \(k\) value should not be too small or too large, because the prediction results are very sensitive to the value of \(k\)[47]. For example, we choose a few \(k\) values, such as 7, 10, 13, 15, and 20, and the accuracy results are 85.24%, 88.44%, 86.67%, 85.42%, and 81.33%, respectively, which illustrates that the accuracy of each prediction with different \(k\) values is quite different. To find the \(k\) nearest neighbor points quickly, we use the ball-tree [48]. The ball-tree is suitable for high-dimensional problems, generally when the feature dimension is greater than 20 [49]. In this paper, the dimension of the dataset is 784. After adopting the ball-tree in KNN, the prediction accuracy is 94.04% and the time consumption is 50 s. The confusion matrix of the prediction result is shown in Figure 12.  
Figure 12: The k-nearest neighbor (KNN) confusion matrices. (**a**) Without normalization; (**b**) normalized. As depicted in Figure 12, the precision of the normal (NM) and disproportional spacing (DS) states is 1, which is the highest. The precision of the broken strand of the left rope (BS-LR) is 0.83, which is the lowest yielded result. The prediction results show that the main prediction errors occur among similar fault types. For example, for the 127 BS-LR faults, 17 are predicted as the broken strand of the right rope (BS-RR) type; for 131 BS-RR faults, 10 are predicted as the BS-LR type; and for 124 double broken rope (D-BR) faults, 9 are predicted as the right broken rope (R-BR) type. The results demonstrate that KNN has some shortcomings in distinguishing similar fault types (consistent with the hypothesis analysis in Section 5.1), and the accuracy is lower than that of the CNN algorithm. (2) ANN-BP  
The ANN-BP is a typical model that uses an error back-propagation algorithm to train the weights and biases of each neuron, and it contains several layers (i.e., input layer, output layer, and hidden layers) [50]. The ANN-BP has a relatively simple structure, and thus it has been widely used in fitting nonlinear continuous functions and pattern recognition [51]. The training and testing processes are shown in Figure 13 using the same structure as the CNN's fully connected layer (784-200-64-32-9) and the same network settings proposed in this paper (i.e., using the hold-out method; the learning rate is set to 0.01; the batch size is set to 5; the iteration is set to 40 epochs; the SGD algorithm is used, etc.).