In statistical classification, including machine learning, two main approaches are called the generative approach and the discriminative approach. These compute classifiers by different approaches, differing in the degree of statistical modelling. Terminology is inconsistent,[a] but three major types can be distinguished, following Jebara (2004):
- Given an observable variable X and a target variable Y, a generative model is a statistical model of the joint probability distribution on X × Y, ;
- A discriminative model is a model of the conditional probability of the target Y, given an observation x, symbolically, ; and
- Classifiers computed without using a probability model are also referred to loosely as "discriminative".
The distinction between these last two classes is not consistently made; Jebara (2004) refers to these three classes as generative learning, conditional learning, and discriminative learning, but Ng & Jordan (2002) only distinguish two classes, calling them generative classifiers (joint distribution) and discriminative classifiers (conditional distribution or no distribution), not distinguishing between the latter two classes. Analogously, a classifier based on a generative model is a generative classifier, while a classifier based on a discriminative model is a discriminative classifier, though this term also refers to classifiers that are not based on a model. Standard examples of each, all of which are linear classifiers, are: generative classifiers: naive Bayes classifier and linear discriminant analysis; discriminative model: logistic regression; non-model classifier: perceptron and support vector machine.
In application to classification, one wishes to go from an observation x to a label y (or probability distribution on labels). One can compute this directly, without using a probability distribution (distribution-free classifier); one can estimate the probability of a label given an observation, (discriminative model), and base classification on that; or one can estimate the joint distribution (generative model), from that compute the conditional probability , and then base classification on that. These are increasingly indirect, but increasingly probabilistic, allowing more domain knowledge and probability theory to be applied. In practice different approaches are used, depending on the particular problem, and hybrids can combine strengths of multiple approaches.
An alternative division defines these symmetrically as: a generative model is a model of the conditional probability of the observable X, given a target y, symbolically, ; while a discriminative model is a model of the conditional probability of the target Y, given an observation x, symbolically, . Regardless of precise definition, the terminology is because a generative model can be used to "generate" random instances (outcomes), either of an observation and target , or of an observation x given a target value y, while a discriminative model or discriminative classifier (without a model) can be used to "discriminate" the value of the target variable Y, given an observation x. The difference between "discriminate" (distinguish) and "classify" is subtle, and these are not consistently distinguished, so the term "discriminative classifier" becomes a pleonasm, meaning that it does nothing other than classify (equivalently, "discriminate") inputs.
Relationships between models
In application to classification, the observable X is frequently a continuous variable, the target Y is generally a discrete variable consisting of a finite set of labels, and the conditional probability can also be interpreted as a (non-deterministic) target function , considering X as inputs and Y as outputs.
Given a finite set of labels, the two definitions of "generative model" are closely related. A model of the conditional distribution is a model of the distribution of each label, and a model of the joint distribution is equivalent to a model of the distribution of label values , together with the distribution of observations given a label, ; symbolically, Thus, while a model of the joint probability distribution is more informative than a model of the distribution of label (but without their relative frequencies), it is a relatively small step, hence these are not always distinguished.
Given a model of the joint distribution, , the distribution of the individual variables can be computed as the marginal distributions and (considering X as continuous, hence integrating over it, and Y as discrete, hence summing over it), and either conditional distribution can be computed from the definition of conditional probability: and .
For example, given a generative model for , one can estimate:
and given a discriminative model for , one can estimate:
Note that Bayes' rule (computing one conditional probability in terms of the other) and the definition of conditional probability (computing conditional probability in terms of the joint distribution) are frequently conflated as well.
Contrast with discriminative classifiers
A generative algorithm models how the data was generated in order to categorize a signal. It asks the question: based on my generation assumptions, which category is most likely to generate this signal? A discriminative algorithm does not care about how the data was generated, it simply categorizes a given signal. So, discriminative algorithms try to learn directly from the data and then try to classify data. On the other hand, generative algorithms try to learn which can be transformed into later to classify the data. One of the advantages of generative algorithms is that you can use to generate new data similar to existing data. On the other hand, discriminative algorithms generally give better performance in classification tasks.
Despite the fact that discriminative models do not need to model the distribution of the observed variables, they cannot generally express complex relationships between the observed and target variables. They don't necessarily perform better than generative models at classification and regression tasks. The two classes are seen as complementary or as different views of the same procedure.
Types of generative models are:
- Gaussian mixture model (and other types of mixture model)
- Hidden Markov model
- Probabilistic context-free grammar
- Bayesian network (e.g. Naive bayes, Autoregressive model)
- Averaged one-dependence estimators
- Latent Dirichlet allocation
- Boltzmann machine (e.g. Restricted Boltzmann machine, Deep belief network)
- Variational autoencoder
- Generative adversarial network
- Flow-based generative model
If the observed data are truly sampled from the generative model, then fitting the parameters of the generative model to maximize the data likelihood is a common method. However, since most statistical models are only approximations to the true distribution, if the model's application is to infer about a subset of variables conditional on known values of others, then it can be argued that the approximation makes more assumptions than are necessary to solve the problem at hand. In such cases, it can be more accurate to model the conditional density functions directly using a discriminative model (see below), although application-specific details will ultimately dictate which approach is most suitable in any particular case.
- k-nearest neighbors algorithm
- Logistic regression
- Support Vector Machines
- Maximum-entropy Markov models
- Conditional random fields
- Neural networks
Suppose the input data is , the set of labels for is , and there are the following 4 data points:
For the above data, estimating the joint probability distribution from the empirical measure will be the following:
while will be following:
Shannon (1948) gives an example in which a table of frequencies of English word pairs is used to generate a sentence beginning with "representing and speedily is an good"; which is not proper English but which will increasingly approximate it as the table is moved from word pairs to word triplets etc.
- Ng & Jordan (2002): "Generative classifiers learn a model of the joint probability, , of the inputs x and the label y, and make their predictions by using Bayes rules to calculate , and then picking the most likely label y.
- Jebara 2004, 2.4 Discriminative Learning: "This distinction between conditional learning and discriminative learning is not currently a well established convention in the field."
- Ng & Jordan 2002: "Discriminative classifiers model the posterior directly, or learn a direct map from inputs x to the class labels."
- Mitchell 2015: "We can use Bayes rule as the basis for designing learning algorithms (function approximators), as follows: Given that we wish to learn some target function , or equivalently, , we use the training data to learn estimates of and . New X examples can then be classified using these estimated probability distributions, plus Bayes rule. This type of classifier is called a generative classifier, because we can view the distribution as describing how to generate random instances X conditioned on the target attribute Y.
- Mitchell 2015: "Logistic Regression is a function approximation algorithm that uses training data to directly estimate , in contrast to Naive Bayes. In this sense, Logistic Regression is often referred to as a discriminative classifier because we can view the distribution as directly discriminating the value of the target value Y for any given instance X.
- Ng & Jordan 2002
- Bishop, C. M.; Lasserre, J. (24 September 2007), "Generative or Discriminative? getting the best of both worlds", in Bernardo, J. M., Bayesian statistics 8: proceedings of the eighth Valencia International Meeting, June 2-6, 2006, Oxford University Press, pp. 3–23, ISBN 978-0-19-921465-5
- Shannon, C. E. (1948). "A Mathematical Theory of Communication" (PDF). Bell System Technical Journal. 27 (July, October): 379–423, 623–656.
- Mitchell, Tom M. (2015). "3. Generative and Discriminative Classifiers: Naive Bayes and Logistic Regression" (PDF). Machine Learning.
- Ng, Andrew Y.; Jordan, Michael I. (2002). "On discriminative vs. generative classifiers: A comparison of logistic regression and naive bayes" (PDF). Advances in neural information processing systems.
- Jebara, Tony (2004). Machine Learning: Discriminative and Generative. Kluwer Academic (Springer). ISBN 978-1-4020-7647-3.
- Jebara, Tony (2002). Discriminative, generative, and imitative learning (PhD). Massachusetts Institute of Technology. hdl:1721.1/8323., (mirror, mirror), published as book (above)