How to classify accelerometer data? I am trying to detect if a car did accelerate or did brake by using the accelerometer of the iPhone. 

In the figure below I plotted the collected data. (To collect the data the phone was laying flat in the car facing the top of the phone to the front). 

The issue I am having now is that visually I can clearly see where the car accelerated and where it did brake (see below). But can't figure out how to do that programatically.

What I basically want is to know how often a car did brake or accelerate during a certain time window. (Window size around 10-30 seconds).

Any help would be highly appreciated.

Thanks in advance!
You should consider doing an STFT on the accelerometer signal. This will allow you to visualize the frequency of the signal. If you can determine the frequency of the brakes, you should be able to set a threshold for that specific braking frequency and count each time it is exceeded. You would also be able to measure how long the braking occurs.

How are you processing your signal? Matlab and python have the specgram function, which will allow you to see the actual frequency braking. From there you will be able to determine the brake frequency as well as a threshold.