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

Noticing what's unusual.

A fault happens rarely, and each time in a different way. Here a model learns only what normal looks like, with the phone resting on the washing machine, and flags everything that strays from it.

What you learn
  1. Why, for faults, you learn what normal looks like instead of learning classes
  2. Two ways to measure how strange something is
  3. How to choose the alarm threshold
  4. What drift is and why normal needs updating
You need to know

If you don't remember one of these, the link takes you to the chapter that explains it.

How do you want to follow it
Preparing the scene…
  1. 01 The problem

    Faults are rare, and each one is different.

    You want to notice when the washing machine gets unbalanced. A classifier would need lots of examples of an unbalanced washing machine, and of every other way it can break. You don't have them, and you don't want to break it just to get them. Normal washes, on the other hand, you can record as many as you like. A model for anomalies01.04 starts right there.

    In practice. When the cases you're looking for are rare or all different, think of anomalies before you think of classes. All you need are examples of when everything is fine.

01 / 07
(Go deeper)

A few more numbers.


(01)

Why classes aren't enough

Picture a machine that breaks down once a year. With one window every two seconds, in a year you record almost sixteen million normal windows and maybe a few dozen windows of the fault. No classifier can learn from a ratio like that, and next year's fault will be different anyway.

That's why anomalies are handled the other way around. You describe one thing well, normal, which has plenty of examples. Everything that doesn't look like it becomes suspicious, even a fault nobody had ever seen.

  • 15.8 Mtwo-second windows in a year
  • 1fault a year
(02)

The autoencoder in practice

For vibrations a tiny autoencoder is enough. For example, 30 features go in, the network squeezes them down to 8 and then to 3 numbers, and then widens them back to 8 and again to 30. The neck of three numbers forces the network to learn only the rules of normal, instead of copying everything.

The strangeness score is the average of the squared differences between input and copy. You train it on normal windows only, for a few dozen epochs, and on the phone it weighs a few kilobytes.

strangeness = mean( (input − copy)² )
alarm if strangeness > threshold for 3 windows in a row
(03)

How to check that it works

Normal examples are enough for training, but to give the model a score you also need a few anomalies. If you don't have any, you can make some safely. A badly spread load in the drum, a fan with a coin stuck to one blade, a foot propped up on a book.

Then you count two things. How many real anomalies the model finds, and how many false alarms it gives over hours of normal running. These are the same two errors of every system that keeps watch, and the threshold shifts the balance between them.

(Try it on your phone)

The unbalanced fan


In the lab you train a model for anomalies with a desk fan or the washing machine. It takes ten minutes and a piece of tape.

  1. Open the lab, choose the Motion input and the Anomalies task.
  2. Rest the phone on top of the fan while it runs. With Continuous recording, record one minute at the first speed, then one minute at the second.
  3. Press Train. The model learns only what normal looks like.
  4. Turn off the fan and tape a coin to one blade.
  5. Turn it back on, go to Use and press Try it live. Watch the strangeness go up, then take the coin off and watch it go down.
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)

    Why do you learn what normal looks like for faults, instead of training a classifier?

  2. (02)

    An autoencoder trained on normal data copies a new vibration badly. What does that mean?

  3. (03)

    How do you choose the alarm threshold?

  4. (04)

    After months, the alarms slowly go up, week after week. What's happening?

To close the lesson, answer the quiz

← Recognizing a gesture or an activity Back to the map
(Next lesson · 04.04) Predicting a number