Discriminative model

A discriminative model learns to predict an output directly from an input, modelling the probability of the answer given the data rather than how the data itself is produced.

A discriminative model answers one question: given this input, what is the most likely output? In probability terms it models P(y|x), the chance of label y given input x, or it simply learns a rule that separates one class from another. A spam filter that reads an email and says spam or not spam, without forming any picture of what emails in general look like, is working discriminatively.

The contrast is with a generative model, which learns how the data is distributed, the joint distribution of inputs and labels, and so could in principle produce new examples. A discriminative model skips that harder job and spends its capacity on the boundary that matters for the task. That is why discriminative models are the usual choice for classification. Familiar examples include logistic regression, support vector machines, conditional random fields, decision trees and random forests, boosting and k-nearest neighbours.

The trade-off between the two approaches has been studied directly. In a paper at the NIPS 2001 conference, Andrew Ng and Michael Jordan compared logistic regression with naive Bayes, a simple generative classifier. The discriminative model reached a lower error once there was plenty of training data, but the generative one approached its own, higher, error level much faster, so it could come out ahead when data was scarce. Neither approach wins in every situation.

Discriminative models are supervised by nature. They need labelled examples, they cannot easily learn from unlabelled data, and they cannot generate anything. That makes them less eye-catching than today's chatbots and image generators, but many of the classifiers in everyday use work this way.

The line is about what a model is trained to represent, not about the technology. A neural network trained to label photos is discriminative; a neural network trained to produce photos is generative. Large language models are generative, yet businesses often use them for discriminative jobs, such as asking one to label a customer review as positive or negative.

Common questions

What is the difference between a discriminative and a generative model?

A discriminative model learns the probability of an output given an input, or a direct rule from inputs to outputs, which is what classification needs. A generative model learns how the data itself is distributed, which lets it estimate how likely an example is and produce new ones. Discriminative models are usually simpler to train for prediction; generative models can do more but have a harder job.

Is logistic regression a discriminative model?

Yes. Logistic regression models the probability of a class given the input features and nothing more, which makes it the textbook discriminative classifier. Its usual generative counterpart in comparisons is naive Bayes, which models how the features are distributed within each class.

Are neural networks discriminative or generative?

They can be either. A network trained to classify images or detect fraud is discriminative, while a network trained to produce text or images is generative. A generative adversarial network contains one of each: a generator that makes samples and a discriminator that judges whether they are real.

When is a generative model the better choice for classification?

Ng and Jordan's 2001 comparison found that a generative classifier can reach its best performance with fewer training examples, so it may win when labelled data is scarce. Generative models also cope better with missing data and can learn from unlabelled examples. With large labelled datasets, discriminative models usually reach lower error.

Finding more

Search for "discriminative vs generative classifiers", "conditional model P(y|x)" or "logistic regression vs naive Bayes" to see the distinction worked through. Reliable sources include machine learning textbooks and university lecture notes, the original conference papers in the NeurIPS proceedings, and encyclopedia articles that cite them. Be aware that some writers use the terms loosely, so check whether a source means the statistical distinction or simply the difference between AI that labels and AI that creates.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.