Giter Club home page Giter Club logo

image_classification_knn's Introduction

image_classification_knn

*Determine the class of these two red points?

Introduction

k-Nearest Neighbour is the most simple machine learning and image classification algorithm. This algorithm depends on the distance between features vectors. In our cases, these features are pixel values in image matrix (height x width) k-NN algorithm classifies new unknown data points by finding the most common class among the k-closet examples.

k-NN can also be used for regression. In this case, output is a continuous variable which is the average of k-closet data points.

k-NN is a non-parametric learning algorithm, which means that it doesn't assume anything about the underlying data

Some useful links

A Quick Introduction to K-Nearest Neighbors Algorithm

K-Nearest Neighbors Algorithm in Python and Scikit-Learn

Pros

  1. One main advantage of k-NN algorithm is that it's simple to implement and understand.
  2. It is lazy learning algorithm and therefore requires no training prior to making real time predictions. This makes the KNN algorithm much faster than other algorithms that require training e.g SVM, linear regression, etc.
  3. There are only two parameters required to implement KNN i.e. the value of K and the distance function (e.g. Euclidean or Manhattan etc.)

Cons

  1. k-NN is more suited for low-dimensional features spaces(which images are not). Distances in high-dimensional features spaces are often unintuitive (curse of dimensionality)
  2. k-NN doesn't learn anything, that means it does not work towrads improving the performance(error) by looking at previous steps
  3. Sharing of k-NN models can be a problem when the data size is really huge as it requires to share all the data.
  4. k-NN algorithm doesn't work well with categorical features since it is difficult to find the distance between dimensions with categorical features.

DATASET

Prerequisite

  1. Python3
  2. OpenCV 3
  3. Packages mentioned in knn.py
  4. Pycharm/ Jupyter Notebook

How to use

  1. Download the dataset and save it in the folder "datasets"
  2. Name of sub-folders in parent folder "datasets" represnt lables (class). In our case, it's "Dog", and "Cat"
  3. Clone the repository
  4. Run knn_model.py using cmd/pycharm/jupyter notebook

Happy Learning !!!

image_classification_knn's People

Contributors

shilparai avatar shilparai1407 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.