Skip to content

yfrist96/Bayesian_ML_Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Summary - Generative & Discriminative Classification of Images

In this project, I used Quadratic Discriminant Analysis (QDA) and a Bayesian Linear Regression model to classify images of dogs and frogs. The datasets used can be found at CIFAR-10 and contain 6,000 images—5,750 for training and 250 for testing.

Decision Boundaries

Given the dataset I fit the mean of a Gaussian to this data. Suppose we use the following log-likelihood: image where we have a prior over the mean: image. Using the posterior image I found the Minimum Mean Squared Error (MMSE) estimate and have plotted the mean decision boundry image.

Generative Classification of Images

I implemented QDA to create a generative classifier for images. To do this, I fit a multivariate Gaussian to each class of images independently and then compared the likelihoods to classify them. The appropriate conjugate prior for the covariance of a Gaussian is called the inverse Wishart distribution. This distribution models the covariance matrix of a Gaussian distribution since it is defined over positive definite (PD) matrices. In this project I assumed that: image where image. The MMSE estimate for the Gaussian distribution is then: image.

For each class (dogs and frogs), I fit a Gaussian distribution and used the following equation to classify both the training and test sets:

image

Below is the plot of the accuracy of QDA as a function of v:

Discriminative Classification of Images

I used a Bayesian Linear Regression model to classify images using the "classification as regression" method. To achieve this, I labeled the regression targets as ±1:

  • +1 for the first class (dogs)

  • -1 for the second class (frogs)

In other words, I fit the following model:

image

The basis functions I used were Gaussian basis functions, with centers defined by the first M training points: image.

I then trained the model with M basis functions from each class and plotted the training and test accuracy as a function of M. The test accuracy when using all the training data as basis functions (M = all) is 0.88.

Finally, I plotted the 25 dog images that the model was most and least confident in classifying.

A notable observation is that the 25 most confidently classified images often contain a dog with white fur, and the dog is clearly distinguished from the background.

Installation & Setup

  1. Clone the Repository
  2. Download the dogs and frogs CIFAR-10 Dataset from https://www.cs.toronto.edu/%7Ekriz/cifar.html
  3. Execute the code found in classifiers.py

About

Generative & Discriminative Classification of Images

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages