## 7 Classification of Failures  
After the preparation of our data, we thought of classifying the data, either continuous or discrete, into clusters that represent the types of failures. Indeed, this step allows maximizing the chances of the machine learning algorithms predicting a failure since it makes the step of learning a type of failure easier than if we opted to predict several different types of failures with different causes. To accomplish this, we used the K-means algorithm, a partition-based cluster analysis technique. It is frequently utilized in cluster analysis because it is more effective, scalable, and quickly converges when working with large data sets [29]. The elbow method, which involves looking for the point that represents the elbow in a graph that shows the sum of the squared distances between the points and the centers of the clusters to which they belong as a function of the number of clusters chosen, was used to determine the optimal number of clusters K for our dataset [30]. The results are presented below (Figure 9). Therefore, we know that K optimal = 3, and we then applied K-means to have three clusters. Table 2 shows the percentage of each cluster. In order to facilitate the resolution of the problem, we followed a precise methodology to achieve our objectives. After the classification of the failures, we defined three steps for the prediction:  
First failure prediction method: prediction of the compressor degradation state (four states: transient to critical);  
Second failure prediction method: prediction of the arrival in X hours or method of fixing X (if it is true, there is the arrival of a failure in X hours, and if it is false there occurs no failure in X hours or less);  
Figure 8: The data set for training and testing. \begin{table}
\begin{tabular}{l l l l} \hline  & **Cluster 0** & **Cluster 1** & **Cluster 2** \\ \hline Continuous Variables & 84.36\% & 4.87\% & 10.76\% \\ Discrete Variables & 10.9\% & 82.13\% & 6.95\% \\ \hline \end{tabular}
\end{table} 
Table 2: K-means results. Figure 9: Result of the elbow method for continuous variables (**left**) and for discrete variables (**right**). Third failure prediction method: prediction of the remaining useful life before failure (RUL). - First method of failure prediction: State degradation This method consists of breaking down the state in the interval between two failures into four states: \"0\" for the steady state where the compressor is working well, \"1\" for the transient state, \"2\" means the degraded state, and \"3\" represents the critical state that leads to the fourth state of the failure (Figure 10). To degrade these states, the hierarchical clustering method was used. The latter is a top-down approach where the intervals between failures are treated as a large cluster and the clustering process consists of dividing the large cluster into several smaller clusters. For our case we had five clusters. - Second method of failure prediction: Fixing X hours before the failure occurs This method involves the calculation of the probability that the compressor will fail in the next X hours. For this purpose, we set \"1\" as the state of the failure and for X hours and \"0\" for the other records. In our case, we tried to predict the X hours that vary between 24 and 500 h in advance. The figure (Figure 11) below shows an example of cluster 2 of the discrete type for X = 90 h before the arrival of the failure. - Third method of failure prediction: Remaining life This method is the most widely used in research [28]. Indeed, the remaining useful life is the duration during which the compressor is likely to operate before it requires a  
Figure 11: Example of the fixing method for X = 90 h for the 2-discrete cluster. Figure 10: Degradation of the compressor condition. repair or a replacement. In this sense, we created two other variables: RULA and RULB, which are those we want to predict.