# A Safety Prediction System for Lunar Orbit Rendezvous and Docking Mission
## 3 Human-Machine Collaborative Self-Judgment Framework for Safety of RVD
### Safety Judgment Knowledge Base
#### 3.3.2 Training of Decision Trees  
We first extract features \((F_{1,1},\cdots,F_{i,j},\cdots,F_{1,l_{n}})\) from the simulated RGB image sequence \(\left(I_{1,1},\cdots,I_{i,j},\cdots,I_{1,l_{n}}\right)\) generated by using the spacecraft dynamics simulation model, and also obtain the deviation of the rendezvous and docking result corresponding to this sequence. Here, \(I_{i,j}\) denotes the simulated image at time \(j\) in the \(i\)-th rendezvous and docking experiment. Then, we convert the deviation into a safety level by using Equation (1). Thus, we can obtain the sample by treating the safety level as a label. After simulating several times, the generated samples are finally used to train the decision tree. In the real rendezvous and docking experiment, after capturing the image of the docking surface of the target using the security surveillance camera installed on the chaser, we extract the features and use the safety judgment knowledge base to determine the safety level corresponding to the current state.  
The safety judgment knowledge base is constructed using an Ordinary Binary Classification Tree (OBCT). The sample set is divided into a training set (90%) and a validation set (10%), and a cross-validation technique is used as the stopping criterion in the training of the decision tree. The algorithm flow of the training of the decision tree is shown in Figure 6. We continuously select the best features to split the node until the average classification error of all validation sets is minimized. Finally, we obtain a decision tree with a depth of 50. During training, the maximum entropy impurity reduction (information gain) strategy is used to select the optimal feature components. The entropy impurity at node \(N\) of the decision tree is \(i(N)\), and the information gain obtained by selecting features \(F_{i,j}\) is \(\Delta i(N)\), as follows:  
\[i(N)=-\sum_{j}P\big{(}L_{j}\big{)}log_{2}P\big{(}L_{j}\big{)} \tag{3}\]  
\[\Delta i(N)=i(N)-P_{L}i(N_{L})-(1-P_{L})i(N_{R}) \tag{4}\]  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**6-DOF Deviations** & **Mean** & **Standard Deviation** \\ \hline \(e_{x}\) & 0.452 m & 0.010 m \\ \(e_{y}\) & 0.371 m & 0.007 m \\ \(e_{z}\) & 0.019 m & 0.007 m \\ \(e_{\varnothing}\) & 0.021\({}^{\circ}\) & 0.400\({}^{\circ}\) \\ \(e_{\theta}\) & 0.008\({}^{\circ}\) & 0.393\({}^{\circ}\) \\ \(e_{\varphi}\) & 0.239\({}^{\circ}\) & 0.201\({}^{\circ}\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Statistics of 6 degrees of freedom deviations from 1500 sets of rendezvous and docking results of spacecraft dynamics simulation.  
where \(P(L_{j})\) indicates the frequency of samples belonging to the category \(L_{j}\) at the node \(N\) in the total number of samples, \(N_{L}\) and \(N_{R}\) are the left and right child node of \(N\), respectively, \(i(N_{L})\) and \(i(N_{R})\) are the corresponding impurities, and \(P_{L}\) is the probability that the tree grows from \(N\) to \(N_{L}\) when the feature \(F_{i,j}\) is selected.  
After training the decision tree, we further generate a test set of 150 samples and show the confusion matrix in Table 2. The classification error on this test set is 6%.