Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using LSTM Neural Network to Process Accelerometer Data

DZone's Guide to

Using LSTM Neural Network to Process Accelerometer Data

We conducted research to find out whether LSTM neural networks can process accelerometer data and determine the way objects move or not.

· Big Data Zone ·
Free Resource

The open source HPCC Systems platform is a proven, easy to use solution for managing data at scale. Visit our Easy Guide to learn more about this completely free platform, test drive some code in the online Playground, and get started today.

When we rotate a smartphone horizontally or vertically, its screen orientation changes. This is so natural that we don’t even care to think what lies behind the image rotation. Every smart gadget has a sensor called an accelerometer, and it is this sensor which is responsible for the screen rotation. Of course, you guys have heard about it. If you are curious to know how it works on a hardware level, I recommend you watch this video by Bill Hammack.

An accelerometer measures the acceleration of the object. Our R&D team analyzed accelerometer data to understand the way smartphone owners move. This analysis turned into research aimed at automating and systematizing the accelerometer data.

We decided to use LSTM neural network models to process sensor data. The research was conducted to find out whether LSTM neural networks can process accelerometer data and determine the way objects move or not.

Steps We Took

  1. We identified the main hypothesis.

  2. We analyzed the accelerometer data visually.

  3. Then we trained our LSTM network.

  4. We finished the research by testing how the network works on a mobile app.

Main Hypothesis Identification

The accelerometer is a device that measures the sum of object acceleration and gravity acceleration. The first accelerometer looked like a weight suspended from a spring and supported from the other side to inhibit vibrations. Nowadays, smartphones have embedded MEMS accelerometers.

A simple accelerometer

A simple accelerometer.

Accelerometers can be single-axis, two-axis, and three-axis. Positioning is measured about one, two, or three axes of rotation. Most smartphones have three-axis models.

We’ve used the accelerometer to determine whether a smartphone was moving or not and to calculate the speed of the movements.

When you move a smartphone, the accelerometer strings inside are stretching and compressing. Considering the type of movements, we formulated the following hypothesis:

If a smartphone is in the pocket of a moving person, oscillations are transmitted to the smartphone and displayed in the accelerometer data.

Accelerometer Data Visual Analysis

All models had the same structure of network layers: the input vector goes to the LSTM layer and then a signal goes to a fully connected layer where the answer comes from. Browse the Lasagne framework website for more info about LSTM layer.

All the models were implemented using Python frameworks Theano and Lasagne. We also applied the Adam solver. The models had different size of input vector and the LSTM-elements number.

Then we tested received models using a special Android app. To run the solution on Android, we chose the following libraries:

  • JBLAS is a linear algebra library based on BLAS (Basic Linear Algebra Subprograms).

  • JAMA (Java Matrix Package).

The library JBLAS showed an error message when the program was running on the arm64 architecture. As a result, we implemented the solution using JAMA.

Testing the LSTM Network on a Mobile App

The Results of Model Testing

The results of model testing.

Using these models, we can define the type of mobile object movements: rest, on foot, driving, etc. This is explained via a specific pattern appearing in the oscillations of vector length that are calculated with accelerometer data in driving or rest periods.

When it relates to on foot or in rest, a pattern is clearly visible. When it relates to a transport trip (subway, bus, or car), the estimation precision decreases, as different factors prevent us from correctly evaluating the human state.

Results of model testing based on accelerometer data from the walk and from the bus trip

How Is This Useful?

We found out that LSTM networks work smoothly for accelerometer data processing. Therefore, what tasks can be solved?

Taxi services can identify dangerous drivers among their employees. An accelerometer located in a cab will help to track the way drivers behave on the road. Bonuses paid for safe driving is a good motivation.

Insurance companies can ask their clients put a sensor in a car and drive that way for a while. The company can then define the driving style of a client and calculate the car insurance value.

All in all, the areas of use are limited only by your imagination and business purposes. We are always happy to help you achieve complex goals using high-end digital solutions.

Managing data at scale doesn’t have to be hard. Find out how the completely free, open source HPCC Systems platform makes it easier to update, easier to program, easier to integrate data, and easier to manage clusters. Download and get started today.

Topics:
neural network ,accelerometer ,data processing ,lstm ,big data

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}