# Machine Learning-Driven Calibration of Traffic Models Based on a Real-Time Video Analysis
## 2 Analysis of the Influence of the Dynamics of the PTS on the Operation of the VTS
### Scheme of Operation and Calibration of the SMTF  
As discussed in the Introduction, traffic flow variations are primarily influenced by changes in traffic density over space and time globally (across the entire study area) and locally in specific areas, such as hybrid systems that combine macroscopic and mesoscopic models. This leads to the evolution of the SMTF by transitioning from analyzing a macroscopic model of a controlled route area to studying changes in various sectors across a given territory over time. The interaction system between the PTS and the VTS, as shown in Figure 3 (Appendix A, Figure A1), includes an initial simulation model implemented in SUMO, divided into sectors with initial global and several local patterns of SMTF timing characteristics. It also incorporates a monitoring system to track the updates of these global or local patterns. Figure 3 illustrates the iterative process of calibrating global and local SMTFs. Once the route graph is divided into sectors, an initial temporal dynamics pattern is established through three stages. The first stage involves initializing simulation modeling in SUMO, where fixed parameters are gathered in general and local databases for each sector. The accuracy of the global ET model output and SMTF SUMO data is at least 85%. The second stage focuses on extracting the global time trend of \(Y_{n}(t)\) for each of the \(n\) fixed parameters using a statistical method called seasonal trend decomposition using locally estimated scatterplot smoothing (LOESS) [99]. By decomposing the time series of fixed parameter dynamics into seasonal \(S_{n}(t)\), trend \(T_{n}(t)\), and residual \(R_{n}(t)\) components, we can pinpoint the trend of the parameter \(T_{n}\) and the seasonal component \(S_{n}(t)\). These components set the statistical proximity boundaries within which the calibration process of SMTF does not commence. \[Y_{n}(t)=T_{n}(t)+S_{n}(t)+R_{n}(t) \tag{1}\]  
The resulting trend \(T_{n}\) is the foundation for training the global regression model. Additionally, the average duration of seasonal deviations \(\tau_{S}\) was determined, representing the period during which \(S_{n}(t)\) values exceed half of its maximum value \(\max(S_{n}(t))\). Figure 3: Iterative process for calibrating global and local SMTF models. The regression model was chosen based on three key criteria: high accuracy for variables with varying dynamics periods, computational complexity impacting training and retraining speed, and noise resistance to random short-term processes on the route. The extra trees regressor (ET) algorithm was selected for the simulation because it met these criteria [100]. As ET is an ensemble algorithm, a method was employed to adjust trained models considering regional drift to accelerate retraining [97]. This involved updating models by incorporating new classifiers trained on new data while removing some older ones until reaching the desired accuracy threshold on the test sample selected during the calibration stage. One advantage of ET is that it utilizes the average prediction from all trees in the ensemble, potentially reducing model variance compared to other ensemble algorithms when dealing with noisy data. Additionally, introducing an extra random process in selecting input parameter split points enhances data noise robustness [101]. The third stage involves constructing the initial template of each cluster's dynamics through additional local training on the global ET model using the described ML model adjustment method within the local database of each sector. The implementation diagram for training local models when calibrating the global SMTF model is shown in Figure 4.  
Subsequently, the SMTF transitions into run mode while the data drift monitoring system continuously compares fixed parameter distributions over time. The SMTF generates data from ET models, allowing the calibration process to operate simultaneously.