## 5 System Overview
### TWIN-ADAPT: Continuous Learning for Digital Twin-Enabled Online Anomaly Classification
Subsequently, the Hyperparameter Optimization function in Algorithm 2 iteratively tunes the thresholds and window sizes within a specified time limit. Specifically, the digital twin model integrates Particle Swarm Optimization (PSO) within its Hyperparameter Tuning function. This allows for the fine-tuning of key model parameters like window sizes and sensitivity thresholds. In customizing hyper parameters such as _windowSize_, _maxWindowSize_ and the detection thresholds (\(\gamma\) and \(\delta\)), TWIN-ADAPT can tailor the model's responsiveness by finding the optimal values of hyperparameters that can construct a highly accurate model. For each hyperparameter configuration space, the optimization function runs the continuous learning model function and evaluates the model's accuracy (lines: 3 to 10 in Algorithm 2). The highest accuracy achieved and the corresponding optimal parameters are stored and returned at the end of the optimization process to generate an optimization anomaly classification model for the CPS. Specifically, the parameters for optimization include the following:  
* **Drift detection threshold** (\(\gamma\)): This threshold is used to compare the accuracy of the current observation window (with the most recent _winSize_ samples) with the previous window (containing \(b-winSize\) samples from a batch of \(b\) samples). If the accuracy drops below \(\gamma\) times the previous accuracy, it indicates potential drift. Optimizing \(\gamma\) helps in accurately detecting when the data distribution changes. * **Adaptation threshold** (\(\delta\)): Once drift is detected, this threshold determines whether the model should be adapted. If the accuracy of the current window of the most recent samples drops below \(\delta\) times the previous accuracy, adaptation is triggered. Optimizing \(\delta\) ensures that the model adapts appropriately to maintain performance. A small adaptation threshold can lead to frequent retraining, harming the overall prediction performance because it causes the model to react too sensitively to minor fluctuations, resulting in a high false alarm rate. * **Window sizes** (_winSize_ and _winSizeMax_): The size of the observation window (_winSize_) and the maximum size of the adaptive window (_winSizeMax_) are crucial for the algorithm's performance. The observation window size affects how quickly changes in data distribution are detected, while the adaptive window size determines how much historical data are considered for retraining the model. A larger adaptive window size implies a greater capacity for the model to retain past information, while a smaller size facilitates quicker adaptation to recent changes. The _winSizeMax_ value sets the sensitivity to the forgetting rule, dictating when the adaptive window should be emptied, effectively resetting the model's memory. This strategic use of adaptive and sliding windows coupled with hyperparameter optimization makes TWIN-ADAPT an advanced system capable of maintaining the high standards required in smart laboratory operations. This approach allows the model to dynamically adapt to changes in data patterns, maintaining high prediction accuracy even in the presence of concept drift. By continuously monitoring performance and adjusting the model as needed, the algorithm ensures robust and reliable analytics for dynamic distributions in cleanroom environments.