Linear discriminant functions: classifying with straight boundaries
10 questions on linear decision boundaries, weight vectors, one-versus-rest, one-hot targets and why least squares struggles with classification.
- 10 questions
- Stopwatch
- Instant feedback
Sample questions
Play now ↑Answers stay hidden. Start the quiz to play them.
Sample 1
A pairwise scheme builds one binary classifier for every pair of classes. How many classifiers are needed for four classes?
- 6
- 4
- 12
Sample 2
What shape do the decision regions of such a multi-class linear discriminant always have?
- Any shape at all, including several separate pieces
- Circular
- Convex and singly connected, so a straight line between two points of a region stays inside it
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
The simplest way to decide which of several categories a new case belongs to is to draw a straight line, or in higher dimensions a flat surface, through the space of inputs and say that everything on one side is one class and everything on the other is another. A spam filter that adds up weighted evidence from words, a credit score that adds up weighted facts about an applicant, and the final stage of many neural networks all work this way. These models are called linear classifiers, and their geometry is simple enough to picture, which makes them the best place to learn the basic vocabulary of classification.
This quiz begins with the two-class case. You will see what the weights of a linear discriminant mean geometrically: which way the boundary faces, what moves it closer to or further from the origin, and what the numerical output of the model tells you about how far a case lies from the boundary. You will also meet the term linearly separable, which describes data that a straight boundary can split perfectly, and learn what happens when the data are not like that.
The second part moves to many classes. A natural idea is to combine several two-class classifiers, either one per class against all the rest or one for every pair of classes, but both leave gaps where the verdict is ambiguous. The quiz asks how many classifiers the pairwise method needs, why ambiguity arises, and how a single set of scoring functions, with the highest score winning, avoids it and what shape the resulting regions have. You will also see the standard way of writing class labels as vectors that are all zeros except for a single one.
The final part asks why the least-squares method that works so well for regression performs poorly for classification. The reasons are instructive: they concern what the outputs mean, how sensitive the fit is to far-away points and whether the assumptions behind least squares fit the data. Frequent mistakes include thinking that a classifier's score is a probability, assuming that far-away points can do no harm, and believing that combining binary classifiers is trivially safe. The same geometry underlies far more sophisticated models: every neuron in a neural network computes a linear score of exactly this kind, and a deep network is a way of making the classes linearly separable by transforming the inputs first. Getting comfortable with the straight boundary is therefore time well spent.
The quiz suits students and practitioners meeting classification for the first time. No algebra is required. 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 linear algebra?
No. The questions use pictures of lines and regions, and the words weight and bias have the same meaning as in earlier topics. You are asked what happens in a given situation, never to calculate with matrices.
›What is a decision boundary?
It is the surface in the space of inputs that separates the region assigned to one class from the region assigned to another. For a linear classifier, it is a straight line in two dimensions, a flat plane in three, and a flat surface of one dimension fewer than the space in general. Points exactly on it are the ones the model finds hardest to call.
›What do the weights and the bias of a linear classifier do?
The weights form a vector that points at right angles to the decision boundary and so set its orientation. The bias moves the boundary towards or away from the origin without turning it. Together they place the line, and the sign of the model's output tells you on which side a point lies.
›What does linearly separable mean?
It describes a data set whose classes can be split perfectly by a straight boundary. Linear classifiers can still be used for data that are not separable, but some cases will then be misclassified, however well the boundary is placed.
›Why is combining binary classifiers awkward?
Whether you train one classifier per class against all the others, or one for each pair of classes, there are areas of the input space where the classifiers disagree or all say no. A point there has no sensible label, and that is the problem the single multi-class scoring approach was designed to avoid.
›What is one-hot, or 1-of-K, coding of labels?
A label is written as a list with one entry per class, with a one for the class the example belongs to and zeros elsewhere. It makes it easy to treat several classes in one formula, and a model's outputs can then be compared with it entry by entry.
›Why is least squares a poor choice for classification?
It was designed for continuous targets with Gaussian noise, and class labels are nothing like that. Its outputs are not confined to a sensible range, and it can be pulled off course by points that are far from the boundary yet perfectly well classified. Models built for classification handle these issues far better. A rule of thumb that follows from all this is to use a model designed for classification, with a suitable output function and loss, rather than reusing a regression method on labels. The extra care costs almost nothing and avoids the most common failures.