Three ways to build a classifier, and why probabilities pay off
10 questions on generative models, discriminative models and discriminant functions, and what posterior probabilities give you that a bare label does not.
- 10 questions
- Stopwatch
- Instant feedback
Sample questions
Play now ↑Answers stay hidden. Start the quiz to play them.
Sample 1
A bank's classifier is a pure discriminant function. The cost of a missed fraud rises sharply. What must be done?
- Change a threshold; nothing else is needed
- Go back to the training data and train the model again, because it has no probabilities to re-weigh
- Nothing, the model adjusts itself
Sample 2
One model interprets images and another interprets blood tests, and both output class probabilities. How can they be combined?
- Average the two predicted labels
- Pick whichever model has more parameters
- Multiply their outputs with the class prior and rescale, if the two kinds of evidence are independent once the class is known
How it works
- One question per screen. An answer is final once sent.
- You see right away whether you were right, with a short explanation.
- The stopwatch runs: on equal scores, the faster player ranks first.
- Only your best attempt counts, so replaying is never risky.
About this quiz
Ask three engineers to build a classifier and you may get three quite different designs. The first builds a detailed statistical description of every class and compares a new case with each. The second skips the description and learns directly the probability that a case belongs to each class. The third skips even that and trains a function that spits out a label. All three are legitimate, all three have been used in real products, and they trade effort and data against flexibility in very different ways. Knowing which to choose is part of the craft of machine learning.
This quiz lays out the three approaches, called generative, discriminative and discriminant-function, and asks what each of them asks of you. You will see which is the most demanding in terms of data and computation, what extra abilities it buys in return, and why spending effort on structure that does not affect the final decision can be wasteful. You will also see that the simplest approach, which goes straight to a label, throws away something valuable: the probabilities.
Most of the quiz is about that value. A classifier that outputs class probabilities allows you to change the costs of different mistakes without retraining, to refuse the hardest cases, to correct for training data whose class mix differs from the real world, and to combine the outputs of separate specialised models into a single verdict. It also makes the whole system smooth enough to be trained end to end by gradient methods. Each of these advantages is tested with a practical scenario, such as a screening system whose training data contain very few positive cases.
Typical misconceptions are to believe that the more elaborate approach is always better, that a model that outputs labels is as flexible as one that outputs probabilities, and that balancing a training set has no side effects. The quiz explains why each of these is wrong. When you next read about a classification system, ask which of the three approaches it uses and what it would take to change its costs, handle a different mix of classes or combine it with another source of evidence. The answers show how adaptable the system really is. None of the three is best everywhere, and many successful systems mix them, for example by learning features without labels and then training a probabilistic classifier on top, so knowing the trade-offs helps you to choose sensibly.
It suits students and practitioners who design or commission classifiers. No mathematics is needed beyond the idea of a probability. There are 10 questions, each explained straight after you answer, and the quiz takes about four minutes.
Questions and answers
›How long does the quiz take?
About 3 to 4 minutes for 10 questions, at roughly 20 seconds each. An explanation appears after every answer.
›Do I need to have built a classifier?
No. The scenarios are described in everyday terms, such as screening, fraud detection and combining several sources of evidence. If you understand that a classifier assigns cases to categories, you can answer every question.
›What are the three approaches?
The generative approach describes the inputs of each class and then uses Bayes' theorem. The discriminative approach models the class probabilities directly. The discriminant-function approach learns a rule that maps an input straight to a label. They are listed from the most to the least demanding. As a rule, if the stakes are high or the conditions are likely to change, it pays to keep the probabilities, even if a bare label would be simpler to implement. The extra information is cheap to keep and expensive to recover later. In practice, most modern classifiers, including deep networks, belong to the second group: they output probabilities directly, are trained by maximum likelihood and are then combined with decision rules that reflect the application's costs, which makes them adaptable and easy to audit.
›Why is the generative approach the most demanding?
It has to describe the whole distribution of inputs for each class, which in a space with many dimensions needs a lot of data. Much of what it learns may have no effect on the final decision. In return it can generate examples and notice unusual inputs.
›What is lost by learning only a decision rule?
The probabilities. Without them, the model is much harder to adapt to new conditions such as changed costs, a different mix of classes or combination with other models.
›Why might a training set be balanced artificially?
When one class is extremely rare, a model can look accurate by always predicting the common class, and it sees too few examples of the rare one to learn from. Balancing the classes helps the model to learn. The probabilities must then be corrected afterwards to reflect the real class frequencies.
›How are probabilities corrected after balancing?
Each class probability is divided by the share of that class in the training set, multiplied by its share in the population where the model will be used, and the results are rescaled so that they add up to one. This works because class frequencies act as priors in Bayes' theorem. It cannot be done for a model that outputs only labels.
›How can two separate models be combined?
Specialised models for different types of evidence can be combined, under suitable independence assumptions, using the rules of probability, which labels alone do not allow. This lets each module work on its own data.