Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
Detecting and Characterizing Driving Events Using Smartphone Nidhi Kalraa, Divya Bansalb Computer Science and Engineering Department, PEC University of Technology, Chandigarh, India {
[email protected],
[email protected]}
Abstract The numbers of accidents are increasing with the increase in number of vehicles on the roads. It has made it imperative to monitor driver’s behavior for promoting driver’s safety, help the driver to know his own driving style, help various transportation agencies to monitor driving habits and thus lower the risk of traffic accidents. It also aims to help various government and private agencies in monitoring driver behavior to promote safety of public transport, private taxis, school buses etc. In this work machine learning techniques have been used to analyze driving patterns. Using the data collected from accelerometer sensors present in a Smartphone. Patterns were generated to characterize driving behaviors. By observing the pattern of different driving events, from the collected data, decision tree model was built, which is further used to classify unknown data into different classes. Keywords- Left Turn; Right Turn; Normal Braking;Sudden Braking; Sudden Forward Acceleration; Automata; Gradient Data; and Decision Tree.
1. Introduction Road accidents occur frequently in our everyday life. Recent studies have shown that it is one of the biggest causes of death in many countries around the world Chang & Lin, 2010. Travelling in India by roads is considered very dangerous as the flow of traffic is chaotic, people drive very fast, harshly without obeying the traffic rules, cross speed limits and overtake others, drive dangerously, honk horns often. So there is a need to monitor driver behaviour and it is a well known common belief that if person behaviour is being monitored, it would be relatively safer. Previously a lot of work is done in this field but researchers mainly focused on monitoring driver behaviour using specialized hardware deployed inside the car or roadside which is expensive and also requires maintenance. Also researchers focused on determining the patterns, machine learning techniques have not been used. Our method, contrary from previous work, use accelerometer sensor of Smartphone to observe the pattern of driver’s driving style and also these patterns are classified using machine learning techniques. This paper is organized as follows, section 2 describes present state of the art in the literature, section 3 discusses system designed and proposed methodology to detect and classify various driving behavior events, section 4 the results of test samples classified by proposed method and accuracy rate and section 5 provides the conclusion and future scope. 2. Related Work In this section present state of the art in the literature and the available applications that could be found at the moment on the market are discussed. Fazeen et al., 2012 have proposed a android application to evaluate driver style. They have used the three-
78
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
axis accelerometer of an Android-based Smartphone to record and analyze various driver behaviors and external road conditions. They have utilized x-axis and y-axis accelerometer data to analyze the driver’s behavior. Safe acceleration or deceleration never reach a g-force of more than±0.3 g, and sudden acceleration or deceleration approach ±0.5 g .Safe right/left-lane produce an average g-force of less than ±0.1 g and unsafe or sudden right/left lane produce a g-force well over±0.5 g An android application is developed by Chirgupta et al., 2012 to give rating to the driver. They used accelerometer sensor, GPS sensor and camera for video recording .They specified range for safe acceleration/deceleration and specified when the data of accelerometer exceed these safe limit, there is an occurrence of event. Zhang et al., 2010 proposed a Pattern recognition approach to characterize drivers based on their skill level. Driving Skill level was defined as low, medium, or expert level, or a simple 1-to-10 scale. The input values they have taken are DFT coefficient of steering wheel angle and accelerator. They used machine learning techniques which includes multilayer perception artificial neural networks (MLPANNs), decision tree, and support vector machines (SVMs). The SVM with polynomial kernel shows better performance than both the MLP-ANN and the decision tree. 3. System Details In this section, we will describe our solution, algorithm and present the details of data collection, preprocessing, automata design, and classification processes. Our system consists of two phase: Training Phase Testing Phase 3.1 Algorithm 3.1.1Training Algorithm Input: text file containing the raw data collected using mobile application. Output: decision tree model for turns and braking, acceleration events. 1. Preprocess the raw input data. a. Calculate gradient data. b. Store in .csv format 2. Divide the data into windows of 1 sec for turns and 600ms for braking and acceleration event. 3. Label the data using automata and store in .arff format for training of classifier. 4. Train the decision tree classifier using labeled data. a. Check for base cases b. For each attribute a, find the normalized information gain ratio from splitting on a c. Let a_best be the attribute with the highest normalized information gain. d. Create a decision node that splits on a_best e. Recurse on the sublists obtained by splitting on a_best, and add those nodes as children of node. 3.1.2 Testing Algorithm Input: text file containing the raw data collected using mobile application. Output: classified and labeled data. 1. Preprocess the raw input data. a. Calculate gradient data.
79
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
2. 3. 4.
b. Store in .csv format Divide the data into windows of 1 sec for turns and 600ms for braking and acceleration event. Label the data using decision tree classifier and store in .arff format. Analyzing the false positive and false negative rate for each event.
Figure 3.1 System Flow Diagram
3.2 Training Phase The steps in training phase are 3.2.1 Data Collection Data is collected from accelerometer sensor present in Smartphone using the self developed android application “Data_Collection”. All values of accelerometer sensor i.e. x, y and z are fetched from Smartphone’s internal hardware sensor. The sampling rate of data collection is 5 reading per second i.e. at time interval of 200ms. While collecting the data, the phone is placed at fixed location at dashboard of a car in portrait mode, Xaxis- points toward right along the smaller side, Y-Axis points up along longer edge and Z-Axis- points towards the sky perpendicular to the plane of the front face of the screen. 3.2.2 Preprocessing The output of data collection module is fed into preprocessing module. There are certain problems in raw data: • Wide range of values observed • Data is noisy • Data shows False Positive and False Negative Rate • Data is not in normalized form • Data is device dependent as different devices have different levels of sensitivity and show different readings for the same event, so it is difficult to set a common threshold for every phone. Therefore, there was a need to do some preprocessing of data. The preprocessing module provides the gradient data. Gradient data is obtained by calculating the difference between the two consecutive values i.e. x2-x1, x3-x2 and so on. The feature used for classification is difference between the consecutive values.
80
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
3.2.3 Automata The gradient data is divided into window of 1 sec along x-axis for turns with sampling rate of 5 readings per window and 600ms along y-axis for braking and forward acceleration event with sampling rate of 3 readings per window. Gradient data is fed into automata module for detecting the pattern of various driving events, thereby to label the training data. 3.2.3.1Pattern Analysis After analyzing the gradient data and doing various experiments, patterns of various driving events are analyzed and threshold is determined. Several experiments are done to verify these values When the vehicle is at rest or moving straight on a smooth road, then also there will be slight deflection in the value of accelerometer. Therefore, the values of x, y and z axis of accelerometer within the range from ‘-1g to 1g’ are considered stable as no event is detected within this range. Table 1 shows the threshold values of various events.
Event
Axis Used for Detection
Threshold
Normal Braking
y-axis(in negative direction)
-1g to -3g
Sudden Braking
y-axis(in negative direction)
3g
Left Turn
x-axis(in negative direction)
1g
Fig 3.2 Patterns of Driving Events
81
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
3.2.3.2 Discretization of data Discretization refers to the process of converting or partitioning continuous attributes, features or variables to discritized or nominal attributes, features, variables or intervals. By observing the range in which the values lies in gradient data, the data is partitioned into intervals and are each interval is denoted by an alphabetical symbol.The gradient data is discretized on number line as follows: ‘a’ is the interval less than -3 ‘b’ is the interval between -3 and -2 ‘c’ is the interval between -2 and -1 ‘d’ is the interval between -1 and 0.75 ‘e’ is the interval between -0.75 and 0.75 ‘f’ is the interval between 0.75 and 1 ‘g’ is the interval between 1 and 2 ‘h’ is the interval between 2 and 3 ‘i’ is the interval greater than 3 3.2.3.3Regular Expressions Automata are used to label the training data based upon the patterns of various driving events. The automata are implemented using regular expressions expressed in terms of symbols provided during discritization of data. Table2 Regular Expressions for various Events
Event Left Turn Right turn Normal Braking
Regular Expression (d|e|f|g|h|i)*(a|b|c)[a-i]* [a-f]*(g|h|i)[a-i]* A.) (a|b|c|d|e|f)*((g|h|i)+(a|b))[a-i]*) B.) (a|d|e|f|g|h|i)*(b|c)[a-i]*
Sudden Braking
([b-i]*a[a-i]*)
Sudden Forward Acceleration
((a|b|c|d|e|f|g|h)*i(e|f|g|h|i)*(a|b|c|d)[a-i]*)+
3.2.3.4Automata Design Model The automata are designed based upon the regular expressions specified above. 3.2.4 Decision Tree Classifier Decision tree model is constructed by analyzing database tuples described by attributes. Each tuple is assumed to belong to a predefined class, as determined by one of the attributes called the class label attribute. The individual tuples making up the training set are referred to as training samples and are randomly selected from the sample population. Since the class label of each training sample is provided, this step is known as the supervised learning (i.e., the learning of the model is “supervised”) in that it is told to which class training samples belongs).Then the learned model is represented in the form of decision trees.
82
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
Figure 3.3 Decision Tree Model of Brakes
Figure 3.4 Decision Tree Model of Turns 3.3 Testing Phase The steps in training phase are: 3.3.1 Data Collection Data collection method is same as for training of model except one of the Smartphone was used for the collection of the sensor data and the other one was used for marking the events to create the ground truth data. Furthermore, time synchronization between the two Smartphone’s was performed to achieve high accuracy for both the sensor and event timestamp data. We used “Data_Collection” self developed application for collecting sensor data and “Event Timestamper” application available in android play store for labeling events with accurate time stamps. The numbers of events (Left turn, Right turn, Normal Braking, Sudden Braking, Sudden Forward Acceleration) are noted, and then used this knowledge for labeling. 3.3.2Preprocessing Then preprocessing on data is done to find the gradient of data. The feature used for classification is difference between the consecutive values which is fed into machine learning classifier. 3.3.3Classifier Engine
83
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
Classifier Engine basically takes two inputs 1. Gradient data 2. Decision tree model built from training data. Classifier engine analyze the class of an unlabeled sample, or to assess the value or value ranges of an attribute that a given sample is likely to have with the help of decision tree model obtained in training phase. Then the learned decision tree model of driving event recognition can be used to classify future data tuples or objects for which the class label is not known or unknown. 3.3.4Analyzer Finally we manually match the event, and find the false positive and false. 4. Results and Discussions In this section the results of test samples classified by proposed method and accuracy rate is discussed. 4.1 Experimental Results We have performed experiments on different data sets to find the accuracy of our algorithm. The details of testing are as given below a. Brake and Sudden Forward Acceleration Table 3 Distribution of events of training data Table 4 False Positive and False Negative Rate
Correctly Classified Instances: 419 Success rate (in percentage): 97.2157 %
84
Incorrectly Classified Instances: 12,
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
b.
Turns
Table 5 Distribution of events of training data Table 6 False Positive and False Negative Rate
Correctly Classified Instances: 237 Incorrectly Classified Instances: 27 Success rate (in percentage): 89.7727 % As analyzed on different data sets, it has been observed that the average classification accuracy for braking and acceleration events is 97% (approx.) and for turns is 89% (approx.). 5. Conclusion and Future Scope 5.1 Conclusion In the present work, techniques have been developed which can analyze driving events using Smartphone Sensor. Results show that the proposed algorithms are able to detect driving events with accuracy rate of 89% (approx) for turns and 97% (approx) for braking and sudden acceleration. The work will be useful in many applications such as government and private agencies who hire driver’s for driving various modes of transport such as school buses, ambulances, taxis through which the driver’s driving behavior can be monitored in order to promote the safety of driver’s, passengers and of vehicles as well. Analyzing driver behavior can lower the risk of road accidents and also helpful for the driver’s to improve their own driving style. 5.2 Future Scope In the future application can be designed to give real time warning to driver, if driver drives rashly using algorithms so devised. Besides that instead of static rules, temporal fuzzy logic can be used to classify and label future data tuples. Different classifier can also be observed to find out some better classifier
85
© Elsevier Publications 2014.
Proceedings of 1st International Science & Technology Congress 2014 ISBN: 9789351072485
than Decision Tree. Also there is a chance to use multiple sensors such as magnetometer, gyroscope and camera instead of only accelerometer. Future researchers can also try their hands on Bus, Trucks, and auto rickshaw data for analyzing Driving events. Acknowedgements This work is done under the sponsored project CARTS (Communication Assisted Road Transportation System) funded by Media Lab Asia. References C.-C. Chang and C.-J. Lin. Libsvm: a library for support vector machines. ACM Transactions on Intelligent Systems and Technology (TIST), 2(3):27, 2011. Chigurupati, S., Polavarapu, S., Kancherla, Y., & Nikhath, A. K., June 2012, Integrated Computing System for Measuring Driver Safety Index, International Journal of Emerging Technology and Advanced Engineering, Volume 2, Issue 6. Fazeen, M., Gozick, B., Dantu, R., Bhukhiya, M., & González, M. C. 2012, Safe driving using mobile phones, Intelligent Transportation Systems, IEEE Transactions on, Mar 13, 2012, pp.1462-1468 Zhang, Y., Lin, W. C., & Chin, Y. K. 2010, A pattern-recognition approach for driving skill characterization, Intelligent Transportation Systems, IEEE Transactions on, April 11,2010,pp. 905-916.
86
© Elsevier Publications 2014.