Edge AI-Assisted IoV Application for Aggressive Driver Monitoring: A Case Study on Public Transport Buses

With increasing adoption of digital technologies to automotive industry, the revo-lution of the vehicles opens new doors for many advanced applications to improve the driver safety and comfort. Thanks to Advanced Driver Assistance Systems (ADAS), no doubt that the future driving experience will be safer than today. De-spite the emergence of new trends, road accidents caused by aggressive driving are still a major problem in many countries. This study presents an edge AI-assisted ag-gressive driver monitoring system based on Internet of Vehicles (IoV) model. In the proposed system, the kNN algorithm and dynamic time warping method are used to recognize the signal patterns of aggressive drivers. The hardware platform is built on the RP2040 microcontroller-based Raspberry Pi Pico board and the Waveshare Quad Expander used for sensor extensions. The MPU-9250 9-axis motion tracking sensor is used as an inertial measurement unit (IMU) to identify the patterns of driv-ers who did sudden lane changes, heavy acceleration, and harsh braking on the roads. Besides, the required software is created using the MicroPython scripting language via Thonny IDE. The proposed method is tested on public transport vehi-cles to determine the drivers engaging in dangerous driving behavior for passengers. The obtained results show that the proposed method can provide satisfactory success to support for recognizing the aggressive behavior of drivers.


Introduction
During the last decade, evolving technologies have played an increasingly essential role in the automotive industry in meeting driving safety challenges and improving traffic management [1].Running parallel to technological innovations, the transportation infrastructure continuously improved to meet drivers' increasing comfort and safety expectations [2,3].Also, vehicle modernization continues to provide energy savings and low emissions as legal obligations require [4].On the other side, due to the excessive increase in traffic congestion due to the increase in the number of vehicles, many new problems arise for transportation day by day [5].To solve these problems that especially have become inextricable in metropolitan cities, a new paradigm is emerged called Intelligent Transportation Systems (ITSs) based on Information and Communication Technologies (ICTs), which includes the Internet of Things (IoT), big data, and artificial intelligence (AI) for data analytics.Thanks to ICTs, drivers can easily access information through communication networks and get assistance for safe driving [6][7][8].
The Internet of Things (IoT) is an empowering innovation currently being developed to transform the traditional Internet paradigm into a fully connected world.Clearly, IoT is a global infrastructure that enables connection, interaction, and exchange of data among a wide variety of embedded smart devices, known as 'Things' [9,10].As an extension of IoT, the recently introduced concept of the Internet of Vehicles (IoV) allows internet connectivity and information sharing between vehicles, pedestrians, and drivers, as well as road and cellular network infrastructure [11].It should be emphasized that the success of IoV mainly depends on secure and reliable connectivity and network setup.Due to the lack of a practical framework to develop IoV applications, many researchers from academia and industry try to develop the appropriate network architectures based on domain-specific and serviceoriented methods [12][13][14].
IoV is mainly employed to remotely collect data from vehicles, pedestrians, and road infrastructure.In this way, it is possible to build a practical analysis to deliver optimized and customized ser-vices that are more contextualized and efficient for ITS applications [15,16].The amount of data collected in IoV applications is increasing day by day, depending on the number and type of sensors placed on the vehicles.Cloud computing provides an effective solution to implement assistive IoV services by extending the computing and storage ability in a centralized and easily accessible location [17].On this basis, cloud-based IoV platforms can offer new services in many real-life scenarios.For instance, authorized service centers can interact with vehicles, gather sensor readings about vehicle health indicators, and provide remote diagnosis/maintenance services [18].Beyond that, realizing a cloud computing-based autonomous driving assistance system may be possible by obtaining data from cameras, radar (radio detection and ranging), and LiDAR (light detection and ranging) sensors.However, the connected car paradigm has not yet matured due to the lack of high throughput and low latency support in current mobile networks (e.g., LTE, LTE-A) [19,20].
Recently, edge computing has emerged as an alternative method to solve the problem of long response time between connected cars and cloud servers.Mainly, it allows data storage to be closer to the source, enables computation on the IoT device at the 'edge' of the network, and removes the need for a cloud connection while guaranteeing higher security [21].When IoT devices have sufficient computing resources to process data for online decision-making, artificial intelligence algorithms can be directly run at the edge level by orchestrating them from the cloud servers.Thanks to this novel approach, known as edge AI, data analytics are made possible in real-time to quickly detect anomalies that can threaten human life or machines' remaining useful life [22].In edge AI applications, the microcontrollers in edge devices allow for the running of machine learning algorithms where the sensor is trained to recognize the recurring activity patterns extracted from sensor data and calculate the spatiotemporal features without human involvement [23,24].
With the rise of IoT devices with sufficient computing power, edge AI has become the core of smart applications, providing machine intelligence for data-driven decision-making and enabling predictions of future trends through data analytics.Nowadays, edge AI applications appear in different fields to open the doors for new opportunities [25].As a novel contribution to existing use cases, this study presents the edge AI-assisted IoV application for remotely monitoring the drivers' behavior while behind the wheel.The main aim is to detect aggressive driving and take preventive measures against traffic accidents.The success of the proposed method is evaluated on public transport vehicles, which have periodically repeated movement patterns with a high similarity between two successive stops.The remainder of the study is organized as follows: Section 2 presents the literature review related to the research topic.Section 3 provides an overview of the proposed method by describing the considered system model.Section 4 explains the hardware design of the driver monitoring unit.Section 5 describes the details of the edge AI implementation to identify the patterns that belong to aggressive driving behavior.Section 6 discusses the results of experimental tests made on public transport buses.Section 7 concludes the study and suggests recommendations for future research.

Related Works
This section reviews the latest research studies on aggressive driving detection and summarizes their findings.
In [26], Li et al. proposed a smartphone-based system for detecting abnormal driving using a built-in smartphone acceleration sensor.The authors collected the acceleration data on a vehicle.Then, they applied their calibration algorithm to convert the obtained data from the smartphone to the vehicle due to the arbitrary location of the smartphone on the vehicle.So, the vehicle's acceleration data are divided into multiple time windows, each representing one second.Each window records the sample data regarding the smartphone's acceleration at a 20 Hz sampling frequency.The abnormal driving thresholds were defined as 0.2g for acceleration and deceleration (braking) and 0.05g for lane change, respectively.The weighted root-mean-square of acceleration was also used to distinguish aggressive driving behavior from unfavorable road conditions.The results show the study's success in detecting distinct driving events.
In [27], Žylius proposed a novel signal segment classification method for driving style classification.The author investigated the features that can more accurately describe differences between aggressive and safe driving styles using sensor data from the 3-axis accelerometer.The classification task was performed using a machine-learning approach based on the Random Forest algorithm.Time and frequency domain (PSD periodogram) features were combined to improve decision-making accuracy.Signals were sampled at 17 Hz, and 78 time and frequency domain features were used.After signal collection, data preprocessing was performed with two stages: redundant data effect mitigation/removal and signal filtering/outlier removal.According to the obtained results, the most essential feature is the standard deviation of X axis acceleration signal.It is possible to achieve about +84% classification accuracy of safe and aggressive driving by using this feature.
In [28], Martinez et al. provided a detailed survey of the approaches used for driving style characterization and recognition, particularly on machine learning approaches in the advanced driver assistance systems (ADAS) context.The authors looked at the current literature based on the tools available, namely rules, models, and learning algorithms.
In [29], Chhabra et al. designed and implemented a system that uses an inbuilt accelerometer and gyroscope to detect sudden changes in acceleration and unsafe/sharp turns.Furthermore, the authors categorized the driving style as aggressive or nonaggressive based on their observed driving patterns.The authors used an Android smartphone to measure the longitudinal acceleration from the Y-axis sensor readings of the accelerometer and angular velocity from the Z-axis readings of the gyroscope.Based on several test drives, abnormal driving thresholds were determined for unsafe acceleration and lane change.
In [30], Moukafih et al. proposed a novel aggressive driving behavior classification approach based on a Long Short Term Memory Fully Convolutional Network (LTSM-FCN).The authors used the UAH-DriveSet as a public dataset that provides many naturalistic driving data obtained from smartphones.Compared to other deep learning and classical machine learning models, the FCN-LSTM model performs well.
In [31], Azadani and Boukerche evaluated the performance of deep learning and machine learning models that can be used for driving behavior identification.The authors studied the public naturalistic driving behavior dataset, which contains trip records of 10 drivers through in-vehicle OBD (On-Board Diagnostics)-II with a sampling rate of 1 Hz.The dataset has 51 features, each of which can provide insights about the engine, fuel, or transmission parameters.Firstly, data normalization was performed to unify the scales of all features.Then, the data segmentation was applied in time series via the sliding window technique.In this way, the time series data was divided into continuous data segments with a fixed window size (100 seconds) and a time step (50 seconds).So, the overlapping windows capture the progressive nature of the time series data and extract the underlying features.The obtained results verified that the CNN and DeepConvLSTM (a combination of CNN and LSTM) exhibit better generalization capability, learning the local temporal dependency in driving behavior data, while the LSTM shows slower learning efficiency than other methods mainly because of its higher number of parameters.
In [32], Schlegel et al. introduced a novel approach for driving style classification based on time series data.Instead of performing all computations in a single recurrent neural network, the authors combined hyper-dimensional computing (HDC) for data representation in high-dimensional vectors and much simpler feed-forward neural networks.The obtained results introduced hyper-dimensional computing as a robust and viable method for aggressive driving identification in the time domain.
In [33], Abdulwahid et al. investigated motorcyclists' dangerous and aggressive driving profiles using Speedometer GPS (Global Positioning System) smartphone application data.The authors prepared the required data sets, and after preprocessing the raw data to make them ready for use, they extracted the relevant features and developed the classification model.So, driver profile thresholds were determined to differentiate between non-aggressive and aggressive driving.
In [34], Monselise and Yang investigated the patterns of aggressive driving and examined the sensor and video data of trips taken by drivers.Beyond that, the authors generated the kNN algorithmbased model to classify driving patterns into four different classes (stop-and-go driving, abruptly changing lanes, driving too fast, and zigzagging) by finding the similarity between trips.To identify the patterns of aggressive driving data recorded during individual trips, the Eros similarity score was used by comparing entire trips and finding the pairwise similarity of all pairs of trips.
In [35], Romero et al. proposed an artificial neural network (ANN) based approach for recognizing driving styles by analyzing the sensor data from the MPU-6050 IMU module with a six-axis accelerometer and gyroscope.The authors classified the driving styles as normal and aggressive.When an abnormal driving pattern is detected, the system warns the driver with a sound message.The overall accuracy of the proposed system with all the variables and two diving styles was 92.43%.Table 1 compares the existing solutions with the proposed method.

Proposed Method
Public transportation is an essential service in urban centers of many countries worldwide.Public transport vehicles (e.g., buses, trains, trams, and ferries) occupy an essential place to reduce traffic congestion and carbon emissions.The bus operation supported by local municipalities is the most common vehicle type used for public transport.Beyond the urban public transport mode, bus line services are also offered for intercity transportation when there is no access by train [36].Notably, many deaths and injuries occur due to traffic road accidents caused by public transport vehicles [37].In most cases, careless driving and over-speeding are the leading causes of accidents.Thanks to the technological developments occurring in embedded systems and artificial intelligence each passing day, it has become possible to prevent traffic accidents to a large extent [38,39].
When considering all the reasons that result in different types of traffic accidents, most of them have resulted from drivers' faults.Due to the driver's fatigue, sleepiness, or distraction, the vehicles can drift out of their lane.Also, drivers may lose vehicle control due to excessive steering-wheel maneuvers [40].Besides the frequent lane changes, aggressive driving reduces a driver's reaction time to road events and ability to handle a vehicle safely while increasing the risk of road accidents.Sudden acceleration and harsh braking by hitting the gas or brake pedals too quickly are two primary behaviors of aggressive drivers [34,41].In addition to accident risk, aggressive driving increases fuel consumption, causes gas emissions, and shortens the vehicle's lifetime by damaging the engine and some other mechanical parts on several subsystems [42].
Although the global definition and determination method of aggressive driving behavior is unclear, it can be detected by tracking variations of recorded vehicle motion data patterns.According to the result of the real-world experiments realized by Junior et al. [43], the accelerometer and gyroscope are the most suitable sensors to detect driving events; also using all sensor axes performs better in a general way than using a single axis.In vehicles, the longitudinal and lateral acceleration (the change in velocity over the change in time) describes the direction of motion, while the gyroscope determines the orientation and rotation angle [44].Accordingly, using the collected data from the accelerometer and gyroscope, aggressive driving behavior can be identified through specific movement patterns [45].
The system model of the proposed edge AI-assisted IoV application is shown in Fig. 1.To reduce or even eliminate aggressive driving behaviors, this study proposes the use of an edge AI-enabled driver monitoring unit (DMU) on public transport vehicles, which continuously tracks the movement patterns of drivers.When aggressive driving behavior occurs, DMU sends notifications to detect possible accidents before they happen.Although this solution can be implemented on private vehicles, Fig. 1.The system model of the proposed application its effectiveness is much greater for public transport vehicles remotely managed by a service provider from the remote monitoring center, like coach buses, passenger buses, or mini-busses.

Edge Hardware Platform
The DMU was prototyped using the Raspberry Pi Pico board, which uses the RP2040 microcontroller with a 32-bit dual-core ARM Cortex M0+ processor up to 133MHz.RP2040 is a low-cost, high-performance microcontroller that thoroughly supports the MicroPython and low-level C/C++ programming languages.It provides ease of use to the programmer thanks to its flexible digital interfaces [46].Based on the Raspberry Pi Pico board, the edge hardware prototype was constructed on the Waveshare Quad Expander as a platform for sensor extensions [47].The prototype design uses the Pico 10DOF sensor expansion module, Quectel L76B Global Navigation Satellite Systems (GNSS) module, 1.3-inch LCD module, and 2-Channel RS485 module to detect aggressive driving cases.Fig. 2 shows the hardware design of the DMU prototype with Raspberry Pi Pico and sensor extensions.
Pico 10DOF sensor expansion module with TDK InvenSense ICM-20948 9-axis MEMS motion tracking sensor was used as an inertial measurement unit (IMU) to identify the drivers who did abnormal acceleration and deceleration as well as frequent or sudden lane changes on the roads.ICM-20948 is a multi-chip sensor combining a 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer, and a Digital Motion Processor™ (DMP).It comprises two separate silicon dies integrated into a single 24-pin QFN package.One of the dies houses the 3-axis magnetometer, and the other houses the 3-axis gyroscope and the 3-axis accelerometer [48].Quectel L76B GNSS module was used to find the position of the vehicles on the earth's surface using positioning satellites, i.e., GPS, BeiDou, and QZSS.It has a horizontal position accuracy below 2.5 meters and provides an easy-to-use global navigation function in vehicle tracking applications.The update rate is given as 1 Hz (default) and 10 Hz (max) [49].The 1.3-inch LCD module has Fig. 2. The hardware platform based on Raspberry Pi Pico board a 1x joystick and 4x user buttons).It was connected to the extender to monitor the sensor readings and select the options in the menu [50].
ICM-20948 allows the tracking of both fast and slow motions precisely.It uses an I2C (Inter-Integrated Circuit) interface for communication with the microcontroller.The accelerometer is used for linear acceleration measurements.It has a 16-bit resolution and measuring range can be configured within the ±2, ±4, ±8, and ±16g.Besides, a gyroscope measures the angular position by observing the movement's pitch, yaw, and roll dimensions.The resolution of the gyroscope is 16-bit, and the measuring range can be configured within the ±250, ±500, ±1000, ±2000 °/sec (degree per second, dps).The accelerometer and gyroscope data rate can be adjusted from 4 Hz to 1125 Hz [51].

Edge AI Implementation
AI is a core enabler in identifying hidden data patterns, emerging correlations, and abnormal behaviors to gain knowledge from real-time data sources and make data-driven decisions for better outcomes [52].It covers multiple technologies and methods powered by advanced tools for several purposes.Machine learning (ML) is a powerful method of AI that uses several learning algorithms to enable faster evaluation of complex datasets and provide insights from them.ML can interpret data, acquire knowledge, identify trends, and make decisions like a human brain.In this way, machines learn from historical data depending on previous experiences without being programmed [53].
ML algorithms are usually classified into three categories: supervised learning, unsupervised learning, and reinforcement learning.Supervised learning is the most common use of ML, where the algorithm is trained on a labeled dataset to solve the regression and classification problems.In classification problems, a supervised learning algorithm can predict a category to which the data belongs from a list of given classes.Besides, it can predict new (unseen) data points in regression problems.On the other side, unsupervised learning uses unlabeled datasets and groups them into separate clusters by describing their structure depending on similar characteristics [54].[29] smartphone accelerometer and gyroscope Statistical analysis Moukafih et al. [30] smartphone accelerometer LTSM-FCN Azadani and Boukerche [31] in-vehicle sensors not specified DeepConvLSTM Schlegel et al. [32] not accelerometer and gyroscope Hyper-dimensional computing Abdulwahid et al. [33] smartphone accelerometer Statistical analysis Monselise and Yang [34] not specified accelerometer and gyroscope kNN algorithm Romero et al. [35] MPU-6050 accelerometer and gyroscope ANN Brahim et al. [59] smartphone accelerometer and gyroscope GBDT and LSTM Eren et al. [65] smartphone accelerometer and gyroscope Statistical analysis As major characteristics of aggressive driving, abnormal acceleration/deceleration and sudden/frequent lane changes create rapid variations in the accelerometer and gyroscope signals.Classification is the most convenient method to expose hidden patterns related to dangerous driving [55].In this study, supervised learning was used to classify driving behavior as aggressive or calm (nonaggressive).There are several supervised machine-learning algorithms available for classification problems, i.e., Support Vector Machines (SVM), k-Nearest Neighbors (kNN), Decision Trees, and Gaussian Naive Bayes [56].Considering Raspberry Pi Pico board's limited computing and data storage resources as an edge device, running the complex machine-learning algorithms in near real-time is impossible.The kNN algorithm has a special place among the supervised machine learning algorithms due to its simple non-parametric nature to solve classification and regression problems.It can work on every kind of data in various applications requiring classification.A typical kNN classifier finds the class of a new data point by looking at the classes of the neighboring 'k' data points.The class assignment is made by calculating the distance (similarity) between the unclassified data point and all the data points in the training dataset.The classification may take a long time depending on the number of samples of the data when compared to other algorithms.Despite that, kNN is a pretty good algorithm specialized to find complex patterns, especially for lowdimensional data [57].
The motion of any vehicle can be modeled through simulation by providing a group of continuous-time signals (i.e., acceleration, rotation, speed, position) acquired by sensors.These signals are usually sampled at regular intervals and represented as one-dimensional arrays.The statistical analysis is made by converting the driving data to time series data containing sequential data points timestamped at regular intervals.When looking at the identification of aggressive driving behavior patterns from a large perspective, it can be seen as a time series data classification problem [58,59].Since time series data typically consist of hundreds of samples, it must be reduced to a small subset of relevant features to be used for classification.The sliding time window is a beneficial method for feature extraction when it is desired to capture relevant information from a time series.So, a sliding window with a predefined size is utilized to generate the segmented data into overlapping series.As the vehicle moves, the new data arrive continually, and the time window slides along the time series [60].
The clustering task mainly depends on defining the similarities between two data points.As implied, the nonparametric kNN algorithm classifies new data points based on the nearest data points by selecting 'k' nearest data points in training data [61].When working with time series, the kNN algorithm again finds the similarity through side-by-side comparisons.The distance measure is usually used to calculate the similarity between time series.The Euclidean distance is the most widely used distance function in kNN classification, which mainly compares the same sequenced points of different time series.When considering the n-dimensional space, Euclidian distance is calculated as follows: where  = { 1 ,  2 , … ,   } and  = { 1 ,  2 , … ,   } represent the time series [62].
It is noteworthy that two different time series might have a similarity even if one of them is displaced or stretched in time with respect to the other.Unfortunately, the accuracy of Euclidean distance cannot be guaranteed when the series may be slightly displaced in time (i.e., out-of-phase signals).Dynamic Time Warping (DTW) is an alternative distance measure that tackles optimal alignment problems by warping the time axis [63].Simply, DTW creates a non-linear mapping and compares one-to-many points in two-time series after optimally aligning them.The flexibility of DTW allows one to compare one data point of a certain time series to many data points of the other time series.So, it can minimize the distance between time series.The following recursive function gives the minimum distance: ( where  = { 1 ,  2 , … ,   } and  = { 1 ,  2 , … ,   } represent the time series.Besides,  is the Euclidean distance function.So, the distances for every element in the λ matrix of  ×  size are calculated [45,64,65].In this study, the aggressive driving characteristics of drivers were identified with supervised learning using a kNN algorithm with a DTW distance measure on the edge platform.Due to simplicity and applicability to run on the edge devices, a 1NN (nearest neighbor) classifier was used to predict the class of obtained time series.Then, the object's class is predicted as closest to it from the training set.Fig 3 .shows the flowchart of the proposed method.The required firmware is created using the MicroPython language via Thonny IDE.MicroPython is a tiny version of the popular Python programming language, which is optimized to run on lowpower microcontrollers with MHz of clock speed like the RP2040 on the Raspberry Pi Pico board.MicroPython is largely compatible with Python 3, which has powerful libraries to handle data (i.e., NumPy, SciPy, Scikit-Learn).While the Statsmodels library supports time series modeling, the Scikit-learn library allows running machine learning algorithms.Unfortunately, both the Statsmodels and Scikit-learn libraries are not available in MicroPython.Despite that, edge AI-oriented development platforms (e.g., Edge Impulse, SensiML, Micro.ai)enable the running of machine learning algorithms on tiny edge devices like the RP2040 microcontroller-based Raspberry Pi Pico board.

Experimental Study
In the experimental study, the driving style of public bus drivers was classified as calm or aggressive through the proposed method.The tests were made on the public transport buses of the metropolitan municipality in Konya Province, Türkiye.The experimental setup was built to test the driving style of bus drivers carrying passengers throughout the Dr. Ahmet Özcan and Fetih Streets.The selected 14-A test line has many unevenly spaced bus stops during a long trip in the Konya city center.Fig. 4 shows the route map of the public transport buses on which the experimental tests were performed.Fundamentally, both the accelerometer and the gyroscope sensor data (rad/s) can be used to sense unsafe lane changes, while the accelerometer sensor data (m/s 2 ) can be used to be aware of abnormal acceleration/deceleration of the vehicle.In the experimental tests, the longitudinal acceleration on the y-axis (Acc_y) direction and yaw rotation around the vertical axis of the vehicle (Gyr_z) were used to identify the aggressive driving behavior of public bus drivers in terms of abnormal acceleration/deceleration and sudden/frequent lane changes, respectively.Fig 5 .shows the 6-Degrees of Freedom (DoF) model used to measure the motion, orientation, and position.
Before the experimental tests, to understand the movement patterns of aggressive drivers, the labeled training data set was created based on recordings of accelerometer and gyroscope sensors, which are captured from 40 trips of approximately 55 minutes each on average.Each trip's recorded data sequence was divided into parts showing the motion pattern between two consecutive bus stops.Then, the collected data from the accelerometer and gyroscope sensors labeled each part as calm or aggressive.On this basis, unsafe acceleration/deceleration and steering maneuverers of drivers were defined with gathered sensor data from IMU. Fig. 6 and Fig. 7 show the typical signal patterns of the accelerometer that show calm and aggressive driving, respectively.Similarly, Fig. 8 and Fig. 9 show the typical signal patterns of the gyroscope that can be used to distinguish aggressive drivers.As seen from the plots, sudden acceleration and harsh braking make a significant deviation in the pattern of Acc_y sensor data, while sudden lane change highly affects the pattern of Gyr_z sensor data.
When considering the public bus transport service in cities, the drivers often demonstrate similar driving patterns by accelerating and decelerating the bus between two successive bus stops.Depending on the road conditions and traffic congestion, vehicle movement patterns may differ from each other.However, it should be emphasized that aggressive driving has a more pronounced effect on forming the vehicle movement pattern.Fig. 10 shows the obtained signal pattern when the public transport bus moves by acceleration and deceleration for varying periods depending on the driver's interaction with the gas and brake pedals.When aggressive driving behavior was classified, firstly, the real-time application was tried to be performed by running sensing and computing tasks simultaneously.The RP2040 microcontroller has two processing cores to power the Raspberry Pi Pico board.So, it is possible to run two threads on separate cores simultaneously.In this way, the main thread execution and the additional thread execution keep two tasks going simultaneously.Micropython has a threading library to launch the thread on the RP2040 microcontroller.Besides, thanks to the global variable definition, two threads can access the same variables, and the additional thread can pass the information back to the main thread.In the proposed edge AI implementation, the main thread starts a loop that reads the sensors and records the data in a CSV file, while the additional thread can run the kNN classification algorithm with a DTW distance measure for each newly acquired data record.However, since the kNN algorithm uses all input variables and training samples for each new observation to be classified, it needs higher computation and memory resources than the Raspberry Pi Pico provide.
To realize a more practical machine learning process, the sensor data gathering and kNN implementation procedures were performed in turn so that when one ends, the other begins.On this Fig.11.The field test scene of the developed system.basis, the significant characteristics of aggressive driving (i.e., acceleration with heavy throttle, deceleration by harsh braking, and sudden/frequent lane changes with steering maneuver) were investigated by detecting the motion patterns of the accelerometer and gyroscope signals.In repeated tests, data collection intervals' start and end points were referenced as bus stops located one after the other.Accordingly, the driving behavior was detected by using the DTW-based 1NN algorithm.The proposed method identifies the driving style by measuring the similarity between test data and each row of the training dataset, then finding the closest neighbor for each prediction.Consequently, the events could be classified into calm or aggressive driving.According to the obtained results from experimental tests, the abnormal acceleration/deceleration cases were correctly identified as 52%, and sudden/frequent lane changes were exactly recognized as 67%.Fig. 11 shows the field test scene of the developed system.

Conclusion
Aggressive driving behavior is one of the most important causes of road accidents.While early detection of abnormal vehicle maneuvers could help prevent deaths and serious injuries, taking proactive measures to ensure traffic safety is immensely beneficial in reducing risky driving behavior.This study presented the feasibility of an IoV application that can be used for aggressive driver monitoring in public transport bus services.The kNN-based machine learning approach was implemented to classify and detect aggressive driving behaviors (i.e., abnormal acceleration/deceleration and sudden/frequent lane change).The Raspberry Pi Pico board was used as the central processor for all sensing, computing, and communication tasks.It can be concluded that, although there are still some shortcomings, the proposed edge-AI implementation will offer a satisfactory solution to identify the risky driving behaviors of drivers.Since the success of the 1NN classifier tightly depends on the size of the training set, the performance of the proposed method can be improved by increasing the number of training templates.Besides, increasing the sampling rate of the accelerometer and gyroscope makes it possible to identify the features better.Despite its computational complexity, the DTW distance measure allows distinguishing the characteristics of aggressive drivers with a minimal training set.Future works will address the application of similar approaches on more powerful computing platforms to improve the success of aggressive driving identification.

Fig 3 .Fig. 4 .
Fig 3. Flowchart of the proposed method to identify the driving style

Table 1 .
Comparison chart for surveyed studies