## 5 System Overview
### TWIN-ADAPT: Continuous Learning for Digital Twin-Enabled Online Anomaly Classification  
TWIN-ADAPT integrates two pivotal algorithms: _Continuous Learning Model using Adaptive and Sliding Window (Algorithm 1)_ and _Hyperparameter Optimization for Continuous Learning Model (Algorithm 2)_. The former dynamically adjusts to changing data from cleanroom equipment sensors, while the latter fine-tunes the model settings using Particle Swarm Optimization (PSO) for optimal performance. The continuous learning strategy for real-time, adaptive anomaly detection in TWIN-ADAPT assigns a dedicated digital twin to each critical CPS component of the cleanroom laboratory. This empowers precise preventive monitoring and analytics under heterogeneous data distribution settings. Similar to many sequential learning algorithms, TWIN-ADAPT's adaptive and sliding window framework operates in two distinct phases: the offline learning phase and the online continuous learning phase. During the initial offline learning phase, a static classifier model (_LightGBM_) is trained on historical sensor data. In the subsequent online continuous learning phase, the pre-trained model's performance is continuously monitored. The model's performance metrics are compared against previous observations, and the model is updated using new concept data as they become available. The continuous learning algorithm (_Algorithm 1_) operates by monitoring the performance of a pre-trained model on incoming data and making adjustments as necessary to maintain the prediction accuracy. The algorithm utilizes a dual-window strategy that employs both adaptive and sliding windows. The sliding window is used for immediate change detection, while the adaptive window accumulates data necessary for retraining the models. The process begins by initializing an adaptive window _AdaptWin_ and setting the system _CurrentState_ to a normal state. As new data points arrive in a streaming batch of \(b\) samples, the last few samples from the batch are collected into an observation window _ObsWin_ consisting of a fixed size _winSize_ such that _winSize_ is a subset of \(b\), specifically designed to capture the most recent data points within the batch. The accuracy of the current observation window _ObsWin_ is compared with the accuracy of the previous window _PrevAcc_ consisting of \(b-winSize\) samples to detect any significant drops in performance between the consecutive windows. In the normal state, if the accuracy drops below a  
Figure 8: System overview of TWIN-ADAPT. defined threshold (\(\gamma\)), it indicates a potential drift, and the system transitions to a warning state (lines: 5 to 11). In this warning state, new data samples are collected into the adaptive window _AdaptWin_ (this process is illustrated in Figure 9). If the accuracy continues to drop further, confirming the drift (\(\delta\)), the model is updated using the samples in the adaptive window, and the system returns to the normal state after clearing the adaptive window (lines: 13 to 20). If the accuracy stabilizes before confirming the drift, indicating a false alarm, the adaptive window is cleared without updating the model, and the system returns to the normal state (lines: 21 to 24). The rationale behind aggregating samples in the adaptive window is to identify abrupt changes in the data while being able to ignore spurious drifts. This approach ensures that only significant and persistent changes trigger model updates, reducing the overhead of adaptations to minor or transient data variations. The algorithm also includes a state for monitoring the model performance in the drift state (State 2) to check if further adaptation is required. If the model reaches State 2, it continues to collect new samples to compute the accuracy of the current observation window _CurrentAcc_ and compare it with the accuracy from the drift starting point (new concept accuracy, _NewConceptAcc_).