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

前端 未结 13 742
孤独总比滥情好
孤独总比滥情好 2020-12-22 14:37

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

相关标签:
13条回答
  • 2020-12-22 14:55

    My two cents: Discriminative approaches highlight differences Generative approaches do not focus on differences; they try to build a model that is representative of the class. There is an overlap between the two. Ideally both approaches should be used: one will be useful to find similarities and the other will be useful to find dis-similarities.

    0 讨论(0)
  • 2020-12-22 14:56

    Imagine your task is to classify a speech to a language.

    You can do it by either:

    1. learning each language, and then classifying it using the knowledge you just gained

    or

    1. determining the difference in the linguistic models without learning the languages, and then classifying the speech.

    The first one is the generative approach and the second one is the discriminative approach.

    Check this reference for more details: http://www.cedar.buffalo.edu/~srihari/CSE574/Discriminative-Generative.pdf.

    0 讨论(0)
  • 2020-12-22 14:56

    The different models are summed up in the table below:

    0 讨论(0)
  • 2020-12-22 15:00

    Let's say you have input data x and you want to classify the data into labels y. A generative model learns the joint probability distribution p(x,y) and a discriminative model learns the conditional probability distribution p(y|x) - which you should read as "the probability of y given x".

    Here's a really simple example. Suppose you have the following data in the form (x,y):

    (1,0), (1,0), (2,0), (2, 1)

    p(x,y) is

          y=0   y=1
         -----------
    x=1 | 1/2   0
    x=2 | 1/4   1/4
    

    p(y|x) is

          y=0   y=1
         -----------
    x=1 | 1     0
    x=2 | 1/2   1/2
    

    If you take a few minutes to stare at those two matrices, you will understand the difference between the two probability distributions.

    The distribution p(y|x) is the natural distribution for classifying a given example x into a class y, which is why algorithms that model this directly are called discriminative algorithms. Generative algorithms model p(x,y), which can be transformed into p(y|x) by applying Bayes rule and then used for classification. However, the distribution p(x,y) can also be used for other purposes. For example, you could use p(x,y) to generate likely (x,y) pairs.

    From the description above, you might be thinking that generative models are more generally useful and therefore better, but it's not as simple as that. This paper is a very popular reference on the subject of discriminative vs. generative classifiers, but it's pretty heavy going. The overall gist is that discriminative models generally outperform generative models in classification tasks.

    0 讨论(0)
  • 2020-12-22 15:00

    Generally, there is a practice in machine learning community not to learn something that you don’t want to. For example, consider a classification problem where one's goal is to assign y labels to a given x input. If we use generative model

    p(x,y)=p(y|x).p(x)
    

    we have to model p(x) which is irrelevant for the task in hand. Practical limitations like data sparseness will force us to model p(x) with some weak independence assumptions. Therefore, we intuitively use discriminative models for classification.

    0 讨论(0)
  • 2020-12-22 15:03

    In practice, the models are used as follows.

    In discriminative models, to predict the label y from the training example x, you must evaluate:

    enter image description here

    which merely chooses what is the most likely class y considering x. It's like we were trying to model the decision boundary between the classes. This behavior is very clear in neural networks, where the computed weights can be seen as a complexly shaped curve isolating the elements of a class in the space.

    Now, using Bayes' rule, let's replace the enter image description here in the equation by enter image description here. Since you are just interested in the arg max, you can wipe out the denominator, that will be the same for every y. So, you are left with

    enter image description here

    which is the equation you use in generative models.

    While in the first case you had the conditional probability distribution p(y|x), which modeled the boundary between classes, in the second you had the joint probability distribution p(x, y), since p(x | y) p(y) = p(x, y), which explicitly models the actual distribution of each class.

    With the joint probability distribution function, given a y, you can calculate ("generate") its respective x. For this reason, they are called "generative" models.

    0 讨论(0)
提交回复
热议问题