# Fault Detection, Diagnosis, and Prognosis of a Process Operating under Time-Varying Conditions
## 4 Case Study
For the sake of completeness, it should be noted that the authors implemented a test for the prediction of the remaining useful life of machinery without the inclusion of the last variable considered, i.e., \(x_{6}\), and the obtained the results were not acceptable. According to the information obtained using contribution plots, i.e., the six variables selected, five prognosis models were developed, one for each sub-interval considered. While for the extraction phase of the process trend's most representative variables the sub-intervals were considered to have common characteristics, for the prognosis phase, the subgroups were again considered as separate, in light of the experience acquired through fault detection. To implement this phase, regression machine learning algorithms were applied, specifically approaching the learning ensemble. As far as statistics and machine learning are concerned, ensemble methods use multiple learning algorithms to achieve better predictive performance instead of using constituent learning algorithms alone. The methods selected for this phase consisted of decision trees. In retrospect, after the analysis and after tests with other algorithms, it is possible to say that this category was the one that guaranteed the best results. Following numerous tests and numerous optimizations of the algorithms, the superiority of the results achievable with the bagged trees was proven. Bagged trees have also been proven to be suitable for prognosis in the presence of datasets that are not considered to be large in size, making them appropriate for this study. In Bagging (Bootstrap Aggregation) several models of the same type are trained on different datasets deriving from an initial dataset obtained by random sampling with replacement, reducing the variance of a decision tree. Firstly, several subsets of data are created from a randomly chosen training sample with replacement. Then, each collection of subset data is used to train its decision trees. Finally, the obtained result is an ensemble of different models, and the average of all the predictions obtained from different trees is used. This process is more robust than a process that uses single decision trees since individual decision trees tend to overfit. Bootstrap-aggregated (bagged) decision trees combine the results of many decision trees, thus reducing the effects of overfitting and improving generalization. Every tree in the ensemble was grown on an independently drawn bootstrap replica of input data, and the observations not included in this replica are \"out of the bag\". The number of features was selected randomly for each decision split, so it is possible to assert that the algorithm selected was the random forest algorithm [39]. The evaluation metrics considered were as follows:  
* \(R^{2}\): it is the coefficient of determination and represents the ratio of the variance in the dependent variable that is predictable from the independent variables. * **MEAN SQUared ERROR (MSE):** it is a frequently used measure of the differences between values predicted by a model and the values observed \(\rightarrow\frac{\sum_{i=1}^{n}|y_{i}-y_{i}|}{n}\)  
The first one, i.e., \(R^{2}\), provided an insight into the quality of the predisposed model, as it allowed understanding to what extent it represents reality. The second one, i.e., MSE, allowed giving greater weight to large mistakes rather than to smaller ones. This metric was extremely important in the analysis under consideration, since the need to penalize large errors was particularly relevant. In conclusion, it should be noted that there was no parallelism between the results of the two phases, i.e., the subgroup with the best results for fault detection was not the best for the prognosis.