# Rolling-Element Bearing Fault Diagnosis Using Advanced Machine Learning-Based Observer
## 4 Proposed Algorithm for Fault Diagnosis in Rolling-Element Bearing
### Fault Detection and Fault Identification Based on Decision Tree Technique
#### 4.2.2 Decision Tree-Based Fault Diagnosis  
Once the windows of residual signals have been characterized using the energy feature parameter, these feature parameters are fed into the classifier, which is made using the DT. DT [40], as well as random forests (i.e., the ensemble of DTs) [43; 44], is a type of machine learning technique that can perform both the classification and regression tasks while their decisions are fairly intuitive and easy to interpret. Because of their properties, decision trees are considered as white-box models; they automatically derive general classification rules that work well for the data given in the training set based on the specific attributes (i.e., feature parameters). Moreover, these obtained decision rules can be efficiently used manually for classifying different samples if necessary.  
During training of the DT to perform fault detection and identification, the heuristic criteria that is based on the error and is called the Gini Diversity Index (GDI) [45], also known in the literature as the Gini Impurity, is applied in this paper. The main advantage of employing the GDI criterion is that the DTs trained with this metric tends to isolate the most frequent data class in its branch of the tree which is useful for evaluating the quality of features in training set and their separability.  
The GDI is defined as follows:  
\[GDI_{i}=1-\sum_{k=1}^{n}{P_{i,k}}^{2}. \tag{34}\]  
where \(GDI_{i}\) is the Gini score for the \(i\)th leaf of the DT, \(n\) is the total number of classes (i.e., bearing faults) presented in data, and \(p_{i,k}\) is the ratio of the instances belonging to class \(k\) among all instances in the \(i\)th leaf.  
The training procedure of the DT can be summarized as follows. Given a specific feature parameter and GDI criterion, the training goal is to find a split for the features that induces a binary partition of the set of data samples with a minimum GDI criterion, where the weights of this criterion are given by the number of data samples that lie in each of the two branches [46]. The leaf node is said to be \"pure\" when all training samples it applies to belong to the same class. Finally, after the training of the DT with the energy values extracted from the windows of residual signals is completed, we obtain a set of rules for differentiating various bearing conditions. This set of rules is based on the threshold values automatically learned by the DT to minimize the weighted sum of Gini scores of the DT leaves. After completing the training process, the new data sample can be simply classified by tracing out a route from the root to one of the leaves of the tree while comparing the energy value with the learned threshold values for each of the leaves. In this paper, the number of assigned leaves is similar to the number of signal classes presented in the dataset, which is equal to four. Equations (35) and (36) are used to formulate the respective fault detection and fault diagnosis based on the DT algorithm.  
\[\left\{\begin{array}{l}if\ E<\zeta_{n}\to Normal\\ if\ E\geq\zeta_{n}\to Faulty\end{array}\right. \tag{35}\]  
\[\left\{\begin{array}{l}if\ E\geq\zeta_{n}\&E<\zeta_{b}\ \&\ E<\zeta_{i}\to Ball \ Fault\\ if\ E\geq\zeta_{n}\&E\geq\zeta_{b}\ \&\ E<\zeta_{i}\to Inner \ Fault\\ if\ E\geq\zeta_{n}\&E\geq\zeta_{b}\ \&\ E\geq\zeta_{i}\to Outer \ Fault\end{array}\right. \tag{36}\]  
Here, \(\zeta_{n},\zeta_{b},\) and \(\zeta_{i}\) are the normal condition threshold, ball fault condition threshold, and inner fault condition threshold, respectively. The proposed DT-based AFSMO for bearing FEDI is summarized in Algorithm 1, and an example of the DT trained using the energy values extracted from the residual signal windows for 0.021 inches crack size condition under 3 hp torque load is presented in Figure 9.