Giter Club home page Giter Club logo

multi-class-logistic-regression's Introduction

Multi-Class-Logistic-Regression

Perform Classification of 5 types of images using logistic regression.

Classifying images is one of the major application areas of Machine vision. There are several state of the art algorithms developed such as AlexNet which uses convolution neural network and other algorithms such as multiclass logistic regression which uses machine learning techniques to do the same task

Obtaining Images

  1. To perform the training phase of the algorithm, training images of five categories are collected from kaggle.com. Although, thousands of images are available, due to the computation time taken by the algorithm for processing we only consider 500 images for each class.
  2. These image directories are loaded and each image is converted into a vector and concatenated to return a huge matrix.
  3. Each of these images has the size of 32X32X3, by sending these images to the getImages_project the image size is reduce to 8X8X3. The result from this function is stored and returned in another matrix of dimension 192XNum of Images.
  4. Similarly, matrices are obtained for five datasets that we considered. The datasets considered in this project are airplane, automobile, bird, cat, and deer. 1 is concatenated to each of the obtained matrix.
  5. Testing is done on 500 images, which are also obtained from kaggle.com and images are ordered one class after another. These are stored in X_test matrix with one concatenated in the first row.

Computing Phi Values

  1. Phi values are calculated by using the fminunc function which takes the parameters as fit_logr_cost which calculates the cost values along with gradient, initial phi and options. This MATLAB function fminunc will give the phi values which will maximize the prediction value when an image of similar type is multiplied to it.
  2. fminunc belongs to the function called fit_logr_project which will give the predictions (matrix obtained when phi is multipled with testing images) and phi values.
  3. Step 6 and 7 are repeated for five times which is the number of datasets. For each iteration the world(w) values are computed in such a way that it is 1 for the data set we are going to build a classifier and 0 for the rest of the dataset.
  4. Overall, we get five phi matrices which represent five classifiers to split the data, the maximum value among these five are picked which indicates the confidence of the image belonging to a specific dataset.

Displaying Images

  1. Max operation is performed on the phi values and max phi value for a given image is obtained and stored in a matrix I (Index) which is used to compute confusion matrix
  2. Based on the I matrix values, the dataset is divided into ten different cells where five cells are for correctly classified image and five cells are for wrongly classified images.
  3. These cells are given to the function visualizeIms which will display the different types of images with proper titles. Example of a visualized image is

How to Run this

-> Run MainFile.m

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.