# Fault Detection, Diagnosis, and Prognosis of a Process Operating under Time-Varying Conditions
## 4 Case Study
#### Prognosis Models  
For the part concerning the prognosis, a model was developed for each of the considered sub-intervals, as previously conducted in the fault detection models [5]. Furthermore, algorithm optimization was implemented to define the algorithm parameters. This means that various combinations of parameters were tested in an automatic way to identify the one that would allow obtaining the best achievable results. The metric taken into consideration to select the best configuration was the MSE. In particular, the best setting was the one that guaranteed the lowest value. As well as in the previous phase, the prognosis models were developed using MATLAB. As previously mentioned, five bagged tree models with different combinations of parameter settings were trained and tested, and three parameters were optimized:  
* Number of learners: Number of trees. * Minimum leaf size: Minimum number of observations per tree leaf. * Number of predictors to sample: Number of variables to be selected at random for each decision split. The number of iterations performed for the optimization of each model was 50, since several experiments showed a flattening of the improvements. Table 1 presents the best settings for all the considered models:  
The metrics selected for each interval were then used to predict the residual useful life of the machinery in the five sub-intervals under consideration. The results obtained are shown in Figures 4-6. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Interval** & **Number of Learners** & **Minimum Leaf Size** & \multicolumn{2}{c}{**Number of Predictors to Sample**} & **MSE** \\ \hline A & 500 & 1 & 3 & 258.46 \\ B & 500 & 1 & 4 & 1504.6 \\ C & 500 & 1 & 5 & 463.42 \\ D & 500 & 1 & 5 & 433.46 \\ E & 85 & 1 & 6 & 843.12 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Best settings for the algorithm in every considered interval. Figure 4: Prediction trend for interval A (**left**) and B (**right**). Figure 5: Prediction trend for interval C (**left**) and D (**right**). Figure 6: Prediction trend for interval E.  
Figures 4-6 represent the trends of the prediction of the RUL for all the analyzed intervals. This highlights the relationship between the predicted value of the RUL on the \(y\)-axis and the actual value of the RUL, on the \(x\)-axis. To analyze the obtained results, in addition to the previously mentioned MSE value (see Table 1), the \(R^{2}\) metric was considered. As previously described, this metric represents the extent to which the model can accurately represent actual operational data. The closer the value is to 1, the higher the model accuracy; on the contrary, values close to 0 represent an inaccurate model. The \(R^{2}\) values of all the intervals were as follows:  
* Interval A: 0.94;
* Interval B: 0.96;
* Interval C: 0.98;
* Interval D: 0.93;
* Interval E: 0.97. It was noted that the algorithm was able to satisfactorily approximate the actual operations considered, demonstrating good predictions of the RUL. Although in some of the analyzed intervals the results were slightly lower than relative to other cases, the overall results were considered to produce substantially favorable outcomes. The lowest forecast value obtained was 0.93. However, the analysis of forecasting trends allowed extrapolation, strengthening the analysis of the results obtained. Evidence from Figures 4-6 reveals that the number of errors detected was low relative to the total number of cases examined and predicted. This observation offered important considerations on the combined use of fault detection, diagnosis, and prognosis, and it also allowed evaluations to manage forecasting errors. By looking at the presented data, it was observed that the errors reduced as the prediction time window increased. For this purpose, due to the need to break the dataset into sub-intervals both in the fault detection phase and for the prognosis phase, it was not possible to define a univocal threshold for all the sub-intervals.