Skip to content
All apps

Rule or example: how a machine learns

About this app

Whether a number is even is told by a rule: the last digit. Whether a pixel image is a handwritten seven is told by none: a real pixel rule gets 6 of 18 images wrong. Classical programming means rules plus data give answers, machine learning means data plus answers give rules. A real logistic regression turns its mixing desk of 8 knobs on 4800 examples, the error drops from 50 to 5.8 percent, then it recognises new sevens.

With explain mode: an AI tutor walks you through the app, points out what matters in the scene and answers your questions.

Writing rules down or learning from examples

Some tasks have a precise rule: whether a number is even is decided by its last digit, however long the number is. Other tasks have no usable rule. Whether an image of 784 pixels shows a handwritten 7 can hardly be written down in pixels, even though every child recognises a 7 at once. Classical programming computes answers from rules and data. Machine learning turns this around: from data and the matching answers, the labels, come the rules that then answer new cases.

What the app shows

Four scenes with a real small model. The rule for even numbers checks seven numbers without a mistake. A hard-coded pixel rule for the 7 is right for only twelve of 18 images: it misses small and shifted sevens and takes a 1 with a flag, a 9 and a 2 for a 7. Then a logistic regression with 785 numbers learns from 480 labelled examples. A mixing desk summarises the weights as eight sliders that set themselves during training while the error rate drops from 50 to 5.8 percent. Once trained, the model recognises 93.3 percent of new test images.

Try it yourself

Pick a scene and go through the steps: check the last digit, lay the pixel rule over the gallery, swap answers and rules in the diagram and start the training. The numbers in the panel show how many images the rule gets right, how many examples the model has seen and how confident it is about a new note.

Frequently asked questions

What is the difference between classical programming and machine learning?
In classical programming a person writes the rules and the computer applies them to data to produce answers. In machine learning the computer gets data together with the correct answers and works out the rules itself, which it then uses to answer new cases.
Why can a handwritten 7 not be recognised with a pixel rule?
Sevens differ in size, position, slant, stroke width and shape, with and without a crossbar. A fixed rule about pixel positions therefore catches only some of them and at the same time lets similar digits such as a 1 with a flag through. A learned model weighs all pixels from many examples and gets much further.
What are the sliders of a model?
A model has a fixed form and many adjustable numbers, the parameters or weights. Training shifts them example by example so that the error gets smaller. A logistic regression on 28 × 28 pixels has 785 such numbers; large networks have millions or billions.
What can I try in the app?
Four scenes with steps: the rule for even numbers, the pixel rule on twelve sevens and six other images, the training at the mixing desk with a real error curve and the trained model with a new note and a cross-check. An explanation mode guides you through everything.

Subject: Machine Learning

More from Machine Learning

A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps