What are the Discriminative and generative models?

To understand these terms better, let us consider an example. Suppose a person has two kids - kid A and kid B. Kid A learns and understands everything in depth whereas Kid B can only learn the differences between what he sees. One day, that person took them to the zoo where they saw a deer and a lion. After coming from the zoo, the person showed them an animal and asked them what it was. Kid A drew the images of both the animals he saw in the zoo. He compared the images and answered “the animal is deer” based on the closest match of the image. As Kid B learns things based on only differences, therefore, he easily answered: “the animal is deer.”.

In ML, we call Kid A a Generative Model and Kid B a Discriminative Model. To make it more clear, the Generative Model ‌learns the joint probability distribution p(x,y). It predicts the conditional probability using Bayes Theorem. Whereas a Discriminative model ‌predicts the conditional probability distribution p(y|x). Both of these models are used in supervised learning problems.