DeepLLM Quiz
Machine Learning

Generative classifiers: Gaussians, priors and naive Bayes

10 questions on generative classification, Gaussian class densities, linear and quadratic boundaries, class priors, naive Bayes, sigmoid and softmax.

  • 10 questions
  • Stopwatch
  • Instant feedback

Shown publicly with your score. Don’t use your full real name.

Sample questions

Play now ↑

Answers stay hidden. Start the quiz to play them.

  1. Sample 1

    Two classes are each modelled by a Gaussian, and both Gaussians share the same covariance matrix. What is the decision boundary between the classes?

    • A circle
    • A straight line, or a flat surface in higher dimensions
    • A curve with several loops
  2. Sample 2

    Why is naive Bayes attractive for data with many binary features?

    • It guarantees perfect accuracy
    • It makes the number of parameters grow only in proportion to the number of features, not exponentially
    • It removes the need for training data

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

There are two ways to build a classifier that tells apart, say, cats from dogs. One is to learn directly where the line between them lies. The other is to learn what cats look like and what dogs look like, separately, and then ask for any new picture which description fits it better. The second way is called generative, because a model that knows what a cat looks like could in principle also draw one. It is more demanding than the first, and it brings some elegant results that explain why certain mathematical functions appear at the end of almost every classification model.

This quiz explores the generative route. You will see how a class-by-class description is turned into a verdict by Bayes' theorem, which combines how likely a case is under each class with how common each class is. A short piece of algebra turns the answer for two classes into a smooth S-shaped function of a score, and the answer for many classes into its multi-class sibling. The quiz asks what these functions are called and what they represent, including the ratio of probabilities whose logarithm drives them.

The practical core is the choice of description. When each class is modelled by a bell-shaped Gaussian cloud, the shape of the boundary between classes depends on whether the clouds share a single spread or have their own. The quiz asks you what boundary results in each case, what the class frequencies do to it, and how all the numbers are estimated from data by maximum likelihood. Then it moves to inputs that take discrete values, where a bold simplifying assumption known as naive Bayes keeps the number of required parameters manageable.

Mistakes that arise in this area include assuming that a generative classifier cannot be wrong about its Gaussians, that the independence assumption of naive Bayes has to be true to be useful, and that class priors are a fixed property of the world instead of something that depends on the data set used. Understanding the structure shows when each assumption matters. Modern generative models of images and text are far more elaborate than a Gaussian per class, but they share the same logic: model how the data arise, then use that model to reason about the cause. The simple version in this quiz is a good place to see that logic at work.

The quiz suits students and practitioners who want to understand the logic behind spam filters and similar models. It needs no mathematics 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 know Bayes' theorem?

It helps, and the quiz on Bayes' theorem and screening is a good starting point. Even without it, the questions explain the idea that a verdict combines how well a case fits each class with how common each class is.

›What is the difference between generative and discriminative models?

A generative model describes how the inputs are distributed within each class, together with the class frequencies, and uses Bayes' theorem to get from there to the class probabilities. A discriminative model skips the description of the inputs and learns the class probabilities directly. The first can also create new examples, and the second is usually more economical.

›Why can a generative classifier produce new data?

Because it contains a complete description of how inputs arise in each class. Picking a class according to its frequency, and then drawing an input from that class's description, creates a synthetic example. The same description also lets it spot inputs that look unlikely under every class, which is useful for detecting unusual cases.

›What are the sigmoid and softmax functions doing here?

When the class probabilities are rewritten from Bayes' theorem, they come out as a smooth S-shaped function of a score in the two-class case and its many-class generalisation otherwise. These functions turn arbitrary real scores into probabilities that are positive and add up to one, which is why they sit at the output of classification models.

›How are the parameters of a generative classifier estimated?

By maximum likelihood, which for these models gives answers that match intuition. Class frequencies are estimated by the share of training cases in each class, and each class's centre by the average of its training cases. A shared spread is estimated by pooling the scatter of the classes around their own centres.

›What is the naive Bayes assumption?

It assumes that, within each class, the input features are independent of each other. This is rarely exactly true, but it reduces the amount that has to be estimated so drastically that the method works well with many features and little data. It is the basis of the classic spam filter. Despite its crude assumption, naive Bayes remains a strong baseline, particularly for text, where the features are word counts and the number of features is huge. It is quick to train, easy to update with new data and often surprisingly hard to beat with little data.

›Can the generative approach be wrong?

Yes. If the chosen description of each class is a poor match to the real data, then the probabilities derived from it will be poor too. Fitting Gaussians by maximum likelihood is also sensitive to outliers. This is one of the reasons for the popularity of the discriminative approach.

More quizzes