## 2 Materials and Methods
### Methodology
#### 2.2.3 Training and Test of the KPCA Monitoring Model  
The two final steps of the methodology, i.e., the training and the test of the KPCA monitoring model, tend to be similar and it is therefore useful to comment on them together. The expression \"training\" refers to the part in which the model is trained using data extrapolated from the operating machinery under normal conditions, aimed at defining the control thresholds of the process. Consequently, as shown in Figure 2, it should be pointed out that the training part of the model was performed in each of the tested combinations using only data representative of a healthy state of the machine in order to correctly calculate the thresholds of \(T^{2}\) and \(Q\)[26]. On the other hand, the expression \"test\" describes the actual process monitoring, i.e., the analysis of process data based on the thresholds previously defined, when it is still not known whether the data fed into the model are healthy or faulty. Throughout this step, the most suitable kernel for the monitored process is defined. In general, it is crucial to obtain the following information to implement the training and testing phases:  
* \(p\) and \(f\) value, based on the autocorrelation function results
* Matrices of past and future measurements, calculated from the values identified for \(p\) and \(f\), for both the training and test datasets
* Kernels identified as possibly suitable for the process to be monitored  
The third point is the most demanding. In fact, while the first two points are a simple application of algorithms with an output that is easy to interpret and ready to use, the third point requires a different approach to define the most suitable kernel for the monitored process, as well as the parameters to be set in the kernel. For the definition of the most suitable kernel, the following approach was adopted: after the definition of \(p\) and \(f\), with the consequent calculation of the matrices of past and future measurements, these two steps of the methodology were considered defined and immutable. Moving on to the choice of the kernel, several kernels were selected based on the literature review, as indicated in Section 2.2. Subsequently, all the selected kernels were applied, both in the training and testing phases, with different settings to identify the most suitable kernel and, consequently, the best setting to monitor the analyzed reverse osmosis process. After identifying the kernel to be applied, the different combinations of past and future matrices for both the training and test phases were tested. For the sake of completeness, the logical path that led to the definition of the combinations tested will be explained in the following section of this contribution. Furthermore, five tests were performed with five different combinations of past and future measurement matrices for the training part and the testing part, i.e., for the real monitoring part of the process. First of all, it was ascertained that within the representative data of a state of health it was possible to identify a trend of degradation, traceable in the same way in the actual monitoring data of the process. This led to the development of the first test, in which the search for this trend of degradation of the machinery resulted in the sole use of the matrices of past measurements both to train the model and subsequently to monitor the process concretely. The two additional implemented tests, for which further and more detailed explanations will be given in the next section, were based on the idea that it is possible to identify unexpected oscillations that allow for the identification of the onset of a fault by jointly analyzing the matrix of past and future measurements. This hypothesis led to an analysis whether or not the difference between the matrix in future and past measurements could be a good input for monitoring with the KPCA.