# Data-Driven Safe Deliveries: The Synergy of IoT and Machine Learning in Shared Mobility
## 5 Results and Discussion
### Classification Model
#### 5.2.2 Data Preprocessing and Feature Extraction  
Prior to model training, the dataset underwent a preprocessing phase to allow the classifiers to capture patterns in the driving behavior. Specifically, to reduce the data volume and streamline the analysis, every 20 readings were aggregated into a single sample. As a result, the dataset was refined to approximately 90,000 data samples. Moreover, important kinematic quantities, such as jerk values, were computed from both the acceleration and angular velocity data. Descriptive statistics were calculated for each sample, resulting in a total of 49 features after preprocessing. The distribution of samples in each class after preprocessing is presented in Table 1.  
The original dataset consisted of the readings of the gyroscope and accelerometer sensors. The gyroscope readings were represented as the angular velocities on three axes of the gyroscope and were denoted as gyro_x, gyro_y, and gyro_z. The accelerometer readings were represented as the acceleration values on three axes of the accelerometer and were denoted as acc_x, acc_y, and acc_z. Every consecutive 20 readings were grouped together and used to extract kinematic, statistical, and rotational features. The details of these features are as follows:  
(a) Kinematic Features  
The kinematic features were extracted through the calculation of different jerk values from the gyroscope and accelerometer readings. Jerk is the measure of how rapidly the acceleration changes over time. The features included individual axis jerk values,such as gyro_jerk_x, gyro_jerk_y, and gyro_jerk_z, which represent the rate of change in acceleration in the x, y, and z axes, respectively, as measured by the gyroscope sensor. Jerk is a critical measure of how rapidly the acceleration changes over time. Additionally, the feature overall_gyro_jerk represented the overall jerk calculated from the three axes of the gyroscope (x, y, z). This value is typically obtained by taking the square root of the sum of the squares of the jerk values in each axis. Another essential feature, gyro_mean_jerk, was computed to represent the mean (average) jerk derived from the three axes of the gyroscope (x, y, z). It is typically obtained by summing the jerk values in each axis and dividing by the number of data points. Analogously, acc_jerk_x, acc_jerk_y, and acc_jerk_z represented the jerk, or rate of change in acceleration, in the x, y, and z axes, respectively, as measured by the accelerometer sensor. Similarly, mean_acc_jerk was calculated as the mean (average) jerk derived from the three axes of the accelerometer (x, y, z) by summing the jerk values in each axis and dividing by the number of data points.  
Statistical Features  
Various statistics were computed for the acceleration and gyroscope data on each axis. For the acceleration data in the x-axis, features such as acc_x mean, acc_x std, acc_x median, acc_x min, acc_x max, and acc_x sem represented the mean, standard deviation, median, minimum, maximum, and standard error of the mean (SEM) values, respectively. Similar statistics were derived for the acceleration data in the y-axis (acc_y_mean, acc_y_std, acc_y_median, acc_y_min, acc_y_max, acc_y_sem) and z-axis (acc_z_mean, acc_z_std, acc_z median, acc_z_min, acc_z_max, acc_z_sem). Likewise, the same set of statistics was calculated for the gyroscope data in the x-axis (gyro_x_mean, gyro_x std, gyro_x median, gyro_x min, gyro_x max, gyro_x sem), \(y\)-axis (gyro_y_mean, gyro_y_std, gyro_y_median, gyro_yy_min, gyro_y min, gyro_y max, gyro_y_sem), and z-axis (gyro_z_mean, gyro_z_std, gyro_z median, gyro_z min, gyroro_z_max, gyro_z_sem).  
The rotational features orientation, pitch, and roll represented the orientation of the gyroscope sensor, which is typically obtained by combining gyroscope readings from multiple axes. Specifically, orientation represented the overall orientation of the device in 3D space, while pitch and roll represented the rotation angles around the x-axis and y-axis, respectively.