What’s the difference between a generative and discriminative model?

A generative model will learn categories of data while a discriminative model will simply learn the distinction between different categories of data. Discriminative models will generally outperform generative models on classification tasks.

In machine learning, generative and discriminative models are two broad categories that differ in their approach to modeling and solving a problem.

  1. Generative Models:
    • Generative models learn the joint probability distribution �(�,�)P(X,Y) of the input features X and the corresponding labels Y.
    • Once the joint distribution is learned, it can be used to generate new samples that resemble the training data.
    • Examples of generative models include Naive Bayes, Gaussian Mixture Models (GMM), Hidden Markov Models (HMM), and Generative Adversarial Networks (GANs).
  2. Discriminative Models:
    • Discriminative models learn the conditional probability distribution �(�∣�)P(YX), i.e., the probability of labels given the input features.
    • These models directly learn the boundary between different classes or categories in the input space.
    • Discriminative models aim to directly model the decision boundary between classes rather than modeling the distribution of individual classes.
    • Examples of discriminative models include Logistic Regression, Support Vector Machines (SVM), Decision Trees, and Neural Networks (specifically when used for classification).

Key Differences:

  • Objective: Generative models aim to understand the data distribution and generate new samples, while discriminative models focus on learning the decision boundary between classes.
  • Usage: Generative models can be used for tasks such as generating new data samples, imputing missing values, or data augmentation. Discriminative models are typically used for classification or regression tasks.
  • Complexity: Generative models often require modeling a more complex joint distribution �(�,�)P(X,Y), which can make them computationally more demanding compared to discriminative models that directly model �(�∣�)P(YX).
  • Robustness: Discriminative models can sometimes be more robust when the class distribution is imbalanced or when there’s a large amount of irrelevant features, as they focus directly on the decision boundary.

In an interview setting, it’s important to articulate these differences clearly and provide examples to demonstrate understanding.