2
votes

I'd like my app to be able to detect when the user carrying the phone falls, using only accelerometer data (because it's the only sensor available on all smartphones).

I first tried to implement an algorithm to detect free fall (accelerometer total acceleration nearing zero, followed by high acceleration due to ground hitting, and a short period of motionlessness to ditch false positives when the user is just walking downstairs quickly), but there's a lot of ways to fall, and for my algorithm implementation, I can always find a case where a fall is not detected, or where a fall is wrongly detected.

I think Machine Learning can help me solve this issue, by learning from a lot of sensor values coming from different devices, with different sampling rates, what is a fall and what is not.

Tensorflow seems to be what I need for this as it seems it can run on Android, but while I could find tutorials to use it for offline image classifying (here for example), I didn't find any help to make model that learns patterns from motion sensors values.

I tried to learn how to use Tensorflow using the Getting Started page, but failed to, probably because I'm not fluent in Python, and do not have machine learning background. (I'm fluent in Java and Kotlin, and used to Android APIs).

I'm looking for help from the community to help me use Tensorflow (or something else in machine learning) to train my app to recognize falls and other motion sensors patterns.

As a reminder, Android reports motion sensors values at a random rate, but provides a timestamp in nanoseconds for each sensor event, which can be used to infer the time elapsed since the previous sensor event, and the sensor readings are provided as a float (32bits) for each axis (x, y, z).

2
Hi, were u able to achieve the falling detection? I also want to apply some ML on accelerometer data.Tina J
@TinaJ I didn't have time to try the current solutions, but I'm interested in knowing if one of those work for you!Louis CAD
Looks like Weka is a good tool. If I have time, I would like to learn how easy it is. I'm also like you, no python background (only Java)! Please update me on your ML progress! HahaTina J

2 Answers

1
votes

If you have your data well organized, then you might be able to use the Java-based Weka machine learning environment: http://www.cs.waikato.ac.nz/ml/weka/

You can use Weka to play around with all the different algorithms on your data. Weka uses a ARFF file for the data. It's pretty easy to create that if you have your data in JSON or CSV. Once you find a algo/model that works, the you can easily put that into your Android app: http://weka.wikispaces.com/Use+Weka+in+your+Java+code

You really don't need Tensorflow if you dont require deep learning algos, which I don't think you require. If you did need the deep learning algo, then DeepLearning4J is a java based open source solution for Android: https://deeplearning4j.org/android

0
votes

STEP 1)

Create a training database. You need some sample of accelerometer data labelled ‘falling’ and ‘not falling’. So you will basically record the acceleration in different situations and label them. i.e. To give an order of magnitude of the quantity of data, 1000 to 100,000 periods of 0.5 to 5 seconds.

STEP 2)

Use SK learn with python. Try different model to classify your data. X is your vectors containing your sample of 3 accelerations axes. Y is your target. (falling/not falling) You will create a classifier that can classify X to Y.

STEP 3)

Make your classifier compatible with Android. Sklearn-porter will port you code in the coding language that you like. https://github.com/nok/sklearn-porter

STEP 4)

Implement this ported classifier in your app. Feed it with data.