Machine learning-based adaptive traffic prediction and control using an edge impulse platform

Machine Learning


The proposed study addresses a large gap in the existing literature on traffic signal control. The literature focuses primarily on optimizing traffic timing through rule-based or reinforcement learning methods, but the proposed approach introduces a new dimension in traffic management. Unlike traditional systems, the proposed methodology employs proximity sensors strategically located far from traffic signals/junctions to autonomously detect vehicles and speeds during approaches. Additionally, edge impulse-based machine learning models are integrated to accurately predict both vehicle speed and vehicle arrival times. This combination of sensor technology and machine learning distinguishes our work from the predominantly rule-based approaches discussed in the literature. This allows real-time, data-driven traffic control that can be adapted to dynamic traffic scenarios. We believe this approach can significantly reduce congestion and delays, but it can also increase road safety by minimizing human intervention. The goal is to reduce waiting times and ideally not provide stops near vehicle traffic lights. You can control the signal based on predictions. Therefore, the predictive model is designed and developed using Edge Impulse Studio.11 The Arduino IDE takes into account traffic in 18 input features and 7 output classes for predicting junction traffic. The neural network is shown in Figure 1.

Figure 2
Figure 2

Methodology of the proposed model. A detailed, step-by-step approach to the processes and methods used to develop traffic forecasting models.

The proposed algorithm

The process flow of the proposed method is explained in Algorithm 1 and is shown in Figure 2. The training process begins with the design of a neural network model configured to efficiently classify traffic density into seven different output classes: “Zero Vehicle”, “One Slow Speed ​​Vehicle”, “One Medium Speed ​​Vehicle”, “One Speed ​​Vehicle”, “Two Medium Speed”. The neural network architecture implemented using the Tensorflow and Keras libraries consists of three dense layers with specific activation RELUs in the first two layers and Softmax in the output layer that is optimally designed for classification tasks. These layers are tailored to handle 18 input functions representing sensor data to extract meaningful patterns related to traffic scenarios. The optimization of hyperparameters, including a learning rate of 0.0005 and a batch size of 32, ensures effective training. A batch logger callback has been added to monitor training progress, and the model is trained with a specified number of epochs (\(n = 1700 \)). During training, the algorithm provides the option to control the per-channel quantization. This can reduce RAM usage at a potential cost of accuracy if disabled. The trained model is ultimately returned as output.

Algorithm 1
Figure a

Training neural network models with Tensorflow/Keras

The algorithm begins with the definition of a sequential neural network model containing three dense layers. The first two density layers have 20 and 10 units, respectively, each with Relu activation and regularization to avoid overfitting. The output layer consists of seven units and supports seven output classes. Adam Optimizer is initialized with learning rate \(\alpha = 0.0005 \)ensuring stable and efficient convergence during training.

Table 1 Hyperparameter settings for the proposed model.
Table 2 Data collection and labeling.
Figure 3
Figure 3

Impulse modeling procedure. 1 is a diagram of the steps involved in impulse response modeling for signal processing.

Generating spikes in time samples is useful for estimating the speed of the vehicle. Two-vehicle analysis is replicated due to the extremely dense traffic of multiple vehicles. The process steps used for modeling are shown in Figure 2. The process includes importing libraries, configuring hyperparameters, preparing datasets, and defining neural networks with 18 input functions and 7 output classes. The model is training (80%) and testing (20%) with optional per-channel quantization to optimize edge device performance. Analyze the proposed model using tensorflow, Keras model, and Keras optimizer libraries. The hyperparameter settings are shown in Table 1. Preprocessing methods are used to prepare training and validate datasets. As shown in Figure 1 and Table 2, a neural network of 18 input features with 20 density layers is used to extract the seven output classes.

The extracted output is optimized with the help of various optimizers, as shown in Figure 2. Edge Impulse Studio11 It is used to train models for computer analysis using built-in machine learning. The platform chosen for its robust support for TINYML workflow, efficient model optimization, and seamless integration with real-world sensor data is in line with research objectives. To train the model, the dataset is split into two buckets. This is the training set used to train the algorithm and the test set used to ensure that the algorithm is functioning properly. 80% of the data samples are used for training and 20% of the data samples are used for testing. Finally, the accuracy of the proposed method analyzes the per-channel quantization. The detailed code is attached to the Supplementary Materials. The proposed work uses the Edge Impulse Studio platform to model the traffic forecasting system. As shown in Figure 3, this process is divided into four steps. The steps are explained in more detail in the subsections below.

Create an impulse

Time samples are used to generate time series data. Duration between consecutive data points in a time series is an important factor to consider when analyzing and predicting time-based data. Input shaft (6) Red, green, blue, brightness, proximity, gesture. These features are measured by onboard IMU sensors and used as inputs to machine learning models.

A window size with a time interval of 2000 ms is taken to analyze the data. Longer time intervals are taken due to large collections of data. A window increase of 1000 ms has been adopted for smooth estimation. A 50 Hz frequency is used to determine the appropriate window size, evaluate the stability of the model, and evaluate prediction accuracy.

Processing block

The processing blocks are divided into two sub-blocks, namely Flatton, spectral analysis.

Flat

Flatten Processing blocks convert multidimensional data into one-dimensional arrays and are suitable for input into machine learning models. Proximity is chosen because proximity is a function that can be extracted from proximity sensors and can be used to train machine learning algorithms. Raw functions are input data collected from sensors, and processed functions are output of processing blocks that extract meaningful functions from raw data. Sample raw data, raw functions and parameters, and DSP results are shown in Figures 2 and 2. 4, 5, 6. Figure 4 shows a time series plot of proximity data over a period of approximately 1920 ms. The proximity values ​​vary between 250 and 254, indicating variations in distance or signal strength detected by the sensor. The graph highlights these variations, showing changes in the environment or movement relative to the sensor. In Figure 5, the Raw Features section lists the collected data values ​​(e.g. 254, 253, etc.) and the Parameters section allows users to set filters and analysis methods. The Scale Axis is set to 1 and no filtering types are applied. For analysis, the FFT (fast Fourier transform) length is set to 16, and both options enable to get the logarithm of the spectrum and overlap FFT frames. These settings are used to analyze data in the frequency domain in specific preprocessing steps (Figure 7).

Figure 4
Figure 4

Raw data time sample plot. A graph showing initial raw time series data collected from traffic sensors.

Figure 5
Figure 5

Features values ​​and parameters. Visualization of functions extracted from raw data used as input to the model.

Figure 6 shows the Status section, indicating that there are no specific states or conditions associated with the settings used. On-device performance, processing time is 1 msec, and operations require 444 bytes of peak RAM usage, reflecting the efficient resource usage of the task.

Figure 6
Figure 6

DSP results. The results of digital signal processing techniques applied to raw data.

Spectrum Analysis

The spectral analysis processing block was used for the iterative pattern of the signal. The Edge Impulse Spectral Analysis Processing Block is a feature extraction block that converts a time-domain signal into a frequency-domain signal. This is done by applying a Fourier transform to the input signal and converting the signal from the time domain to the frequency domain. The resulting frequency domain signal contains information about the frequency content of the input signal. The results of the DSP after filtering are shown in Figure 8, Figure 8 and Figure 4. Figure 4 shows it. The analysis parameters are shown in Figure 7. The Scaling parameter is set to ensure consistent data normalization. The selected method, min, maximum, root mean square, standard deviation, skewness, and kurtosis are statistical measures that capture the essential characteristics of the data, such as central trends, variance, and distribution shape. The selected metrics are important as they help identify patterns, trends, and anomalies and ultimately improve the accuracy and effectiveness of the predictive model. The parameters are well-organized so that the extracted features are representative and meaningful, leading to more reliable model performance.

A spectral diagram (PowerLog) is also shown in Figure 9. This indicates that the spectral power distribution across frequencies is enriched at lower frequencies, decreasing with increasing frequencies and slightly increasing at higher frequencies. The processed functions represent important characteristics of the frequency components of the signal and summarise the behavior of the signal for further analysis or modeling tasks.

Figure 7
Figure 7

Analysis parameters. All important analytical parameters are shown.

Figure 8
Figure 8

Results after DSP filtering. Filtered signal data showing the results after applying a digital signal processing filter.

Figure 9
Figure 9

Spectrum Power Log. Logarithmic plot of spectral power distribution (energy) across different frequencies in the data.

Classification

A classification model is trained on a labeled dataset in which each data point is associated with a particular class or label, and the goal is to predict a new, unmarked data point class. The sample classification is shown in Figure 10. The training performance results show that the model achieves a high accuracy of 95.5% on the validation set with a low loss of 0.13, suggesting strong predictive performance. The confusion matrix shows that most of the predicted classes are well matched with actual classes, especially in categories such as “1-Fast” and “zero”. However, categories like “One-Slow” have minor misclassifications like 14.3% time, which is misclassified as “two fast.” F1 scores for all categories exceed 0.85, indicating a balanced performance of accuracy and recall across all classes.

Figure 10
Figure 10

Classification of data samples. Classification of data samples into different classes based on model predictions (zero vehicle, one vehicle, two VHICLE, second low, medium speed, high speed).

Output function extraction block

This feature is extracted from the input data used to train machine learning modules. In machine learning, the output of a model can be a probability distribution, a vector of scores, or a class label. These outputs can be further processed to extract useful information that can be used for downstream tasks.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *