Giter Club home page Giter Club logo

svd-lda-image-rec's Introduction

svd-lda-image-rec

A simple example of image recognition using singular value decomposition and linear discriminant analysis, based on examples from the excellent Computational Methods for Data Analysis course on Coursera taught by Nathan Kutz.

Usage

Grab a copy of GNU Octave (or switch to the Matlab branch if you're using Matlab rather than Octave) and the image package, run Octave in this directory, and run main.m by simply typing main in Octave.

This will spit out a handful of graphs and images illustrating some interesting stuff. It will also print the success rate that indicates how well things went on the test data set (which should start out at 81.25%).

Have a look at the code to see what's going on and let me know how you improve it with pull requests!

Basic Idea

This is a rough sketch of what's going on:

  1. Load training data consisting of 80 dogs and 80 cats. Each consists of a 64x64 black and white image packed into one 4096x80 matrix for dogs and one for cats. One of the figures shows the first 9 dogs. These images are heavily processed - they're perfect face shots.
  2. Grab image edges, which we'll use for training. Another image shows how this looks on the first 9 dogs. Playing with the edge detection methods in dc_edges.m will have a big effect on the results.
  3. Generate the singular value decomposition for a matrix that includes both sets of data. We end up with "eigenfaces" (shown in one of the figures) in the U matrix that are the basis columns with which any individual image can be generated, weights of each basis column in the S matrix (we only use the first 20 features ... you can see why in the figure that shows the strengths of each feature), and the "mix" of basis vectors in U required to generate each animal in V.
  4. Use linear discriminant analysis to project the results and come up with a cat/dog threshold. Refer to the figure showing the LDA stats ... the red line is the threshold, one side is cats, the other is dogs.
  5. Load test data (can't use training data to test, that would make us think we were way more accurate than we really are).
  6. Generate the same LDA projection and test against the threshold we calculated earlier.
  7. Calculate success rate ... around 81% with the settings provided here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.