Dynamic Basic Activity Sequence Matching Method in Abnormal Driving Pattern Detection Using Smartphone Sensors

: In this work, we present a novel method, namely dynamic basic activity sequence matching (DAS), a combination of machine learning methods and ﬂexible threshold based methods for distinguishing normal and abnormal driving patterns. Indeed, DAS relies on the activity detection module (ADM) presented in our previous work to analyze each driving pattern as a sequence of basic activities—stopping (S), going straight (G), turning left (L), and turning right (R). In fact, the threshold value and other parameters like the duration of long and short activities are iteratively induced from the collected dataset. Hence, DAS is ﬂexible and independent of driving contexts such as vehicle modes and road conditions. Experimental results, on the dataset collected from numerous motorcyclists, show the outperformance of our proposed method against dynamic time warping and the two popular machine learning methods—random forest and neural network—in distinguishing the normal and abnormal driving patterns. Moreover, we propose an e ﬃ cient framework composing of two phases: in the ﬁrst phase, the normal and abnormal driving patterns are distinguished by relying on DAS. In the second phase, the detected abnormal patterns are further classiﬁed into various speciﬁc abnormal driving patterns—weaving, sudden braking, etc. This fusion framework again achieves the highest overall accuracy of 97.94%.


Introduction
According to the global status report on road safety 2018 by the World Health Organization (WHO), approximately 1.35 million of people die per year as a result of road traffic crashes [1].The main cause of road accidents is due to human factors, e.g., drunken drivers, speeding, sudden turning.Therefore, real-time detecting abnormal driving patterns is an effective approach to prevent such fatal accidents by alerting drivers to the potentially predicted dangerous scenarios as well as reporting the detected risk cases to a transportation management center.
Due to the high increment in popularity and computational capability, smartphones become widely used in these studies.Yet, they are considered the powerful devices being able either to access driver and vehicle information with the help of the embedded sensors-such as accelerometers, gyroscopes, GPSs, etc.-or to provide immediate feedbacks to drivers through intelligent abnormal driving pattern detection applications.
In order to deal with the above problems, various methods have been proposed to detect the driving abnormalities.These methods can be classified into two main categories: the binary and multiclass detection methods.The binary detection methods focus on identifying driving patterns as normal or abnormal ones [14,17,18].In contrast, the multiclass detection methods try to recognize various specific abnormal driving patterns such as weaving, swerving, sudden braking, etc. [9][10][11][12][13][19][20][21][22].Moreover, the abnormal driving pattern detection problem has been solved by three main approaches: dynamic time warping (DTW) [3,17,18], threshold based methods [20], and machine learning methods [14,[17][18][19]21,22].In fact, each method has its own pros and cons depending on its application domain.The DTW methods often apply on the raw sensor data signal.Hence, they do not acquire much of computation resource.Nonetheless, their prediction accuracy is often low [3,17,18].In the threshold-based methods, the sensor data signal must be further processed, then a threshold value is selected to determine the abnormal patterns.However, such threshold values are quite sensitive to driving context such as vehicle mode and road condition.On the other hand, studies have shown that the machine learning methods often achieve relatively high prediction accuracy [14,[19][20][21][22].However, these methods might encounter several problems such as the imbalance of training dataset, the incorrect labels of collected data.In fact, our experiments show that the performance of some machine-learning methods, such as RF, is quite sensitive due to the hardness of collecting abnormal driving patterns.
In this study, we first propose a novel approach, namely dynamic basic activity sequence (DAS) matching, a combination of machine learning methods and threshold based methods for identifying normal and abnormal driving patterns.Indeed, DAS relies on the activity detection module (ADM) presented in [23] to analyze each driving pattern as a sequence of basic activities-stopping (S), going straight (G), turning left (L), turning right (R).In the previous study, it has been shown that in the normal driving scenarios of cars or motorcycles, the optimal duration of basic activities leading to the best prediction accuracy ranges from 4 to 6 s.However, by observing, when an abnormal driving pattern occurs, the duration of its basic activities is often much shorter, i.e., 1 or 2 s.Thus, each basic activity with a long duration-i.e., from 4 to 6 s-is then further analyzed as a sequence of sub basic activities with a shorter duration.By estimating the difference between the sequence of sub basic activities and the original basic activity, the abnormal driving pattern can be effectively detected with a proper threshold.Note that the threshold value and other parameters like the duration of long and short activities are induced from the collected dataset in an iterative procedure.Hence, our proposed method is flexible and independent of driving contexts such as vehicle modes and road conditions.Experimental results illustrate that DAS achieves the prediction accuracy, which is higher than DTW, RF, and NN by 28.83%, 9.24%, and 1.10% respectively in distinguish normal and abnormal driving patterns.
Secondly, we present an efficient framework for recognizing specific abnormal driving patterns, for instance weaving, sudden braking, etc.This task is done through a fusion of two modules: the first one is responsible for distinguishing normal and abnormal driving patterns by relying on DAS.The second one is in charge of further classifying the obtained abnormal patterns into various specific abnormal driving patterns.This fusion approach allows us to achieve the overall accuracy of 97.94%, which outperforms all common existing methods-DTW, RF, and NN.
The rest of this article is organized as followings: The related work is presented in Section 2.Then, the details of the proposed method are described in Section 3. Next, the experimental settings and results are shown in Section 4. Finally, Section 5 provides various conclusion remarks.

Related Work
This section presents the review of recent researches on abnormal driving pattern detection.These works have investigated various methods such as DTW [17,18], threshold based [20], and numerous machine-learning algorithms including RF, NN, SVM (support vector machine), artificial neural network (ANN), Bayesian network (BN), maximum likelihood (ML), naive Bayes (NB) [14,[17][18][19]21,22].Moreover, RF and NN have been shown to achieve a high performance among others [19,21,22].Table 1 provides the summary of recent researches in the area of abnormal driving pattern detection.In the machine learning methods, the time domain features, and the frequency domain features are popularly applied.Yet, Carlos et al. propose a novel approach relying on the bag of words to automatically extract features from accelerometers [22].
Though the method of Yu et al. [19] obtains a high prediction accuracy, i.e., 96.88%, its feature set is quite big, i.e., 152 features.This factor absolutely leads to a high computational time and resource.Thus, our proposed framework utilizes the smaller feature set consisting of 34 time-domain features and seven frequency-domain features and 18 Hjorth features previously described in [23].

Proposed Method
In order to increase the accuracy in detecting specific abnormal driving patterns, we propose a framework composing of two parts (Figure 1): in the first phase, the normal and abnormal driving patterns are distinguished relying on DAS.Then, in the second one, the detected abnormal patterns are further classified into various specific abnormal driving patterns-weaving, sudden braking, etc.-with the help of DAS.This framework allows us to achieve the highest overall accuracy of 97.94%.
In order to increase the accuracy in detecting specific abnormal driving patterns, we propose a framework composing of two parts (Figure 1): in the first phase, the normal and abnormal driving patterns are distinguished relying on DAS.Then, in the second one, the detected abnormal patterns are further classified into various specific abnormal driving patterns-weaving, sudden braking, etc.-with the help of DAS.This framework allows us to achieve the highest overall accuracy of 97.94%.

Dynamic Basic Activity Sequence Matching
As aforementioned, the proposed method, namely dynamic basic activity sequence matching (DAS), for identifying generic abnormal patterns is a combination between the machine learning techniques and the threshold-based techniques.Note that the threshold values and certain

Dynamic Basic Activity Sequence Matching
As aforementioned, the proposed method, namely dynamic basic activity sequence matching (DAS), for identifying generic abnormal patterns is a combination between the machine learning techniques and the threshold-based techniques.Note that the threshold values and certain parameters are induced from the training dataset in an iterative procedure.Hence, our proposed method is flexible and independent of driving context such vehicle mode and road condition.
Indeed, the proposed method contains two phases: the parameter optimization phase and the detection phase (Figure 2).In the parameter optimization phase, the sensor data, including accelerometer, gyroscope, and magnetometer, are collected and labeled corresponding to the normal or abnormal driving patterns.Then, such data are passed to activity detection module (ADM) (described in [23]) to transform into two sequences of basic driving activities-containing stop (S), going straight (G), turning left (L), turning right (R)-corresponding to the long duration of activities in normal driving scenarios (representing by the window size W) and the short duration of activities in abnormal driving scenarios (representing by the window size W ). Thus, each basic driving activity is detected by ADM in a sliding data window with a specific overlapping ratio that determines the overlap between two consecutive data windows.
Supposing that ADM, using the window size W seconds, transforms a sensor data segment into a sequence of basic activities A 1 , A 2 . . .A n where A i ∈ {S, G, L, R}, i = 1, 2, . . ., n.In our previous work [23], it has been shown that in the normal driving scenarios, the optimal window size for accurately identifying basic activities of car and motorcycle drivers usually ranges from 4 to 6 s.Hence, in the later experiments, W will be tested in this range.
On the other hand, by observing, when an abnormal driving pattern occurs, the duration of its basic activities is often much shorter, i.e., 1 or 2 s.Hence, each basic activity A i inferred by ADM with the window size W seconds, can be alternatively considered as a set of k smaller data windows of the size W seconds where k = | W W |.Then, A i is further analyzed by ADM as a sequence of k smaller basic driving activities A i1 , A i2 . . .A ik where A ij ∈ {S, G, L, R}, j = 1, 2, . . ., k.Let S i = {A i1 , A i2 . . .A ik } be the set of sub-labels of A i .
The sub-label difference of the basic activity A i is computed as where D i is the set of labels in the set S i that are different from the original activity label A i or accelerometer, gyroscope, and magnetometer, are collected and labeled corresponding to the normal or abnormal driving patterns.Then, such data are passed to activity detection module (ADM) (described in [23]) to transform into two sequences of basic driving activities-containing stop (), going straight (), turning left (), turning right ()-corresponding to the long duration of activities in normal driving scenarios (representing by the window size ) and the short duration of activities in abnormal driving scenarios (representing by the window size ′).Thus, each basic driving activity is detected by ADM in a sliding data window with a specific overlapping ratio that determines the overlap between two consecutive data windows.Supposing that ADM, using the window size seconds, transforms a sensor data segment into a sequence of basic activities  ,  … where  ∈ {, , , }, =1, 2…n.In our previous work [23], it has been shown that in the normal driving scenarios, the optimal window size for accurately identifying basic activities of car and motorcycle drivers usually ranges from 4 seconds to 6 seconds.Hence, in the later experiments,  will be tested in this range.
On the other hand, by observing, when an abnormal driving pattern occurs, the duration of its basic activities is often much shorter, i.In the other word, d i represents the basic signal change rate detected during the period of the activity A i .Thus, if d i > ε then A i should be considered as an abnormal driving pattern, where ε denotes the threshold value.We would investigate ε in the range of (0.5-0.9) as more than half of the sub-labels of an abnormal activity are different from the label of the original activity.
Figure 3a shows the acceleration patterns of abnormal driving pattern from a data window size of 6 s.The strong fluctuations on z and y components show the changes in direction or basic activities (R and L), which are recognized in smaller windows.For normal driving pattern, the acceleration patterns in the same window size as shown in Figure 3b are smoother in the 'going straight' mode.
Electronics 2020, 9, 217 6 of 14 where  is the set of labels in the set  that are different from the original activity label  or  = {:  ∈  ,   }.
In the other word,  represents the basic signal change rate detected during the period of the activity  .Thus, if   then  should be considered as an abnormal driving pattern, where ε denotes the threshold value.We would investigate ε in the range of (0.5-0.9) as more than half of the sub-labels of an abnormal activity are different from the label of the original activity.
Figure 3a shows the acceleration patterns of abnormal driving pattern from a data window size of 6 seconds.The strong fluctuations on z and y components show the changes in direction or basic activities ( and ), which are recognized in smaller windows.For normal driving pattern, the acceleration patterns in the same window size as shown in Figure 3b   The prediction accuracy with the parameter set (, ′, ε) is estimated on the training dataset.This procedure is repeatedly done with various combinations of , ′, and ε values in previously mentioned ranges.The parameter set (, ′, ε) corresponding to the best prediction accuracy is the optimal one.
In the detection phase, the accelerometer data is collected and then preprocessed similar to that The prediction accuracy with the parameter set (W, W , ε) is estimated on the training dataset.This procedure is repeatedly done with various combinations of W, W , and ε values in previously mentioned ranges.The parameter set (W, W , ε) corresponding to the best prediction accuracy is the optimal one.
In the detection phase, the accelerometer data is collected and then preprocessed similar to that in the parameter optimization phase.The details of this phase are described in Figure 2: two simultaneous processes of driving activity detection at the different data window size W and W are implemented; the abnormal driving pattern is identified by using the optimal set of parameters (W, W , ε) obtained from the parameter optimization phase.The procedure of detecting abnormal driving pattern is demonstrated in Algorithm 1, where ADM (W i ) is responsible for identifying the basic activity of the data window W i .
Algorithm 1: Abnormal Driving Pattern Detection (W i , ε, k) Input: A data window W i , threshold value ε, k Output: The pattern label (normal/abnormal) with respect to the data window label ← abnormal 13.Else 14.

Specific Abnormal Driving Pattern Classification
As previously described, the abnormal driving patterns identified by DAS are then further classified into various specific abnormal patterns.Phase 2 is divided into the training and the monitoring modules.In the training part, time series data are first collected from accelerometer sensor and manually labeled with the corresponding pattern type-i.e., weaving, sudden braking, etc.Then, these data were calibrated by preprocessing techniques such as noise filtering, and windowing techniques.Next, representative information is extracted by exploring various categories of popular features, for example time domain features, and frequency domain features as shown in Figure 4.The time-domain features provide statistic metrics of driving activities in time domain; the frequency-domain features provide information about cyclic characteristics of activities; and Hjorth features can provide additional information of activities in both time and frequency domains.A set of formulas for computing such features is presented in [23].The resulting feature vectors are then used to train the abnormal driving detection model.Finally, we use machine learning classifiers such as random forest (RF) and neural network (NN) for training dataset to select the most suitable classifier in the monitoring part.
shown in Figure 4.The time-domain features provide statistic metrics of driving activities in time domain; the frequency-domain features provide information about cyclic characteristics of activities; and Hjorth features can provide additional information of activities in both time and frequency domains.A set of formulas for computing such features is presented in [23].The resulting feature vectors are then used to train the abnormal driving detection model.Finally, we use machine learning classifiers such as random forest (RF) and neural network (NN) for training dataset to select the most suitable classifier in the monitoring part.

Environment and Data Collection
We develop an Android-based application for collecting the tri-axis data from accelerometers, gyroscopes, and magnetometers.This application is built on Android OS version 6.0 to 7.0.Using this application, we collected two datasets from eight volunteer subjects with the age of 22-40 years old.Each dataset contains the samples for normal or abnormal driving patterns.The sensor data is sampled at 50 Hz on different types of smartphones.The smartphones can be freely put into the shirt pockets or held in one hand of the subject or in the vehicle's hold during travelling.In our study, we focus on identifying abnormal driving patterns of motorcyclists.The subjects used different types of motorbikes and simulated the abnormal scenarios, including weaving and sudden braking, in which travelers were driving with alternative or abrupt changes in the direction of vehicle at a high speed.For the safety of the subjects, the abnormal driving situations were carried out in carefully supervised conditions.Otherwise, the subjects traveled in usual driving conditions to collect the normal pattern data.Figure 5 shows the percentage of each type of driving pattern with total amount of 3240 samples.
Next, the collected datasets are used to evaluate the performance of three groups of techniques for distinguishing normal and abnormal driving patterns: the typical rule-based methods (DTW), the machine learning methods (RF and NN), and our proposed method (DAS).Based on the experimental results obtained from our previous work [23], the optimal window size for each basic activity should range from 4 to 6 s.
different types of motorbikes and simulated the abnormal scenarios, including weaving and sudden braking, in which travelers were driving with alternative or abrupt changes in the direction of vehicle at a high speed.For the safety of the subjects, the abnormal driving situations were carried out in carefully supervised conditions.Otherwise, the subjects traveled in usual driving conditions to collect the normal pattern data.Figure 5 shows the percentage of each type of driving pattern with total amount of 3240 samples.Next, the collected datasets are used to evaluate the performance of three groups of techniques for distinguishing normal and abnormal driving patterns: the typical rule-based methods (DTW), the machine learning methods (RF and NN), and our proposed method (DAS).Based on the experimental results obtained from our previous work [23], the optimal window size for each basic activity should range from 4 to 6 seconds.
As aforementioned, the framework of specific abnormal driving pattern detection is carried out in two phases (Figure 1): the phase 1 is responsible for distinguishing the normal and abnormal driving patterns, then the detected abnormal ones are further classified with the help of RF and NN classifiers.In the later phase, the feature set is extracted from every sliding window of preprocessed accelerometer data.As described in detail in [23], the feature set combines the features computed on different preprocessed accelerometer components in different domains that consists of 34 time-domain features and seven frequency-domain features and 18 Hjorth features.
For evaluating the performance of each method, we use 10-fold cross validation and the accuracy metric.The accuracy of a classification is the proportion of correctly classified examples of a specific class out of all its examples [24].

Normal 55%
Weaving 24% Suddend Braking 21% As aforementioned, the framework of specific abnormal driving pattern detection is carried out in two phases (Figure 1): the phase 1 is responsible for distinguishing the normal and abnormal driving patterns, then the detected abnormal ones are further classified with the help of RF and NN classifiers.In the later phase, the feature set is extracted from every sliding window of preprocessed accelerometer data.As described in detail in [23], the feature set combines the features computed on different preprocessed accelerometer components in different domains that consists of 34 time-domain features and seven frequency-domain features and 18 Hjorth features.
For evaluating the performance of each method, we use 10-fold cross validation and the accuracy metric.The accuracy of a classification is the proportion of correctly classified examples of a specific class out of all its examples [24].
where TP, TN, FP, and FN respectively represent the number of true positive, true negative, false positive, and false negative samples.

Normal and Abnormal Driving Pattern Detection
In this implementation, the collected dataset is randomly divided into training (V) and testing (T) datasets with 70% and 30% of data samples, respectively.

• Dynamic Time Wrapping
The performance of the DTW technique on the generic abnormal driving pattern detection is evaluated by computing the similarity between two time series patterns of acceleration data, i.e., the input one and the collected one labeled as normal or abnormal.In this work, the threshold value ε DTW and the window size are investigated in the range (1, 2-10) meter per second squared and (4, 5, 6) seconds respectively.The selection of threshold values is based on the range of the similarity values which is computed as the root sum squared error of acceleration data patterns in each window.
Figure 6 shows the prediction accuracy of the DTW model as a function of threshold value and the window size.Each scene Si -j is represented for the test case at the window size of i seconds and the threshold value of j.The results indicate the difficulty in selecting the optimal threshold to detect the abnormal driving pattern.The accuracy of detection depends much on the collected dataset that must be adequate and representative in various contexts.In the obtained results, the case S6 − 4 is selected that corresponds to the window size of 6 s and the threshold value of 4. By using the selected values, the accuracy of abnormal driving pattern detection based on the DTW model is 61.6%.
Figure 6 shows the prediction accuracy of the DTW model as a function of threshold value and the window size.Each scene Si -j is represented for the test case at the window size of i seconds and the threshold value of j.The results indicate the difficulty in selecting the optimal threshold to detect the abnormal driving pattern.The accuracy of detection depends much on the collected dataset that must be adequate and representative in various contexts.In the obtained results, the case S6 − 4 is selected that corresponds to the window size of 6 seconds and the threshold value of 4. By using the selected values, the accuracy of abnormal driving pattern detection based on the DTW model is 61.6%.

• Machine Learning Method
In this method, the datasets are preprocessed and then transformed into sets of features before the classifiers such as RF and CNN (using Dl4jMlpClassifier package in Weka) are applied to recognize the abnormal patterns.The set of features that was used for activity recognition consists of 34 features in time domain and seven features in frequency domain and 18 Hjorth features [23].In each classification algorithm, the Weka default setting was utilized.For evaluating the performance of each detection algorithm, 10-fold cross validation and the accuracy metric are applied.
Table 2 shows the performance of abnormal driving detection using two classifiers with various window sizes.The results show that the best performance of detection can be obtained with the window size of 6 seconds and the classifier CNN outperforms RF over all window sizes.The highest accuracy of 89.33% is obtained for the classifier CNN.

• Machine Learning Method
In this method, the datasets are preprocessed and then transformed into sets of features before the classifiers such as RF and CNN (using Dl4jMlpClassifier package in Weka) are applied to recognize the abnormal patterns.The set of features that was used for activity recognition consists of 34 features in time domain and seven features in frequency domain and 18 Hjorth features [23].In each classification algorithm, the Weka default setting was utilized.For evaluating the performance of each detection algorithm, 10-fold cross validation and the accuracy metric are applied.
Table 2 shows the performance of abnormal driving detection using two classifiers with various window sizes.The results show that the best performance of detection can be obtained with the window size of 6 s and the classifier CNN outperforms RF over all window sizes.The highest accuracy of 89.33% is obtained for the classifier CNN.• Proposed Method In our proposed method (DAS), the collected datasets are also split into the training set and the testing set that is similar to the above methods.Then, the training set is used in the parameter optimization phase to obtain the optimal parameter set (W, W , ε).Finally, the testing set is used to evaluate the performance.
As aforementioned, the window size W, W , and the threshold value ε are investigated in the range of (4,5,6) seconds, (1,2) seconds, and (0.5,0.6,0.7,0.8,0.9)respectively.Note that DAS must rely on ADM (presented in [23]) that is responsible for identifying a basic activity (S,G, L) corresponding to each data segment with a specific overlapping ratio.The accuracy of the ADM on the training dataset is shown in Table 3 after using 10-fold cross validation.The results show the best performance of ADM can be achieved at the window size of 2 s with 50% overlapping ratio.Next, we investigate the effect of threshold value ε and the window size W on the DAS performance given W = 2 s.Table 4 shows the accuracy of DAS on the training set.The results indicate that the performance is sensitive to the threshold and the best results are only attained in the widow size of 6 s with the threshold ε = {0.5, 0.6, 0.7}.After the parameters of the detection model are properly selected, we estimate the abnormal driving detection model on the testing dataset.The performance of the driving pattern detection, shown in Table 5, presents the accuracy of detection in both abnormal and normal driving patterns.The best performance of 90.43% is attained at the threshold of 0.5, which is higher than the machine learning methods.Although the performance of the normal pattern detection for the threshold of 0.7 outperforms that of the abnormal pattern detection is much lower.Figure 6, Tables 2 and 4 indicate that the proposed method achieves the best accuracy in distinguishing normal and abnormal behaviors with the window size W = 6 s.Hence, this window size will be used in Phase 2 of DAS for identifying specific abnormal driving patterns.

• Discussion
Table 6 shows that choosing the appropriate window to recognize a behavior is very difficult task, especially for unusual actions due to the relatively short time it takes.The experimental results show that the DTW techniques obtained the lowest accuracy, while the proposed method achieved the highest one among three approaches.In addition, DTW techniques rely on the selected threshold to evaluate and classify abnormal behaviors so the results are quite sensitive to the fixed threshold.In contrast, the proposed method is flexible in estimating the threshold value from the training dataset.Hence, it is able to detect abnormal driving patterns that the system never meets in advance.It helps our system deal with the unknown potential dangers on the road.In fact, there are many kinds of abnormal driving patterns.We just use two abnormal driving patterns including weaving and sudden braking for evaluating the proposed method.The collected dataset is eliminated all normal driving samples and then divided into abnormal training (AV) and abnormal testing (AT) dataset with 70% and 30% of data samples, respectively.The size of data segments is 6 s.Note that 10-fold cross-validation is applied.
We also have applied three methods including DTW algorithm, the machine learning methods and the proposed technique to identify various types of abnormal behaviors.Experiments were performed on the same collected dataset to evaluate the performance of each technique.

• DTW Algorithm Based Approach
The DTW algorithm evaluates the accuracy of identification of abnormal behavior types by comparing the similarity between the behavioral patterns of abnormalities on the set AT and the samples on the set AV.All labeled data in AV and AT are cut with the window size W = 6 s.The 6-s data is then further divided into segments with window size W'= 2 s based on the sliding window technique.Next, the featured data will be extracted according to the attribute set that is similar to the set used in the activity recognition model.Identification of behaviors with the window size W data obtains the corresponding set of behaviors.To do the same for the AT data set, we will obtain sequence of behaviors.We then applied the DTW algorithm to evaluate the accuracy when matching these two data sets.Parameters to classify abnormal behaviors are selected from the experiments on Si − j with i = 6 s and threshold j = 4.The results obtained with this experiment are shown in Table 7 below.• Machine Learning Methods In this experiment, we also extracted data according to the same attribute set as above mentioned with data window size W = 6 s.Next, a number of classification algorithms are used including two RF algorithms and CNN (Dl4jMlpClassifier).Experimental results on the data set AT are also shown in Table 7 below.

• Classifying Abnormal Patterns of Driving Behaviors Based on DAS
We also applied the DAS to classify the specific abnormal behaviors.The parameter set (W = 6, W = 2, ε = 0.5) was selected to evaluate the performance of the proposal on the dataset.The experimental results achieved better performance than line based methods (Table 7).

• Discussion
Table 7 shows that RF is able to detect weaving patterns with 100% accuracy.However, its performance drops to 93% in identifying sudden braking patterns.These results indicate that the performance of some machine-learning techniques might be quite sensitive.Indeed, correctly collecting abnormal driving patterns is a difficult task.The DTW returns the better average result, comparing to two machine-learning methods.Overall, the proposed method achieves the highest average performance.

Conclusions
We proposed a novel method, namely DAS, for detecting abnormal driving patterns relying on analyzing sensor data into a sequence of basic driving activities.Indeed, DAS is a combination of the threshold methods and the machine leaning methods.However, the threshold value and other parameters are iteratively induced from the collected datasets.They are thus independent of driving contexts, such as vehicle mode and road conditions.The experimental results indicate DAS outperforms over DTW and the two popular machine-learning methods-RF and NN.Furthermore, the proposed framework for detecting specific abnormal driving patterns-composed of two detection phases-obtains the relatively high overall prediction accuracy of 97.94%.The experiments also illustrate that for distinguishing normal and abnormal driving patterns problem, the longer window size leads to the higher prediction accuracy, as the duration of each basic activity is often long in the normal driving scenarios.In contrast, for specific abnormal driving pattern detection problem, the shorter window size leads to the higher prediction accuracy, as the duration of each basic activity is quite short in the abnormal driving scenarios.Moreover, our experiments also indicate that the performances of some machine-learning methods, such as RF, are quite sensitive.

Figure 1 .
Figure 1.Proposed framework for detecting specific abnormal driving patterns.

Figure 1 .
Figure 1.Proposed framework for detecting specific abnormal driving patterns.

Figure 2 .
Figure 2. Proposed framework of the abnormal driving pattern detection.
e., 1 or 2 seconds.Hence, each basic activity  inferred by ADM with the window size  seconds, can be alternatively considered as a set of k smaller data windows of the size ′ seconds where  = | |.Then,  is further analyzed by ADM as a sequence of k smaller basic driving activities  ,  … where  ∈ {, , , }, j = 1, 2…k.Let  = { ,  … } be the set of sub-labels of  .The sub-label difference of the basic activity  is computed as

Figure 2 .
Figure 2. Proposed framework of the abnormal driving pattern detection.
are smoother in the 'going straight' mode.(a) Abnormal pattern (b) Normal pattern

Figure 3 .
Figure 3.Typical abnormal/normal driving pattern of tri-axis accelerometer data of a basic activity with the duration of 6 seconds.

Figure 3 .
Figure 3.Typical abnormal/normal driving pattern of tri-axis accelerometer data of a basic activity with the duration of 6 s.

Figure 4 .Figure 4 .
Figure 4. Feature extraction process combines the features computed in different domains.

Figure 6 .
Figure 6.Results of pattern detection model using DTW method. −  denotes the test case at the window size of  seconds and the threshold value of j.

Figure 6 .
Figure 6.Results of pattern detection model using DTW method.Si − j denotes the test case at the window size of i seconds and the threshold value of j.

Table 1 .
Summary of recent researches on abnormal driving pattern detection.

Table 2 .
Performance of abnormal driving detection using machine-learning methods

Table 2 .
Performance of abnormal driving detection using machine-learning methods.

Table 3 .
Performance of basic driving activity detection with respect to different small window sizes, overlapping ratios on the training dataset.

Table 4 .
Prediction accuracy of the proposed method with respect to various window sizes and threshold values on the training dataset.

Table 5 .
Prediction accuracy of the proposed method on the testing dataset

Table 6 .
Prediction accuracy for identifying abnormal driving patterns

Table 7 .
Prediction accuracy for identifying various specific abnormal driving patterns