Application of Hidden Markov Model On Car Sensors For Detecting Drunk Drivers
Application of Hidden Markov Model On Car Sensors For Detecting Drunk Drivers
Application of Hidden Markov Model On Car Sensors For Detecting Drunk Drivers
Abstract—The ability to detect drunk driving behavior on can be detected through instantaneous changes in how the car
roadways enhances road safety by significantly reducing the risk is driven like sudden breaking or acceleration, drunk driving
of fatal accidents. In this paper, a set of measurements, readily is best described by slow changes in driving trajectories, in
available via on-board vehicle sensors, was selected to detect
drunk driving behaviors based on learning in accordance with addition to abnormal breaking and acceleration. Therefore,
certain drunk driving cues. A Hidden Markov Model (HMM) the data required by the learning algorithm is mostly a time
method was applied for each of the collected time series data, series data, and therefore, an appropriate machine learning
which correspond to the selected measurements. The prediction framework is needed. In this regard, options like recurrent
accuracy attained using each measured variable was derived and neural network, Auto-regressive Moving Average (ARIMA)
analyzed. The longitudinal acceleration achieved the best average
prediction accuracy, for detecting both drunk and normal driving based models, and Hidden Markov Models (HMM) can be
behaviors, with an accuracy that is equal to about 79%. used. In this paper, the prediction power of Hidden Markov
Index Terms—Drunk Driving Detection, Vehicle On-board Models, which seeks to recover a sequence of states based on
Sensors, Time Series Analysis, Hidden Markov Model, CarSim. an observed series of data, will be investigated in predicting
drunk drivers based on car sensors data.
I. I NTRODUCTION The measurements of the selected sensors are available
Drunk driving crashes claim the life of one person every 50 through the Controller Area Network (CAN) bus of the car
minutes, causing the death of 10 497 people in 2016 across which connects the on-board unit (OBU) to the various sensors
the United States [1]. According to the National Highway and actuators in the car. Hence, we propose through this
Traffic Safety Administration (NHTSA), the number of deaths paper for the OBU to run our proposed algorithm and provide
caused by alcohol-related crashes has significantly decreased detection results in real time, so that corresponding actions
since the early 1970’s [1]. The drop is associated with several are taken to prevent related accidents from occurring. Such a
factors such as law enforcement efforts, education programs, prevention could be realized through enabling the car’s OBU to
traffic safety legislation, and others. As the worldwide use take over to safely bring the car to a stop, to alert neighboring
of automobiles is increasing, the efforts to eliminate drunk cars using vehicle-to-vehicle communication, and/or to notify
driving behavior on roadways are still advancing to improve family members or the police. Such a capability is becoming
road traffic safety with minimal social and environmental increasingly possible with the ongoing trends of making cars
impact. Consequently, many research communities and indus- smarter and able to communicate with the surroundings.
tries were committed to analyzing drunk driving behavior and The paper is organized as follows. In Section II, state of the
corresponding vehicle usage patterns for better anticipation of art methods for drunk drivers detection were reviewed, where
the impairment. different approaches were elaborated. Section III describes
The work in this paper is in line with the global effort our proposed method for collecting data and applying HMM
of just-in-time detection especially with the advent of car for identifying drunk driving. The performance of the applied
computer assisted driving, whereby the car could be instructed machine learning method was evaluated in section IV using
to slowly come into a stop when such a detection is made. experimental data. Finally, section V summarizes the paper.
The distinguishing feature of the proposed method is relying
solely on the normal on-board sensors available on virtually all II. R ELATED W ORK
cars. A machine learning based methodology is employed for The subject of detecting drunk drivers is widely tackled
learning about the cues associated with drunk driving behavior in literature, and there are different methods adopted for
and how to distinguish it from normal driving. Such cues are this purpose. Generally, most of the techniques are based on
described in the NHTSA report [1], which includes drifting, using breath sensors, or depending on smart phone sensors, or
swerving, weaving, etc. In contrast to aggressive driving which implementing cameras in cars and applying image processing
techniques on face images. Hence, the proposed techniques
The authors would like to thank the University Research Board (URB) of
the American University of Beirut for the generous gift, which funded this mostly involve external sensors and equipment that are not
work. normally built-into the car system, and therefore do not easily
allow for interacting with the car’s powertrain in order to allow In summary, the reviewed approaches and techniques show
it to mitigate the situation. In contrast, our approach depends the feasibility of detecting drunk drivers intelligently based
totally on the readily available measurements of the sensors on driving behavior, but have various disadvantages, as we
of the car that are instantly accessible to the OBU through the have pointed out. The novelty of our approach is that it takes
CAN bus to detect drunk driving behaviors. into consideration the time series nature of the data collected
In [2], the authors propose a method for detecting drunk from car sensors, which leads to better prediction accuracy.
drivers using mobile phones. The authors implemented a Moreover, our method perform prediction based on every car
mobile application that utilizes the accelerometer and ori- sensor data separately, which allows identifying the relevance
entation sensors in the phone to identify driving patterns of every sensor measurement in the detection of drunk drivers.
that characterize drunk driver’s behavior. These patterns are
extracted based on the NHTSA report [1] which identifies the III. S YSTEM M ODEL
cues of typical driving behavior of drunk drivers. However, A. Selection of On-board Sensor Measurements
this method, which uses the accelerometer, assumes that the
Drunk driving behaviors can be labeled according to four
phone is always in a fixed location with respect to the car
categories, according to field studies conducted by the NHTSA
which is not the case when the driver uses the phone while
[1]:
driving, or when the phone is not fixed to the car’s structure.
• Problems in maintaining proper lane position
Second, this detection method requires continuous monitoring
• Speed and braking problems
of the phone sensors, which may drain the battery of the phone
• Vigilance problems
unless it is connected to a power outlet in the car. Third, and
• Judgment problems
as we have mentioned, this does not integrate with the car’s
OBU, so the latter can take precautionary actions once drunk As enlisted in the Driving While Intoxicated (DWI) detection
driving is inferred. guide [1], each one of these categories has several visual
In [3], the authors used an On-board Diagnostic (OBD2)- driving cues tied with a high Blood Alcohol Concentration
Dongle to collect data from the car sensors. After processing (BAC) at a given probability. In addition, the probability of
the data collected from the sensors, the authors computed a driver being drunk increases when more than one cue is
different statistical measurements over a fixed time window. observed. For instance, maintaining proper lane position is a
Next, they used a logistic regression algorithm to classify challenging task for a drunk driver, and its major cues are
the data as drunk or normal driving data. However, this illustrated in Fig. 1. All these four cues require excessive
classification method is considered inadequate for the data steering angles, which in return excite the vehicle’s lateral
under consideration since this method ignores the correlation dynamics, as well as roll dynamics when cornering [9]. As
between samples in the time series data that is collected from for the speed and braking problems, the vehicle’s longitudinal
the sensor. dynamics as well as the pitch dynamics are directly affected.
In [4], the authors segmented the car sensor time series
data according to a Piecewise Linear Representation (PLR)
algorithm [5], then they found the first order polynomial
interpolant for each segment that best fits the data. Afterwards,
they used the slope and the time interval of each segment as
the extracted features. Finally, they applied a Support Vector
Machine (SVM) algorithm to classify the extracted features
and detect the drunk drivers. The issue with this technique
is that the followed segmentation method looses valuable
information from the collected data. Moreover, only two car
sensors, which are the lateral position and steering angle data
were used in that work. Finally, the PLR segmentation method
requires a full view of the series under consideration which
makes it not suitable for real time detection applications.
In [6], the authors used a multi-layer perception (MLP) and
support vector machine (SVM) [7] to decide if the alcohol
concentration in drivers blood was over 0.4 g/L based on car
sensor measurements, and consequently to decide if the driver
is drunk or not. The authors in [8] developed three algorithms
for detecting drunk driving based on car sensors data. One Fig. 1. Cues related to maintaining proper lane position [1]
algorithm employed logistic regression, the second one utilized
decision trees, while the third used a support vector machine. Hence, by a suitable selection of a set of variables to map
Similar to the above approaches, all these algorithms do not the vehicle’s dynamics into the driver’s behavior, the driving
consider the time series nature of the car sensor data. cues can be better exposed. A close examination of the drunk
2018 IEEE International Multidisciplinary Conference on Engineering Technology (IMCET)
driving cues’ impact on vehicle dynamics is essential for this which delivers accurate simulation of vehicle dynamic perfor-
selection. This step consists of identifying the following: mance [12]. In addition, Drunk Busters goggles were used by
• The driver’s inputs which produce the drunk driving the participants to simulate vigilance and judgment problems
cues,hence the choice of the steering wheel angle, and that a driver is subject to when his BAC ranges between
throttle position (which directly relates to the extent to 0.04 and 0.35 [13], e.g. visual distortion, depth and distance
which the driver presses on the gas pedal). perception problems, delayed reaction time, and so on.
• The vehicle’s lateral and longitudinal velocities, along The Driving Simulator (DS) package in CarSim ® is used
with the accelerations in the longitudinal, lateral, and to interface with the motion simulator where the configuration
vertical directions as a consequence of the driver’s inputs. of the export channels was employed to record the selected
• The variables depicting the excitation of the vehicle variables in Table I during each driving run [14]. The sampling
dynamics when the cues in Fig. 1 occur, such as the side time was set to 0.025sec, hence the sampling frequency
slip angle, yaw, roll, and pitch rates. SamplingF req is equal to 40Hz. The vehicle initial speed, as
• The error on the position of the center of gravity with well as the road type, and desired trajectory are among many
respect to the center of the lane reflect the inability of adjustable parameters of a given run, which were set once
the driver to maintain the vehicle in a proper position. before training the participants to drive the motion simulator.
The measured variables used in this work along with their The trajectory shown in Fig. 3 is the center of the lane, which
description are defined in Table I. Data collection for each ideally, the normal driver will tend to keep the vehicle’s Center
variable is achievable even for real time applications, since of Gravity (COG) aligned with, whereas a drunk driver will
all the variables can be accurately measured via existing tend to drift away from the center of the lane when following
on-board sensors, excluding the vehicle speed and the side the drunk driving cues.
slip angle. However, reliable estimation schemes can also
be used to observe both vehicle speed and side slip angle
based on existing measurements [10], [11]. In our work, data
was collected from 13 selected on-board measurements on a
CarSim ® simulator, where the time series data corresponding
to each measured variable were acquired and recorded on an
excel spreadsheet for training and testing the machine learning
engine of our detection technique. The experimental process
is elaborated next.
TABLE I
S ELECTED VARIABLES
Variables Description
SteerDM The driver’s steering wheel input
T hrottle The driver’s control to regulate the gas pedal
Beta The vehicle’s COG body side slip angle [10]
Xdev The difference between the X coordinate
of the center of the lane and the actual vehicle COG
Ydev The difference between the Y coordinate
of the center of the lane and the actual vehicle COG
Vx The vehicle’s longitudinal speed at the COG
Vy The vehicle’s lateral speed at the COG
AVz The vehicle’s yaw rate, i.e. the angular
speed w.r.t. the vehicle’s vertical axis
AVy The vehicle’s pitch rate, i.e. the angular
speed w.r.t. the vehicle’s lateral axis
AVx The vehicle’s roll rate, i.e. the angular
speed w.r.t. the vehicle’s longitudinal axis
Ax The vehicle’s longitudinal acceleration
Ay The vehicle’s lateral acceleration
Az The vehicle’s vertical acceleration
Fig. 2. Motion Simulator
first introduced to the motion simulator and the hardware to generate the emissions is unknown. Analyses of the Hidden
interfaces like the steering wheel and the pedals. Next, a Markov Models basically seek to recover the sequence of
demonstration on how to drive the motion simulator took states from the observed data [15].
place, followed by having each participant get behind the In the considered application, we observe the sequence of
wheel to train for about an hour to get a feel of how the measurements by the selected on-board sensors, as emissions,
platform responds to his/her input by replicating the physics. and our objective is to predict the driver’s state that generated
Afterwards, the drunk driving cues were explained and the the observed sequence [15].
differences in the driver’s performance during drunk and The procedure followed in collecting and pre-processing
normal driving conditions were highlighted to the participants the data, applying the HMMs, and evaluating its prediction
while testing the goggles. performance is summarized in Fig. 4.
Each participant emulated two driving behaviors while
driving the simulator to follow the predefined trajectory. Each
driving run consists of finishing the track, and recording the
selected variables throughout the duration of each run. Each
participant started by simulating the normal driving behavior
by completing 3 runs. Each participant was then asked to
wear the goggles and emulate the drunk driving behavior
throughout the three runs that he or she drove. Finally, it is
worth mentioning that the participants were supervised during
the driving sessions and were trained on simulating the drunk
driving cues on the motion simulator platform before the
experiment.
600
400
200
Y (in m)
-200
-400
-600
-200 0 200 400 600 800 1000
X (in m)
1) Training: After collecting the time series data of the 2) Testing: The trained models, corresponding to each
selected 13 measured variables, the following pre-processing measured variable, were then tested over the cross validation
steps were performed. The data corresponding to the first data. A detection window, with W indowSize = 5sec, is
few seconds of each run were truncated, since this interval defined to detect the state of the driver. For each detection
contained random data and thus can be misleading to the window, an optimization problem for finding the most likely
classification procedure. Next, the data corresponding to each sequence of states that produced the observed sequence of
time series was normalized into 100 discrete levels from 1 measurements is solved.
to 100. This step is important since each set of time series More formally, given as an input a trained HMM with
generated has different range of values, and given that the transition and emission probability matrices: A and B, and
HMM only accepts integer input data over a well defined scale a sequence of observations O = o1 , o2 , ..., oT , we aim to find
of values. A label describing the state of the driver was added the most probable sequence of states Q = q1 , q2 , q3 , ..., qT ,
to each sample of the time series data. This label is used for where T = SamplingF req × W indowSize. This uncon-
the supervised learning of the HMM, and for the evaluation strained optimization problem which has the objective function
of the model prediction accuracy while testing it. The labels presented in Eq. 1 is solved using the Viterbi Algorithm [18]
defined are the following: to find the optimal sequence of states Q∗ .
• Initial state (S1 ): The starting state of any driver.
• Normal state (S2 ): The state when the driver’s behavior
Q∗ = argmax P (Q|O) (1)
Q
is normal.
• Drunk state (S3 ): The state when the driver’s behavior is After identifying the optimal driver’s state sequence based
as drunk. on the observed measured data, the decision over the window
Finally, the annotated data generated by all the runs of all under consideration is taken according to the majority of the
participants and in different states were concatenated together. states decoded over the window. Hence, the driver’s state
At this stage, we have one time series, Xj , corresponding to predicted over specific time window, S ∗ , is computed as
each measured variable j which contains all the generated data follows:
under drunk and normal driving behavior.
Consistent with the literature, the data samples in each time S ∗ = Sj if mode(Q∗ ) = Sj for j = 1, 2, 3. (2)
series Xj were then split into 70% as training data and 30%
A sliding window mechanism, shifted by one step at each
as testing or cross-validation data.
iteration is used over all the testing data to predict the driver’s
Using the terminology of HMM, the normalized data cor-
state. This is done for all the measured variables and their
responding to a certain measured variable j, which forms the
corresponding HMMs to evaluate their prediction accuracy as
time series Xj , form the observations:
elaborated in Section IV.
Oj,i for j = 1, ..., M and i = 1, ..., N .
The recorded running time of the adopted method for every
where M is the total number of measured variables, and N
5 seconds window is 1 msec on average. This ultra short
is the number of time steps recorded.
execution time for making a decision allows applying our
Using the statistics and machine learning Toolbox in MAT- method in real time.
LAB [17], a Hidden Markov Model was generated for each
selected variable. The observed measurements recorded Oi for IV. P ERFORMANCE E VALUATION
a given selected variable j, in addition to the annotated labels
were fed into the HMM model for training. In this supervised The performance of each HMM corresponding to a given
training, the model input is a sequence of observations associ- measured variable is evaluated, as well as its effectiveness in
ated with the states that generated these observations. By the terms of capturing the drunk drivers cues described in [1] is
end of the training phase, the parameters of each instantiated investigated in this section.
HMM for each measured variable j we estimated using the The trained HMMs are used to predict the driver’s state over
Maximum likelihood Estimation algorithm [16]. In our HMM the cross-validation data. The accuracy ASj of the prediction
application, the estimated parameters are the following: decisions for each measured variable j and for each driver
state S is evaluated. The state S can either be drunk (d) or
• Transition probabilities matrix (A): A 3 × 3 matrix that
normal (n):
is made up of the probability of transition from any state
Si to any state Sj for i = 1, 2, 3 and j = 1, 2, 3.
N
• Emission probabilities matrix (B): A 3 × 100 matrix that X
contains the probability of occurrence of an observation ASj = bSj (3)
i=0
Oi given that the state was Sj where i = 1, ..., 100 and
j = 1, 2, 3. where
The recorded running time of the training phase for every
(
1, Sj∗ = S
Hidden Markov Model on 2.4 GHz core i7 x86 machine was bSj = (4)
240 msec. 0, otherwise.
2018 IEEE International Multidisciplinary Conference on Engineering Technology (IMCET)
In the above, N is the total number of detection windows about 79%. Collecting more driving data can certainly enhance
evaluated over the cross-validation data, and Sj∗ is the pre- the achieved results, since the models can probably be trained
dicted state based on a given measured variable j. better. Additionally, implementing a method that combines
The performance in terms of the accuracy results corre- the decisions of different sensors in a smart way can also
sponding to each measured variable in detecting drunk and achieve promising results. Finally, taking into consideration
normal driving states is shown in Fig. 5. data related to the driving environment of the driver, such as
driving time, the location of the car (e.g., near night clubs) can
certainly enhance the classification scheme and achieve better
results.
R EFERENCES
[1] U.S. NHTSA, “The Visual Detection of DWI Motorists”,
https://www.nhtsa.gov/sites/nhtsa.dot.gov/files/documents/808677.pdf.
[2] J. Dai, J. Teng, X. Bai, Z. Shen and D. Xuan, “Mobile phone based
drunk driving detection”, 4th Intrn’l Conf. on Pervasive Computing
Technologies for Healthcare, Munich, 2010, pp. 1-8.
[3] A. El Basiouni El Masri, H. Artail and H. Akkary, “Toward self-
policing: Detecting drunk driving behaviors through sampling CAN
bus data”, Intrn’l Conf. on Electrical and Computing Technologies and
Applications (ICECTA), Ras Al Khaimah, 2017, pp. 1-5.
[4] Z. Li, X. Jin, X. Zhao, “Drunk driving detection based on classification
(a) First set of measured variables. of multivariate time series”, Journal of Safety Research, v. 54, 2015, pp.
61.e29-64.
[5] E. Keogh, S. Chu, D. Hart, M. Pazzani, “An online algorithm for
segmenting time series”, IEEE Intrn’l Conf. on Data Mining, San Jose,
CA, 2001.
[6] A. Robinel, D. Puzenat, “Multi-user blood alcohol content estimation
in a realistic simulator using artificial neural networks and support
vector machines”, European Symp. on Artificial Neural Networks,
Computational Intelligence and Machine Learning, pp. 2426, 2013.
[7] C. Cortes, and V. Vapnik. “Support-vector networks”, Machine learning.
[8] J. Lee, D. Fiorentino, M. Reyes, T. Brown, O. Ahmad, J. Fell, “Assessing
the feasibility of vehicle-based sensors to detect alcohol impairment”,
DOT HS 811358 Washington, DC: National Highway Traffic Safety
Administration.
[9] R. Rajamani, “Vehicle Dynamics and Control”, Springer, 2006.
[10] C. Bardawil and N. Daher, “Combined fuzzy and nonlinear dynamic
observer for vehicle longitudinal velocity and side-slip angle”, 11th
Intrn’l Symp. on Mechatronics and its Applications (ISMA), 2018.
(b) Second set of measured variables. [11] U. Kiencke and L. Nielsen, Automotive Control Systems, for Engine
Fig. 5. Accuracy achieved by each measured variable in predicting both Driveline and Vehicle, Germany: Springer, 2005.
normal and drunk states. [12] Simcraft ® , [available online], https://www.simcraft.com/.
[13] Drunk Busters of America LLC, [online] Available:
http://drunkbusters.com/.
Clearly, the vertical acceleration (Az ) achieves the highest [14] CarSim ® , [available online], https://www.carsim.com/products/ds/.
accuracy in detecting normal driving with a prediction ac- [15] L. Rabiner, B. Juang, “An Introduction to Hidden Markov Models, IEEE
curacy that reaches 94.51%. On the other hand, the angular ASSP MAGAZINE , Jan. 1986.
[16] A. Bernhard, “Asymptotic Properties of Conditional Maximum-
rate of the car (AVx ) gives the highest accuracy in detecting Likelihood Estimators, Journal of the Royal Statistical Society. Series B
drunk drivers with an accuracy of 85.7%. Finally, the mea- (Methodological), v. 32, n. 2, 1970, pp. 283301. JSTOR, JSTOR.
sured variable which achieves the best prediction accuracy, on [17] MathWorks, (2018). Statistics and Machine Learning Toolbox: User’s
Guide (R2018a). Retrieved June 01, 2018 from www.mathworks.com.
average, for both drunk and normal states is the longitudinal [18] G. Forney, “The viterbi algorithm”, Proceedings of the IEEE, v. 61, n.
acceleration with an accuracy of 79.14%. Recalling the drunk 3, pp. 268-278, March 1973.
driving cues described in [1], one can estimate the importance
of the longitudinal acceleration sensor in capturing these cues,
which are best measured through this sensor.
V. C ONCLUSION
In this work we investigated the information collected from
a set of vehicle on-board sensors to study its resemblance to a
set of cues defined by NHTSA that characterize drunk driving.
Different Hidden Markov Models were trained for the mea-
sured variables of the considered sensors, and their prediction
accuracy was analyzed. The longitudinal acceleration sensor
achieved the best average prediction accuracy for detecting
both drunk and normal driving states, with an accuracy of