# A Fault Diagnosis Method of Mine Hoist Disc Brake System Based on Machine Learning
## 4 Decision Tree Classification Method
### Algorithm Implementation  
The actual calculation process described below provides details about the implementation process of K_C4.5 algorithm optimization. Table 3 is the sample data set.  
As can be seen from Table 3, there are three attribute values in the condition attributes A, B, and D: 1, 2, 3, and C have two attribute values: 1, 2. There are two attribute values in the decision attribute F: 0,1. According to the attribute values in the table, the coefficient \(W\) is first calculated, then the gain rate of each attribute is calculated with respect to the formula (12). After that, the decision tree is constructed according to the gain rate. The detailed steps are as follows:  
First, each attribute is evaluated according to the rating method. Assuming that the grade of 0 in the decision attribute F is higher than 1, then the probabilities that the three attribute values in A are obtained as: \(P(A_{1})=\frac{1}{6}\), \(P(A_{2})=\frac{1}{2}\), and \(P(A_{3})=\frac{1}{3}\). Obviously, \(P(A_{2})>P(A_{3})>P(A_{1})\). Similarly, we can get \(P(B_{2})>P(B_{3})>P(B_{1})\) in attribute B, \(P(C_{2})>P(C_{1})\) in attribute C, and \(P(D_{1})>P(D_{2})>P(D_{3})\) in attribute D. The results of grade evaluation are shown in Table 4.  
Then, Calculate the coefficient \(W\) by using Equations (6) and (7) according to the data in Table 4.  
Calculate the sum of the first line of conditional attribute values as:  
\[R_{1}=5.5+3.0+4.0+3.0=15.5\]  
\begin{table}
\begin{tabular}{c c c c c c} \hline \multirow{2}{*}{**No**} & \multicolumn{4}{c}{**Condition Attribute**} & \multicolumn{2}{c}{**Decision Attribute**} \\ \cline{2-6}  & **A** & **B** & **C** & **D** & **F** \\ \hline
3 & 2 & 3 & 2 & 1 & 0 \\
4 & 2 & 1 & 2 & 2 & 0 \\
5 & 1 & 2 & 1 & 2 & 1 \\
6 & 3 & 2 & 2 & 3 & 0 \\
7 & 3 & 3 & 2 & 1 & 1 \\
8 & 1 & 2 & 2 & 1 & 0 \\
9 & 2 & 2 & 1 & 1 & 0 \\
10 & 3 & 3 & 2 & 2 & 0 \\ \hline \end{tabular}
\end{table}
Table 3: Sample data set.  
Similarly, the values of the other rows are \(R_{2}=37\), \(R_{3}=16\), \(R_{4}=22.5\), \(R_{5}=28\), \(R_{6}=22\), \(R_{7}=19.5\), \(R_{8}=19\), \(R_{9}=17\), \(R_{10}=23.5\).  
According to formula (8):  
\[T_{1}=\sum\limits_{i=1}^{m}\frac{n_{i}^{3}}{12}=\frac{3^{3}-3}{12}+\frac{3^{3} -3}{12}+\frac{4^{3}-4}{12}=9\]  
In the same way, \(T_{2}=12.5\), \(T_{3}=30\), \(T_{4}=12.5\). Thus,  
\[W=\frac{\sum\limits_{i=1}^{K}R_{i}^{2}-\frac{\left(\sum\limits_{i=1}^{K}R_{i} \right)^{2}}{N}}{\frac{1}{12}K^{2}(N^{3}-N)-K\sum\limits_{i=1}^{N}T_{i}}=\frac {\left(15.5^{2}+37^{2}+\ldots+23.5^{2}\right)-\frac{\left(15.5+37^{+}\ldots+23.5\right)^{2}}{10}}=0.359\]  
The information gain of each attribute is calculated by formula (10):  
\[\sum\limits_{k=1}^{K}\frac{C_{k}\times(N-C_{k})}{N}=\frac{6\times(10-6)}{10}+ \frac{4\times(10-4)}{10}=4.8\]  
\[\begin{array}{l}W\times\sum\limits_{i=1}^{n}\sum\limits_{k=1}^{K}\frac{C_{k} \times(N_{i}-C_{k})}{N_{i}}\\ =0.359\times\left(\frac{1\times(3-1)}{3}+\frac{2\times(3-2)}{3}+\frac{2\times (4-2)}{4}+\frac{2\times(4-2)}{4}\right)\\ =1.197\end{array}\]  
\[\begin{array}{l}\sum\limits_{i=1}^{n}\frac{N_{i}\times(N-N_{i})}{N}=\frac{3 \times(10-3)}{10}+\frac{3\times(10-3)}{10}+\frac{4\times(10-4)}{10}\\ =6.6\end{array}\]  
\[\begin{array}{l}\mathit{Gain}(A)=\frac{4.8-1.197}{6.6}=0.546\end{array}\]  
Analogously, the gain rates of several other attributes are given as \(\mathit{Gain}(B)=0.5\), \(\mathit{Gain}(C)=0.785\), and \(\mathit{Gain}(D)=0.5\). Since \(\mathit{Gain}(C)>\mathit{Gain}(A)>\mathit{Gain}(B)=\mathit{Gain}(D)\), condition attribute \(C\) should be selected as the root attribute.