2
$\begingroup$

I am using a smartphone in my car to gather acceleration data (both longitudinal and lateral). Now, I want to classify my data in real-time based on the acceleration force applied through accelerating, breaking and maybe turning.

Is there a proper method to do this kind of online classification? And also how does one determine whether a "harsh/aggressive" or just "normal" driving style?

enter image description here

$\endgroup$
2
  • $\begingroup$ Latitude and longitude are position data not acceleration data. Are you suggesting that position vs. time be used to derive acceleration, or do you additionally have acceleration data from the phone's accelerometer? Could you post some samples of your data? This will take this question from highly abstract to a more concrete example that we can help you with. Thanks! $\endgroup$
    – AN6U5
    Jun 9, 2016 at 15:55
  • $\begingroup$ @AN6U5 Sorry, I might not be able to make it clear enough what I want to achieve then. Longitudinal and lateral just means that I am able to gather acceleration data separately in forward/backward direction (longitudinal) as well as in left/right direction (lateral). I also added a picture for better understanding and I will try to add a data sample by tomorrow too. $\endgroup$
    – R. Doe
    Jun 9, 2016 at 19:22

1 Answer 1

1
$\begingroup$

Supervised vs. Unsupervised Learning

You will first need to decide whether to approach this as a supervised or unsupervised learning problem.

For supervised learning, you would need to take some portion of the data and hand score it as harsh/aggressive and normal. I suggest you not go this route to start. But if you do, I suggest using a support vector classifier for your initial testing.

I suggest approaching this as an unsupervised learning problem. Assuming you tend to be a normal/safe driver you can view this behavior as normal and harsh/aggressive driving as an anomaly or an outlier. This is known as outlier detection.

Feature Engineering

Feature engineering will play a significant roll in this problem. Despite your attention to the longitudinal and lateral axes of the car, the phone will have arbitrary orientation within the car i.e. it will just be in your pocket. Thus its probably best to factor out the direction somewhat.

First, I would find the length of the acceleration vector (magnitude of acceleration without regard to its directional orientation). Since you have three orthogonal axes, you can just use:

$$||\mathbf{a}||=\mathbf{a}_x^2+\mathbf{a}_y^2+\mathbf{a}_z^2=a$$.

Additionally, you can also integrate the acceleration vector over time and find its magnitude to find the vehicle speed:

$$speed=||\mathbf{v}||=\mathbf{v}_x^2+\mathbf{v}_y^2+\mathbf{v}_z^2=v$$

where $$\mathbf{v}(t)=\int_{start-of-trip}^t\mathbf{a}(t)$$

The speed is very useful in determining the difference between different modes of acceleration e.g. driving around in a circle will yield constant acceleration, but also constant speed vs. holding down the gas pedal and driving straight, which could yield constant acceleration with changing speed.

An important aspect of this method lies in the fact that integrals of your data will tend to damp noise, where as derivatives (differences) will tend to amplify noise. Don't take derivatives of your data.

Outlier Detection

At this point you can normalize the speed and acceleration-magnitude and find the mean and standard deviation of both values. When your normalized speed and acceleration-magnitude lies outside of some z-value, say two standard deviations, then you can classify your driving as dangerous.

Don't forget to think of speed and acceleration as orthogonal values and form a circular function out of the respective z-values for proper outlier detection. You can read about 2D or nD outlier detection and also here

Remember that the equation for a circle is:

$$r^2=a^2+v^2$$

We can therefore solve for $r$ and set it equal to $2$ standard deviations.

As an aside, note that since variance is just the square of the standard deviation, you could alternatively think of this in terms of variance.

Now for two standard deviations, the driving is aggressive if:

$$\sqrt{\big(\frac{v-\mu_v}{\sigma_v}\big)^2+\big(\frac{a-\mu_a}{\sigma_a}\big)^2} \gt2$$

The online learning component simply requires that you continuously update the means and standard deviations. Though, I suggest that this be done in some sort of batch mode rather than continuously.

Hope this helps!

$\endgroup$
5
  • $\begingroup$ Thank you for your help! I sort of realigned the orientation of smartphone and vehicle in a calibration process. The general idea here is to be able to identify different maneuvers, and from there, classifying them differently. The combination of all the maneuver classification could then lead to a driving style score or classification. However, for now I just have the separated accelerations. I like your way, but I have two questions: Can I do this outlier detection online? And do I have to change anything in order for it to work on the two components separately? $\endgroup$
    – R. Doe
    Jun 10, 2016 at 7:43
  • $\begingroup$ Does this Image show sort of what you have in mind? $\endgroup$
    – R. Doe
    Jun 10, 2016 at 8:00
  • $\begingroup$ No, don't worry about the orientation. Worrying about the orientation will just make your learner perform poorly and only work for a well-calibrated phone that is perfectly mounted within the car. Turning the acceleration vector into a scalar acceleration magnitude and scalar speed removes the need for calibration. If you replace the axes on your image with speed and acceleration magnitude then this is basically what I am describing. $\endgroup$
    – AN6U5
    Jun 10, 2016 at 15:19
  • $\begingroup$ How would you do this as an online analysis task, which classifies while driving from normal to aggressive and even from aggressiv to normal back again? $\endgroup$
    – R. Doe
    Jun 11, 2016 at 7:40
  • $\begingroup$ I've added a brief statement on online learning. BTW, online learning is not what you mention in your last comment above. What you describe in your comment is just running the learning algorithm continuously. Online learning is continuously updating the learning algorithm so that it gives potentially different answers to the classification over time. $\endgroup$
    – AN6U5
    Jun 14, 2016 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.