# Machine Learning-Driven Calibration of Traffic Models Based on a Real-Time Video Analysis
## 4 Simulation Results of the SMTF Calibration Algorithm and Comparison of Results with PTS  
The intersection of Karl Marx and Sverdlov streets in Ufa was chosen as a simulated section for creating and calibrating the SMTF. The coordinates of the video surveillance camera at this location are latitude 54.725376 and longitude 55.940998. Using OpenStreetMap data, a SUMO model was developed with traffic parameters set to through traffic factor = 5 and count = 12. The initial simulation involved 5000 steps, divided into six parts to establish the SMTF and subsequent calibration during the initial simulation. For example, to extract an indirect parameter of vehicles, we chose the parameters of speed, time of signal transmission from the vehicle to the infrastructure object, and the vehicle's rotation angle relative to the geographic north. The simulated route area within a 600 m radius from the camera location was divided into 40 sectors using geohash coding (see Figure 7). Traffic speed trends were extracted using LOESS for the first 1600 simulation steps (Figure 8). After averaging the calculated values of \(\tau_{Sn}\), a time interval \(\tau_{S}\) of 60 simulation steps was chosen, approximating a minute of real time. In the subsequent five iterations generating new data from the SUMO model, the average global and local learning times were 3500 and 110 ms, respectively. Global SMTF calibration initialization occurred in 5 out of 70 drift tracking iterations, while local calibration was observed in 26 cases. After simulating the SMTF calibration, the model calibration was first tested based on data from an actual video stream of the PTS intersection. Of the 40 sectors in the new dataset, information was only available for 6 sectors in the center of the intersection. When initializing a new data drift monitoring cycle, global calibration of the model was not required due to a slight divergence in the trends of all parameters under consideration. Local calibration was initiated only for four sectors for the speed parameter, two for the signal transmission time parameter, and one for the rotation angle. Data obtained directly from a moving vehicle in the simulated area were recorded using a programmable microcontroller ELM327 from ELM Electronics, which supports OBD-II protocols [108], to monitor vehicle data in real time. The performance of the calibration system was assessed by comparing data from the ELM327 and data generated by the SMTF before and after SMTF calibration. Two methods were used to compare the data: assessing the degree of statistical elimination of drift in data from the SMTF relative to the PTS and assessing the performance of the ML regression model trained on the SMTF data to determine the positions of the main lobe of the radiation pattern for establishing communication between the V2I infrastructure object and the vehicle. Figure 8: Extracting global, seasonal, and random trends from vehicle speed time series. Figure 7: Division of the simulated area into sectors. To assess the statistical efficiency of SMTF calibration, the Kolmogorov-Smirnov (K-S) test was used, which is used to compare two samples to confirm that they belong to the same distribution [109]. The results of the K-S test show a decrease in the maximum absolute difference between the distributions of the video stream data and the calibrated SMTF compared to the original model trained on SUMO data. An example of the original velocity distribution obtained from the SUMO model, the velocity distribution from the PTS, and the distribution after model calibration are presented in Figure 9.  
Thus, the results of the average level of reduction in the maximum absolute difference between the distributions of vehicle parameters are:  
* For the signal transmission time from the vehicle to the infrastructure object, a reduction of 37.64% was reached;
* For vehicle speed, a reduction of 72.89% was achieved;
* For the angle of rotation of the car relative to the geographic north, a reduction of 49.27% was acquired.