Gait @ TreeHacks 2016

Join the chat at

Diagnosing walking disorders with accelerometers and machine learning

Based on the original work of Dr. Matt Smuck

Walking correctly

Author : Shelby Vanhooser
Mentor : Dr. Matt Smuck


Can we diagnose patient walking disorders?

  • Log data of walking behavior for a known distance through a smartphone
  • Using nothing but an accelerometer on the smartphone, characterize walking behaviors as good or bad (classification)
  • Collect enough meaningful data to distinguish between these two classes, and draw inferences about them


  • Wireless headphone triggering of sampling
  • Signal processing of collected data
  • Internal database for storing collection
  • Support Vector Machine (machine learning classification)

-> Over the course of the weekend, I was able to test the logging abilities of the app by taking my own phone outside, placing it in my pocket after selecting the desired sampling frequency and distance I would be walking (verified by Google Maps), and triggering its logging using my wireless headphones. This way, I made sure I was not influencing any data collected by having abnormal movements be recorded as I placed it in my pocket.

Main screen of app I designed Landing screen

The logging in action The logging app in action

-> This way, we can go into the field, collect data from walking, and log if this behavior is 'good' or 'bad' so we can tell the difference on new data!


First, let us observe the time-domain samples recorded from the accelerometer:

Raw signal recorded

It is immediately possible to see where my steps were! Very nice. Let's look at what the spectrums are like after we take the FFT...

Frequency Spectrums of good walking behavior Good walking behavior frequency spectrum

Frequency spectrums of bad walking behavior Bad walking behavior frequency spectrum

19 'correct' walking samples and 5 'incorrect' samples were collected around the grounds of Stanford across reasonably flat ground with no obstacle interference.

Let's now take these spectrums and use them as features for a machine learning classification problem

-> Additionally, I ran numerous simulations to see what kernel in SVM would give the best output prediction accuracy:

How many features do we need to get good prediction ability?

Linear kernel ROC-like characterization

Look at that characterization for so few features!

Moving right along...

Quadratic kernel ROC-like characterization

Not as good as linear. What about cubic?

Cubic kernel ROC-like characterization

Conclusion: We can get 100% cross-validated accuracy with... A linear kernel

Good to know. We can therefore predict on incoming patient data if their gait is problematic!


  • From analysis of the data, its structure seems to be well-defined at several key points in the spectrum. That is, after feature selection was run on the collected samples, 11 frequencies were identified as dominating its behavior:

[0, 18, 53, 67, 1000, 1018, 1053, 2037, 2051, 2052, 2069]

Note : it is curious that index 0 has been selected here, implying that the overall angle of an accelerometer on the body while walking has influence over the observed 'correctness' of gait

  • From these initial results it is clear we can characterize 'correctness' of walking behavior using a smartphone application!
  • In the future, it would seem very reasonable to have a patient download an application such as this, and, using a set of known walking types from measurements taken in the field, be able to diagnose and report to an unknown patient if they have a disorder in gait.


  • Special thanks to Dr. Matt Smuck for his original work and aid in pushing this project in the correct direction

  • Special thanks to Realm for their amazing database software

  • Special thanks to JP Simard for his amazing code to detect volume changes for triggering this application

  • Special thanks to everyone who developed Libsvm and for writing it in C so I could compile it in iOS

Built With

Share this project: