# A Framework for Diagnosing Urban Rail Train Turn-Back Faults Based on Rules and Algorithms
## 5 Framework
### Diagnostic Type Classification
#### 5.2.3 Classifier  
Classification and regression trees (CARTs) can be applied to solve classification and regression problems. In the process of constructing a binary decision tree, a decision tree as large as possible is generated. During the traversal process, each node selects the best attribute to split in order to reduce its impurities [35]. The sample set of the parent node is \(A\), and CART selects feature \(B\) for splitting. The corresponding set is \(D_{1}\), \(D_{2}\). \[Gini(A,B)=\frac{|D_{1}|}{|D|}Gini(D_{1})+\frac{|D_{2}|}{|D|}Gini(D_{2})\]Finally, the smallest loss function is selected to prune it in order to prevent it from overfitting. The subtree \(X\) loss function is:  
\[F_{n}(X)=F(X)+\alpha|X|\]  
A random forest (RF) is a classifier composed of multiple decision trees. More precisely, a random forest is a strong classifier composed of multiple weak classifiers, and the output category is determined by the mode of the category output by the individual tree [22; 36]. Its advantage is that it can handle a large number of input variables and balance errors and, at the same time, produce unbiased estimates for generalized errors internally. The gradient boosting decision tree (GBDT) is an iterative algorithm composed of multiple decision trees. Its basic idea is that each tree learns the output and residuals (negative gradient) of all previous trees:  
\[F_{m}(a)=\sum_{m=1}^{M}T(a;\beta_{m})\]  
where \(T(a;\beta_{m})\) represents the decision tree, \(\beta_{m}\) is the parameter of the decision tree, and M is the total number of all decision trees. The loss is  
\[L[b,F_{m-1}(a)+T(a;\beta_{m})]=[b-F_{m-1}(a)-T(a;\beta_{m})]^{2}\]  
AdaBoost trains different weak classifiers and determines the best weak classifier through a threshold. Finally, the weak classifier from each iteration is constructed as a strong classifier. In this algorithm, the training of multiple classifiers gives it the advantages of flexibility and high accuracy. However, it also leads to the disadvantages of longer running time of the algorithm and sensitivity to abnormal samples. Taking binary classification as an example, the weighted error rate of the \(k\)-\(th\) weak classifier \(F_{i}(x)\) in the calculation is:  
\[\mathrm{e}_{i}=P(F_{i}(x_{j})\
eq y_{j})=\sum_{j=1}^{n}w_{ij}I(F_{i}(x_{j}) \
eq y_{j})\]  
The weight coefficient is:  
\[\alpha_{i}=\frac{1}{2}\log\frac{1-e_{i}}{e_{i}}\]  
The weight coefficient of the \(k+1\) weak classifier is:  
\[w_{i+1,j}=\frac{w_{ij}}{Z_{i}}\exp[-\alpha_{i}y_{j}F_{i}(x_{j})]\] \[Z_{i}=\sum_{j=1}^{n}w_{ij}\exp[-\alpha_{i}y_{j}F_{i}(x_{j})]\]  
The generated strong classifier is:  
\[g(x)=sign[\sum_{i=1}^{I}\alpha_{i}F_{i}(x)]\]  
A support vector machine (SVM) is an algorithm for finding the best classification hyperplane [37]. Its basic idea is to construct an objective function based on the principle of structural risk minimization to separate the two modes as much as possible. Its multi-objective function is also regarded as a kernel method. A linear kernel was used in this study:  
\[\mathrm{kernel}(\chi,\varepsilon)=\chi^{T}\varepsilon+c\]  
and radial:  
\[F_{n}(X)=F(X)+\alpha|X|\]0The optimization problem for a soft-margin SVM is expressed as follows:  
\[ \begin{array}{l}\min\limits_{a,j}\frac{1}{2}||a||^{2}+c\sum\limits_{i=1}^{X}F_{ i},F_{i}=\max[0,1-m_{i}(\alpha^{T}n_{i}+j)]\\ s.t.n_{i}(\alpha^{T}n_{i}+j)\geq 1-F_{i}\end{array} \]  
The principle of logistic regression (LR) is very similar to that of SVM. The difference is that SVM does not require any assumptions about data distribution. Logistic regression is a parametric model, which assumes that the data obey a certain distribution, as shown below:  
\[f(x)=h(\alpha^{T}x)=\frac{1}{1+e^{-\alpha^{T}x}}\]  
where \(\alpha\) is a parameter, and \(f(x)\) is the probability of \(y=1\) when \(x\) is a certain value.