DeepLLM Quiz
Machine Learning

Logistic regression: a probability from a weighted sum

10 questions on activation functions, generalised linear models, cross-entropy, gradients, basis functions and the overfitting trap on separable data.

  • 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

    How can a logistic regression model produce a curved boundary in the original input space?

    • By first applying fixed nonlinear transformations to the inputs; the boundary is straight in the transformed space
    • By using a larger learning rate
    • It cannot, under any circumstances
  2. Sample 2

    The training classes can be separated perfectly by a straight boundary, and no regularisation is used. What happens to the weights during maximum likelihood fitting?

    • They settle at small values
    • They grow without limit, making the model infinitely confident on the training data
    • They become zero

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

Logistic regression is one of the most used models in all of data science, and one of the most misnamed: it is not a method for predicting numbers but for classification. It takes the weighted sum that a linear regression would produce and squeezes it through a smooth S-shaped curve, so that the result lies between zero and one and can be read as the probability of a class. It is used to predict whether a customer will leave, whether a loan will default and whether a message is spam. It is also the direct ancestor of the output stage of countless neural networks.

This quiz explains how the model is built and why it works. You will meet the idea of an activation function that transforms a linear score, and the family of generalised linear models it belongs to. A subtle point is that the nonlinearity does not change the shape of the decision boundary, which remains straight in the space of the inputs. You will also see how applying fixed nonlinear transformations to the inputs first can produce curved boundaries, and what no transformation can do, which is to remove overlap between classes.

The second part is about training. The error that the model minimises comes from maximum likelihood and is known as cross-entropy. You will see how its gradient has the same pleasing form as in linear regression, why there is no tidy closed-form solution, what kind of iterative method is used, and which property of the error function makes the search well behaved. The quiz also compares the number of parameters with that of a generative classifier, which explains why this discriminative approach is so popular when there are many features.

One famous trap closes the quiz. If the classes in the training data can be separated perfectly, maximum likelihood tries to make the model infinitely confident, with weights that grow without limit. The quiz asks what happens and how to prevent it. Common mistakes include thinking that logistic regression predicts quantities, that it has a closed-form solution, and that a nonlinear activation makes the boundary curved. Because it is simple, fast and easy to interpret, logistic regression is often the first model to try on a classification problem, and a surprisingly strong baseline that more complicated models must beat to justify their cost.

The quiz suits students and practitioners who use the method and want to understand its inner workings. No calculus is needed. There are 10 questions, each explained 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 the formula of the logistic function?

No. It is enough to know that it is an S-shaped curve that maps any number to a value between zero and one. The questions never ask you to evaluate it, only what it does and why it is used.

›What is an activation function, and what is a link function?

An activation function is the nonlinear function applied to the weighted sum of the inputs to produce the model's output. In statistics the inverse of this function is called the link function. They are two views of the same thing: one goes from score to prediction, and the other goes back from prediction to score. Common choices are the sigmoid for two classes and its multi-class version for several.

›What is a generalised linear model?

It is a model in which a nonlinear function is applied to a linear combination of the inputs. Logistic regression is the standard example for classification. Because the nonlinear function is applied after the linear combination, the decision boundaries remain straight, though the parameters no longer enter the model in a simple linear way.

›Why is logistic regression a good choice with many features?

It learns the class probabilities directly and needs only about one adjustable number per feature. A generative model of the same problem has to describe each class's whole distribution, and the number of its parameters grows far faster as features are added. Fewer parameters mean less data is needed and less risk of overfitting. Its weights are also easy to read: each one says how strongly a feature pushes the score towards one class, which is why the model is popular in fields such as medicine and credit scoring, where decisions have to be explained.

›What is cross-entropy?

It is the error function obtained from the negative logarithm of the likelihood when the target is a yes-or-no label and the model outputs a probability. It punishes confident wrong answers severely and rewards confident correct answers mildly. It is the standard loss for classifiers, from simple models to deep networks. It is also the quantity that classification networks minimise.

›How is a logistic regression model fitted?

With an iterative method, because the equations that give the best weights are no longer linear. Gradient descent, which takes steps down the slope of the error, is the general-purpose choice, and a specialised method called iterative reweighted least squares is also used. Reliable convergence is guaranteed because the error has a single minimum. Each step needs only a pass through the data to compute the error and its slope.

›Why can perfectly separable data cause trouble?

It leads to a problem with the fitted weights that the quiz asks about. A penalty on the size of the weights removes the problem.

More quizzes