How to Design & train a model for counting steps

Hello everyone,

I would like to design a NN to count the number of steps based on the accelerometer data measured using a smartphone.

I completed the Machine Learning Specialization and some parts of the Sequence model course and Convolutional Neural Networks course.

So I know the theory of NNs, CNNs, RNNs, BRNNs, GRUs, LSTMs, etc.

However, it is unclear how to achieve my goal in practice.
I could follow the TensorFlow Developer Professional Certificate Course 4 Sequences, Time Series and Prediction but it seems to focus on predictions.

Is it what I’m looking for?
What would be the best next action for me?

I have collected training data (time series), but don’t know how to label it, process it, count the number of steps (categorize?), etc…

Thank you for your help,
Vincent

2 Likes

I think that you can just convert the accelerometer data accumulated to a number of steps and thats what they do rather than use a ML model to predict it.

Of course an ML model might give you similar results but needs a lot of work: gathering data, preprocessing it, building the model, testing it etc. but if you think thats the way to go, then your task is straightforward, for a given accelerometer count find the number of steps (from what I understand), its a straightforward NN which outputs a scalar number (the number of steps). I don’t think a time series prediction is needed here, the problem is simpler!

1 Like

@gent.spah What do you mean by just convert ?

I got this part.

1 Like

Means use a formula that creates a relationship between both (and maybe other variables also) like f(x) = x/(1+x**2), where x is the input data and f(x) is the calculated output!

2 Likes

I’m not sure how this task would require machine learning.

For machine learning to be used, you’d need to create a labeled training set from which a model can learn how to identify when a step has occurred.

Maybe you could do this with a sequence model, using a method like what was used in Course 5 to detect a keyword that was spoken in an audio recording.

However to me this seems like a difficult way to solve a simple task.

1 Like

Thank you for your response.

I talked about step counting for simplification but in fact, I would like to count the number of jumps while jumping rope.
I know it sounds simple but when you dig into it, having a high accuracy is not that trivial.
Yes, a sequence model is what I had in mind but it’s unclear to me how to apply it to my time series.

Regards,

1 Like

You’re going to have to label the time series as to at what point a jump has happened.

That’s what happens in the DLS Sequence Models course in the Week 3 Assignment 2 “Trigger Word” lab.

1 Like

@TMosh thank you very much, I’ll look into this.

1 Like

I do not think this would work. For instance, the accelerometer might collect data when you are accelerating in a lift or a car. You have to somehow detect that a certain acceleration is related to a step being taken. I think that is what your watch actually does. So, I guess the training task would be to use machine learning to do this detection.

1 Like

I am not sure this is necessary. I think I would create a neural network that takes as input a time series of the accelerometer and the number of jumps that are taken within that time. The neural network should then be able to learn which patterns in the time series relate to a jump. Nice project! :smiley:

1 Like

Thank you for your input @davelomm

But in this case, how do you “convert” the measured time series into an input vector to feed it to the NN ?
Do you get rid of the timestamp altogether?
here is what my measurements look like this:

# vertical acceleration, timestamp
-0.5146311341736756,1714131735871
-0.5404148086798478,1714131735875
-0.4741858500806992,1714131735875
-0.4119229009192524,1714131735876
-0.21065804515054054,1714131735876
-0.13615667279806254,1714131735876
0.25644108987027536,1714131735878
0.32077900136286613,1714131735882
0.5183291261570935,1714131735883
0.5128649315856246,1714131735884
0.636482160278032,1714131735888
1 Like

I think each training example would be a 2D matrix, 2 x n, where n is the number of timestamps. I think n should ideally be larger than what you gave. So, you might have m training examples, of size 2 x n each. In principle, it should be possible to have n vary across your training examples. However, it might be easier to fix n for your first attempt.

If the data is sequential and uniformly spaced, and you’re using a sequence model, you probably don’t need the time stamps. So you’d have a 1D vector of values.

1 Like

And if you are using the time stamps (i.e. it becomes a 2D set), then having duplicate time values is a bad idea. For example, what significance does the time stamp have if you have multiple values at the same time stamp?

1 Like

Good point! I did not check the sample data properly. Frankly, I am surprised that there are multiple entries for one time stamp.