Supervised Learning

Introduction to supervised learning

Among the various approaches to ML, supervised learning is the one that reaped the most impressive results so far. Here is how supervised learning solves a problem like diagnosing pneumonia.

To do supervised learning, we’ll start from a set of examples, each carrying a label that the computer can learn from. For instance:

What are we building? Example Label
A system that identifies a dog’s breed from its barking A .wav recording of a dog The dog’s breed, like “greyhound” or “beagle”
A system that detects pneumonia An X-ray scan A boolean flag: 1 if the scan shows pneumonia, 0 if it doesn’t
A system that predicts the earnings of a lemonade stand from the weather The recorded temperatures on a day in the past The recorded earnings on the same day
A system that recognizes the sentiment in a politician’s tweet The tweet Emotional states such as “indignant,” “angry,” or “absolutely furious”

As we can see, examples can be a lot of different things: data, text, sound, video, and so on. Also, labels can be either numerical or categorical:

  • Numerical labels: These are just a number, as in the case of the temperature-to-lemonade converter.
  • Categorical labels: These represent a category in a pre-defined set, as in the case of the dog breed detector.

With some imagination, we can come up with many other examples of predicting something, be it numerical or categorical, from something else.

So, let’s assume that we have already put together a collection of labeled examples. Now we can dive into the two phases of supervised learning:

Phase 1: Training

During this phase, we feed the labeled examples to an algorithm that’s designed to spot patterns. For example, the algorithm might notice that all pneumonia scans have certain common characteristics, (maybe certain opaque areas), that are missing from non-pneumonia scans. This is called the training phase, because the algorithm is looking at the examples repeatedly and learning to recognize those patterns.

Phase 2: Prediction

Now that the algorithm knows what pneumonia looks like, we switch to the prediction phase, where we reap the benefits of our work. We show an unlabelled X-ray scan to the trained algorithm, and the algorithm tells us whether it contains signs of pneumonia or not.

Another example of supervised learning is a system that recognizes animals. Each input is the picture of an animal, and each label is the species. During the training phase, we show labeled images to the algorithm. During the prediction phase, we show it an unlabelled image, and the algorithm guesses the label:

Get hands-on with 1200+ tech skills courses.