Giter Club home page Giter Club logo

k-means-clustering-and-pca's Introduction

K-Means Clustering and Principal Component Analysis

Part One: Implementing the K-Means clustering algorithm and using it to compress an image.

K-Means is an algorithm which automatically clusters similar data together. First, it assigns every training example (point) with its closest centroid:

image

The second part of the algorithm recomputes the mean of the points that were assigned to it:

image

Running K-Means on an example dataset:

image

Compressing an example image:

Initially, the image has a size of 128 x 128 pixel locations with 24 bits at each location which is 393, 216 bits. The new image has a size of 65, 920 bits after using the algorithm to group similar data together. This compression redues the size by a factor of 6.

image

Part Two: Principal Component Analysis for Dimensionality Reduction

First Step:

Compute the covariance matrix of the data:

image

Second Step:

Use the SVD function to compute the eigenvectors

Visualization Example of Projected data after PCA:

image

Using PCA on Faces Dataset

Each face image starts with 32 x 32 = 1024 pixels

image

They are then compressed into a vector of R^100. More than 10 times reduction!

image

This can be used to train data much more efficiently

The images can then be reconstrcuted from the compressed data using an estimate

image

Program based on Stanford's Machine Learning Course.

k-means-clustering-and-pca's People

Contributors

graydonhope avatar

Watchers

James Cloos avatar

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.