# A Real-Time Novelty Recognition Framework Based on Machine Learning for Fault Detection
## 3 Proposed Predictive Maintenance Architecture
### AI Unit
Thanks to the windowing approach, each window is used to perform computation by condensing the initial amount of data (a cumulative sum is used for each window in this paper). The mathematical representation of the windowing function and cumulative absolute sum for each window is reported below:  
\[[x_{1},x_{2},\ldots,x_{n}]-> \begin{cases}[x_{1},x_{2},\ldots x_{m}]\;with\;m< n\\ [x_{m+1},x_{m+2},\ldots x_{m+k}]\;with\;m<m+k<n\\ \ldots\\ [x_{m+k+1},x_{m+k+2},\ldots x_{n}]\end{cases} \]  
While the cumulative absolute sum function used is the following:  
\[ \begin{cases}[x_{1},x_{2},\ldots x_{m}]\\ [x_{m+1},x_{m+2},\ldots x_{m+k}]\\ \ldots\\ [x_{m+k+1},x_{m+k+2},\ldots x_{n}]\end{cases} \]  
Figure 5: Features selection. The feature extraction and labeling phase follow the preprocessing stage. This block is responsible for preparing data for the following ML model training. With a multi-threading approach, a feature is extracted from the dataset by converting it to a label; this procedure is done for each window/feature, creating a number of labels equal to the number of windows and predictors. This rule is schematized in the following figure:  
At the end of the preprocessing stage, a number of trainsets equal to the number of windows are created; each trainset is used for the related ML model training. Then, the testing phase follows the training one. The same preprocessing approach is applied to each new dataset; in the end, the label related to \(i_{th}\) model is predicted and compared with the real one, computing the error used for novelty detection. Hence, the AI Unit can be divided into two different macro-stages:  
* The first part is related to the training process in which the system waits for a predefined number of data to train the models;
* The second part is the testing process in which incoming data are continuously tested to compute the predictions' error results. For the Training phase, three regressors are tested to visualize the potential differences in the prediction behavior. The models used during the evaluation are:  
* Linear Regressor;
* Decision Tree Regressor;
* Random Forest Regressor. The \"Low Lubrication Case\" of the \"Digital Model\" (better explained in the following paragraph) is used as a representative example to see how the mentioned models work in order to compare them. Generally, a system works always in the same way: at the beginning of life, when it is healthy, the error computed by the model's prediction is low; when the failure appears, the error's prediction starts to increase. A further confirmation that a general system works in this manner is shown in Section 5 in which the real cases behave exactly like the digital model used for the proof-of-concept, starting with a low error that increases at the end of the life when the failure appears. This general  
The results obtained by comparing the three models are almost identical. In the Linear Regressor model, the y-scale has a lower variance in terms of the range in which the error can span, while in the other two models, the y-scale range is almost the same. The user can choose one of the three models with no particular weakness; generally, the tree models have better accuracy than the easier Linear Regressor, but this one has the advantage of being faster when the training process is performed. Decision Tree Regressor and Random Forest Regressor work similarly from a general point of view: the former works only with decisions while the latter works with decision trees. The main difference between them concerns the accuracy obtained and the computation's complexity: a Decision Tree Regressor has lower computational complexity and accuracy than a Random Forest Regressor.