Go to Map Courses Lab Glossary How it works Troubleshooting Start →
ITEN
← Course 04 · Sensing motion (Lesson 04.02 · 22 minutes · Motion sensors · First model)

Recognizing a gesture or an activity.

Shaking the phone, drawing a circle in the air, walking. Here you'll record the examples, train the model on the phone, and learn to check that it also works with people it has never seen.

What you learn
  1. The difference between a gesture and an activity, for a model
  2. Why the class for everything else matters most
  3. How to test a model on people it has never seen
  4. How to avoid one-off answers and gestures counted twice
How do you want to follow it
Preparing the scene…
  1. 01 Gestures and activities

    A gesture lasts a moment, an activity keeps going.

    Shaking the phone, drawing a circle in the air, tapping twice on the back. These are gestures, they last a second and then they're over. Walking, running and sitting are activities, they go on for minutes. For the model, the difference is in the window04.01. For a gesture the window has to hold all of it, for an activity a piece that repeats is enough.

    In practice. If you're not sure whether your problem is a gesture or an activity, ask yourself if it has a beginning and an end. If it does, it's a gesture.

01 / 07
(Go deeper)

A few more numbers.


(01)

What UCI HAR teaches you

In the UCI HAR dataset, thirty people walked, went up and down stairs, and sat, stood and lay down with a phone on their belt. The first models built on the 561 features made very few mistakes on the activities with movement. Almost all the errors were between sitting and standing.

That's the lesson of the mix-up table. One precise weak spot explains almost all the error. To tell sitting from standing with a phone on the belt, you don't need a bigger model. You need one more piece of information, for example the angle of the thigh, which you can't measure from the belt.

(02)

Networks that read the traces

Instead of features worked out by hand, you can give the network the whole window, 100 rows by 6 columns. Small filters slide along time, like with images but in one dimension only, and find the useful patterns on their own. This is called one-dimensional convolution.

It does better when there are many gestures or when they look alike, but it needs more examples and more computing. With three or four very different gestures and twenty examples each, features and a small network are still the best choice, and you can also see why the model gets things wrong.

(03)

Leaving one person out

If you mix everyone's examples and set aside one in five at random, the tests end up with gestures from the same people the model has already seen. The score goes up, but it tells you little about a new person.

The honest method is called leave one subject out. With N people you train N models, each one without one person, and you test each one on the person left out. The average of the scores is what you'll see with the people who use the app. It's usually lower, and it's good to know that beforehand.

(Try it on your phone)

Three gestures with the phone in your hand


In the lab you teach the phone three gestures you pick yourself. It takes ten minutes and, if you can, a second person for the last test.

  1. Open the lab and choose the Motion input.
  2. Create three classes, for example shake, circle and other.
  3. Record 20 examples per gesture, changing speed and hand. For the other class, make two continuous recordings of 15 seconds. Press Continuous recording, move around normally, and press it again to stop.
  4. Press Train and watch the two curves. In Evaluate you'll find the mix-up table.
  5. In Use, press Try it live. Then have another person try the model and count how many times it gets it wrong.
Open the lab →
(Quiz)

4 questions to close the lesson.

When you have answered them all, the lesson counts as done and its stone on the map turns yellow. Answering is what counts, not the score.


  1. (01)

    What's the difference between a gesture and an activity, for the model?

  2. (02)

    The model only knows shake and circle. What happens when you put the phone down on the table?

  3. (03)

    How do you find out if the model works with new people?

  4. (04)

    Why do you wait for two or three matching answers in a row before acting?

To close the lesson, answer the quiz

← The phone senses motion Back to the map
(Next lesson · 04.03) Noticing what's unusual