# Neural Network-Enhanced Fault Diagnosis of Robot Joints
## 4 Computational Experiments
### Experimental Evaluation of Single Size of Fault
The black box is false negative (FN), which indicates that the actual value is positive in our example, but the model predicts it to be negative, i.e., some other labelled class. The value of FN, which can be computed from the neighbouring rows except for the TP value, is zero. The green box is True Negative (TN), which indicates that the actual and predicted values have the same meaning, and it is the sum of the values of all non-0 rows and columns, which is 1800. For data labelled as 0, TP, FP, FN and TN can  
Figure 10: Confusion matrix of classifier by injected fault at one degree with two features. help to implement more metrics specific to that category, such as accuracy for fault-free trajectory diagnosis:  
\[\text{Precision}(0)=\frac{\text{TP}}{\text{TP}+\text{FP}}=\frac{297}{297+3}=99\% \tag{6}\]  
This means that for data labelled 0, there is a 99.85% probability that each classification prediction is correct. \[\text{Accuracy}(0)=\frac{\text{TP}+\text{TN}}{\text{TP}+\text{TN}+\text{FP}+ \text{FN}}=\frac{297+1800}{297+1800+3+0}=99.85\% \tag{7}\]  
Precision means that if a label is identified as class 0, then there is a 99% probability that it belongs to that class. \[\text{Recall}(0)=\frac{\text{TP}}{\text{TP}+\text{FN}}=\frac{297}{297+0}=100\% \tag{8}\]  
Recall means that if a data belongs to class 0, then there is 100% probability of being predicted correctly. With the confusion matrix, some parameters can be calculated for specific individual classifications, calculated in the same way as above, and it can be seen that training the neural network with dual features when the injected faults are one degree and the number of samples of a single trajectory is 1500, which has a very good classification effect. In addition to the confusion matrix, another commonly used metric for evaluating classifier performance is the ROC curve, which is a reflection of the relationship between sensitivity and specificity. The horizontal position X-axis is the specificity metric, also known as the false positive rate (false alarm rate), and the closer the X-axis is to zero, the higher the accuracy is; the vertical position Y-axis is known as the sensitivity, also known as the true positive rate (sensitivity), and a larger Y-axis represents a better accuracy. According to the position of the curve, the whole graph is divided into two parts. The area of the lower part of the curve is called the Area Under Curve (AUC), which is used to quantify the overall performance of the ROC curve and indicate the prediction accuracy; the higher the AUC value, that is, the larger the area under the curve, the higher the prediction accuracy. The closer the curve is to the upper left corner (the smaller the X, the larger the Y), the higher the prediction accuracy. The test set ROC curve for the neural network model after the above experiment is shown in Figure 11.  
Figure 11: ROC curve by one degree injected fault with two features. As can be seen from Figure 11, the ROC curves for all seven classifications fit perfectly on the upper left axis, and the corresponding AUC values are all one, which means that the model achieves perfect prediction under all thresholds, i.e., the trade-off between the True Positive and False Positive rates is optimal. In other words, the model has a strong ability to distinguish between positive and negative categories well. But, on the other hand, there may be some problems in this case, such as data overfitting, which means that the model may have over-learned the features and noise in the training data, resulting in a very good performance on the training data, but the prediction of the new data may not be as good, i.e., the generalisation error will be larger. Overall, the performance of the neural network model for classification of fixed trajectories is still excellent, and the near-perfect performance also leads to the fact that a single incorrect prediction may also lead to a very high cross-entropy loss, as previously conjectured.