## 4 Methodology
### Machine-Learning Model Development
#### 4.4.2 Classification Machine Learning Models  
Forecasting if C5 content is off specification is a challenging task given the strongly imbalanced data. Only 14 out of 167 measurements in _Unit A_ corresponded to such events in our particular use case, while no such events were registered in _Unit B_. In our research, we compared six models; two baseline models and four models that aim to provide better predictions:  
* **Baseline 1 (zero forecast)**: we predict no off-spec occurrence takes place;
* **Baseline 2 (LgR)**: logistic regression to predict C5 content based on raw temperature and pressure sensor measurements (P1 and T2 from Figure 1, described in Feature Group ID #1 at Table 3);
* **Model 1 (LgR)**: logistic regression considering raw sensor measurements of P1 and T2 sensors at fifteen-minute intervals (see Figure 1), and all features described in Table 3, for the time range as presented in Figure 3;
* **Model 2 (SVC)**: Support Vector Classifier [84], which takes into account most relevant features assessed over all created features;
* **Model 3 (MLPC)**: Multi-layer Perceptron Classifier [85], which takes into account most relevant features assessed over all created features;
* **Model 4 (CatBoost)**: a CatBoost classifier with a Focal loss [92], which provides an asymmetric penalization to training instances, focusing more on those that are misclassified. The model takes into account most relevant features assessed over all created features.  
We expect that most of the time, C5 content levels remain within the required specifications. Thus, predicting that no off-spec event takes place (_Baseline 1_) provides a realistic estimate that is accurate in all cases, except for a handful of cases where such an anomaly takes place. We expect the machine learning models to surpass such a baseline, showing they can accurately predict off-spec events, without introducing many false positives and negatives. The _Baseline 2 (LgR)_ and _Model 1 (LgR)_ were initialized with the same parameters, using a limited-memory Broyden-Fletcher-Goldfarb-Shannon solver algorithm [93; 94; 95; 96], along with a L2 regularization. In both cases, a class balancing strategy was used to weights classes inversely proportional to class frequencies. _Model 2 (SVC)_ was initialized with a radial basis function kernel and epsilon value of 0.1 and L2 regularization. We did not constrain the number of solver iterations. We initialized the _Model 3 (MLPC)_ with a single hidden layer of a hundred neurons, with a ReLU activation and Adam solver. We used a constant learning rate (0.001) and trained the model over 300 iterations, with a validation set obtained by random sampling 0.1 of the training set. Finally, the CatBoost model was initialized with a Focal loss, growing asymmetric trees, a depth of six nodes, and a maximum number of 64 leaves. We trained the model over a thousand iterations, with a learning rate of 0.0299 evaluating against the AUC ROC metric. In all cases, we standardized features by removing the mean and scaling them to unit variance.  
When building the classification models, we avoided using features based on past C5 measurements to ensure the models consume only data that can be provided in real time, and thus issue real-time forecasts.