## 2 Methodology
### Departmental and Interdepartmental Inference Modules: Architecture, Operation, and Justification
#### 2.3.2 Interdepartmental Inference Module  
The interdepartmental module aggregates the outputs from the departmental modules. It employs a random forest algorithm to analyze the combined data, specifically correlating predictions and quality labels from earlier stages (such as steel mill and logistic) with the final quality outcomes observed in later stages (like rolling mill). This module uses ensemble methods to compute the importance of various features and to determine which preceding factors most significantly contribute to defects at later stages in batches of the chosen size as shown in Figure 10. With the departmental module, we know the relevant features for the final label in each stage, but the aim of the interdepartmental module is refining the departmental module by differentiating the bad labels at every stage that have no reason with the variables of the stage itself. Applying techniques such as SHAP (SHapley Additive exPlanations) to render the decision process of the random forest interpretable  
Figure 9: Flow chart of the department module operation.  
allows for us to determine if the most relevant variables for the bad labelling come from the current stage or from a previous stage, thereby highlighting the key variables that drive quality outcomes.  
Random forests were selected for their robustness in handling heterogeneous and high-dimensional data, but the main reason of the choice was the ability to interpret the main features that drive the decision-making [22; 23]. The ensemble approach reduces overfitting and enhances generalization, which is essential when linking subtle sensor anomalies from early stages to downstream quality issues. Moreover, the interpretability of random forests through feature importance and SHAP values enables process engineers to understand the root causes of defects. This is crucial for not only verifying model predictions but also for supporting operational decision-making and continuous process improvement.  
In this module, the architecture is basically a random forest model built with XGBoost, which uses some predefined parameters by defect (estimators \(\rightarrow\) 1000, learning rate \(\rightarrow\) 0.001, early stopping rounds \(\rightarrow\) 100, evaluation metric \(\rightarrow\) \"auc\"), but the hyperparameters can be improved for every batch through an optuna library implementation option. If we enable this option, the process becomes much slower, but it improves the results. This interdepartmental module is capable of running on a mid-range computer, but depending on the size of the batches and whether we use the optimization function, the process can become very slow. The speed in processing the data is not a problem, since the interdepartmental inference is performed once the lamination process is finished, and we need to produce an entire batch of product to analyze it.  
Each module's architecture was deliberately chosen to address specific aspects of the problem.  
* For departmental inference, the combination of LSTM and MLP networks enables temporal forecasting and complex decision emulation, respectively. The LSTM component isolates and predicts trends in sensor data, while the MLP integrates these predictions with event signals to generate anticipated quality labels.
* For interdepartmental inference, the random forest-based module synthesizes data across departments to reveal causal relationships between early-stage anomalies and final product quality. Its ensemble structure and interpretability ensure that the system's diagnostic conclusions are both robust and actionable.  
In essence, these architectures were selected because they provide a modular, scalable, and interpretable framework. They not only replicate human expert decisions but do so in a manner that anticipates potential quality issues, thereby allowing for proactive interventions that improve overall efficiency and product quality.  
Figure 10: Flow chart of the interdepartmental module operation.