Coder Social home page Coder Social logo

j4nn0 / machine-learning-pca-svm Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 30.02 MB

PCA applied on images and Naive Bayes Classifier to classify them. Validation, cross validation and grid search with multi class SVM

License: GNU General Public License v3.0

Python 100.00%
pca-analysis machine-learning machine-learning-algorithms pca-implementation pca-predict pca-mode-visualization machine-learning-tutorials machine-learning-models classification-algorithm naive-bayes-classifier

machine-learning-pca-svm's Introduction

Machine Learning

Principal Component Analysis (PCA) applied on images and Naive Bayes Classifier used in order to classify them. Validation, cross validation and grid search performed with multi class Support-Vector Machines (SVM).

Table of Contents

Principal Component Analysis

It is shown what happens if different Principal Components (PC) are chosen as basis for images representation and classification. Then, the Naive Bayes Classifier has been choosen and applied in order to classify the image.

Addiotional information and step by step code explained in PCA README.md.

Checkout out documentation in order to have a more in-depth explenation. Also a demo is available on youtube.

Watch the video

PCA Image Reconstruction

Example result of PCA application on images: in the 2-PC and 6-PC is possible to see (with a little attention) the silhouette (shape) of a dog. Instead, in the 60-PC the silhouette is more evident. The more are the number of PC the more easier to see becomes the solhouette of the dog. The last 6-PC, as expected, are really bad and it is not possible to understand nothing.

img_reconstruction

PC Visualization

Each color is a different type of subjetc: blue -> dogs, green -> guitar, red -> houses and yellow -> people. The higher is the number of PC the more is the number informations that are brought. In the figure below is showed how, trough PC visualization, is possible to distinguish the different classes.

pc_visualization

Naive Bayes Classifier

The classifier is able to predict, given an observation of an input, a probability distribution over a set of classes, rather than only outputting the most likely class that the observation should belong to. After splitting the data-set into train and test set, I used the Naive Bayed Classifier in several cases and checked the respective accuracy.

classifier

Addiotional information and step by step code explained in Naive Bayes Classifier README.md.

Support-Vector Machines

Given a set of training examples, each marked as belonging to one or the other of two categories, an Support-Vector Machines (SVM) training algorithm builds a model that assigns new examples to one category or the other, making it a non-probabilistic binary linear classifier.

Addiotional information and step by step code explained in SVM README.md.

Checkout the documentation in order to have a more in-depth explenation. Also a demo is available on youtube.

Watch the video

An example of two different graphs in data classifciation using the rbf (Radial Basis Function) kernel.

  • Data and decision boundaries

    test_set
  • Validation accuracy

    validation_accuracy

Requirements

Install python dependencies (note that each sub prokect contains its own requirements.txt file) by running

 python -m pip install -r requirements.txt

Troubleshooting

If using sklearn you get the following error

 DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp

Check file 'cloudpickle.py' and delete row

 imports imp

machine-learning-pca-svm's People

Contributors

j4nn0 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zhoupanyun

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.