<p>Based on your post I'm assuming you haven't had much experience with this type of work. Here are several things that immediately jump out as being potential problems:</p>

<ul>
<li><p>You should probably perform some type of preprocessing so your inputs are in a more acceptable range such as (-1, 1), or (0, 1). When the magnitude of the input values are large, the the hidden units are likely to saturate (i.e. be very close to $\pm$ 1 assuming you're using tanh hidden units). This causes the gradients to be nearly zero which can result in backpropagation performing poorly.</p></li>
<li><p>In my experience, you will not get good results when you have very unbalanced classes (50 tap, 3000 no tap) if you just naively apply some machine learning algorithm. For example, a classifier which always outputs -1 will achieve approximately 98% accuracy on your dataset, while being completely useless for your task.</p></li>
<li><p>Since you have not mentioned a training/test split of your dataset or cross validation, I'm assuming you're not doing these things. You should be. Neural networks are notorious for overfitting and if you use the same data to train and assess accuracy, you almost surely will.</p></li>
</ul>

<p>That being said, I'm surprised this question hasn't been closed or migrated. It is almost certainly a better match for the CS stack exchange or <a href="http://metaoptimize.com/qa" rel="nofollow">Metaoptimize</a>.</p>

CC BY-SA 3.0
2012-06-25T06:29:37.090Z
Hi, thanks for your answer. The data I posted is normalized between -1 and 1. We are doing cross validation now and are seeing better results compared to the amount of data. I'm curious thought - do you think that a set of maybe 100 taps and noise data would be sufficient or way to low?
Hampus Ahlgren
CC BY-SA 3.0
2012-06-25T12:36:14.800Z
That's good to hear that cross validation helped. Unfortunately, getting ML algorithms to work in the world is more art than science, and involves a lot of guess and check work in my experience. That doesn't mean you shouldn't be scientific about it. Have a look at these [slides](http://cs229.stanford.edu/materials/ML-advice.pdf) from Andrew Ng. They do good job of introducing some common ML diagnostics.
alto
CC BY-SA 3.0
2012-06-25T14:16:32.647Z
"...more art than science..." I think I'm starting to realize that. Great link.
Hampus Ahlgren
CC BY-SA 3.0
2012-06-24T18:47:30.787Z
2012-06-24T18:47:30.787Z
alto
<p>I'm building an application for Android devices that requires it to recognize, by accelerometer data, the difference between walking noise and double tapping it. I'm trying to solve this problem using Neural Networks.</p>
<p>At the start it went pretty well, teaching it to recognize the taps from noise such as standing up/ sitting down and walking around at a slower pace. But when it came to normal walking it never seemed to learn even though I fed it with a large proportion of noise data.</p>
<p><strong>My question</strong>: Are there any serious flaws in my approach? Is the problem based on lack of data?</p>
<h3>The network</h3>
<p>I've choosen a 25 input 1 output multi-layer perceptron, which I am training with backpropagation. The input is the changes in acceleration every 20ms and output ranges from -1 (for no-tap) to 1 (for tap). I've tried pretty much every constallation of hidden inputs there are, but had most luck with 3 - 10.</p>
<p>I'm using Neuroph's easyNeurons for the training and exporting to Java.</p>
<h3>The data</h3>
<p>My total training data is about 50 pieces double taps and about 3k noise. But I've also tried to train it with proportional amounts of noise to double taps.</p>
<p>The data looks like this (ranges from +10 to -10):</p>
<p>Sitting double taps: <a href="https://i.sstatic.net/a7PDT.png" rel="nofollow noreferrer">https://i.sstatic.net/a7PDT.png</a></p>
<hr />
<p>Fast walking: <a href="https://i.sstatic.net/ljRwp.png" rel="nofollow noreferrer">https://i.sstatic.net/ljRwp.png</a></p>
<p>So to reiterate my questions: Are there any serious flaws in my approach here? Do I need more data for it to recognize the difference between walking and double tapping? Any other tips?</p>

CC BY-SA 3.0
2015-11-14T00:58:58.713Z
Hi, so were you able to solve your problem?
OmarAsifShaikh
<machine-learning><ne.neural-evol>
Neural Networks to classify accelerometer double taps
Hampus Ahlgren
# Neural Networks to classify accelerometer double taps

(Asked by: username_0 on 2012-06-23)

I'm building an application for Android devices that requires it to recognize, by accelerometer data, the difference between walking noise and double tapping it. I'm trying to solve this problem using Neural Networks.

At the start it went pretty well, teaching it to recognize the taps from noise such as standing up/ sitting down and walking around at a slower pace. But when it came to normal walking it never seemed to learn even though I fed it with a large proportion of noise data.

**My question**: Are there any serious flaws in my approach? Is the problem based on lack of data?

### The network

I've choosen a 25 input 1 output multi-layer perceptron, which I am training with backpropagation. The input is the changes in acceleration every 20ms and output ranges from -1 (for no-tap) to 1 (for tap). I've tried pretty much every constallation of hidden inputs there are, but had most luck with 3 - 10.

I'm using Neuroph's easyNeurons for the training and exporting to Java.

### The data

My total training data is about 50 pieces double taps and about 3k noise. But I've also tried to train it with proportional amounts of noise to double taps.

The data looks like this (ranges from +10 to -10):

Sitting double taps: <https://i.sstatic.net/a7PDT.png>

---

Fast walking: <https://i.sstatic.net/ljRwp.png>

So to reiterate my questions: Are there any serious flaws in my approach here? Do I need more data for it to recognize the difference between walking and double tapping? Any other tips?

**Tags:** machine-learning, ne.neural-evol

> **Comments:**
> **username_1**: Hi, so were you able to solve your problem?  

---

## 1 answers

### Answer by username_2 on 2012-06-24. Score: 4 | Accepted answer

Based on your post I'm assuming you haven't had much experience with this type of work. Here are several things that immediately jump out as being potential problems:

* You should probably perform some type of preprocessing so your inputs are in a more acceptable range such as (-1, 1), or (0, 1). When the magnitude of the input values are large, the the hidden units are likely to saturate (i.e. be very close to $\pm$ 1 assuming you're using tanh hidden units). This causes the gradients to be nearly zero which can result in backpropagation performing poorly.
* In my experience, you will not get good results when you have very unbalanced classes (50 tap, 3000 no tap) if you just naively apply some machine learning algorithm. For example, a classifier which always outputs -1 will achieve approximately 98% accuracy on your dataset, while being completely useless for your task.
* Since you have not mentioned a training/test split of your dataset or cross validation, I'm assuming you're not doing these things. You should be. Neural networks are notorious for overfitting and if you use the same data to train and assess accuracy, you almost surely will.

That being said, I'm surprised this question hasn't been closed or migrated. It is almost certainly a better match for the CS stack exchange or [Metaoptimize](http://metaoptimize.com/qa).

> **Comments:**
> **username_0**: Hi, thanks for your answer. The data I posted is normalized between -1 and 1. We are doing cross validation now and are seeing better results compared to the amount of data. I'm curious thought - do you think that a set of maybe 100 taps and noise data would be sufficient or way to low?  
> **username_2**: That's good to hear that cross validation helped. Unfortunately, getting ML algorithms to work in the world is more art than science, and involves a lot of guess and check work in my experience. That doesn't mean you shouldn't be scientific about it. Have a look at these [slides](http://cs229.stanford.edu/materials/ML-advice.pdf) from Andrew Ng. They do good job of introducing some common ML diagnostics.  
> **username_0**: "...more art than science..." I think I'm starting to realize that. Great link.  

---

