Giter Club home page Giter Club logo

knn's Introduction

K-Nearest Neighbours

K Nearest Neighbour (KNN) is a non parametric and lazy learning algorithm method used for classification and regression. Non parametric means that the dataset is distribution-free or having a specified distribution but with the distribution's parameters unspecified.

Lazy algorithm mean sit does not need any training data points for model generation. All training data is used in the testing phase. This makes training faster and testing phase slower and costlier since it consumes more resources of your PC as the dataset increases.

KNN performs better with a lower number of features than a large number of features!

How does the KNN algorithm work?

In KNN, K is the number of nearest neighbours. It is the core deciding factor. It is generally an odd number when the number of classes are 2.

Simplest case of the algorithm: K = 1.

KNN has the following basic steps:

  1. Calculate distance using eucledan distance.
  2. Find closest neighbour.
  3. Vote for labels.

How do you decide the number of neighbours in KNN?

Using Elbow method.

Files in the repository

  • KNN_heart_disease.ipynb - In this file, I've analysed the dataset, then made the KNN model.
  • KNN_heart_improved.ipynb - In this file, I showed how to improve the accuracy of the KNN model.
  • Heart Disease folder - In this folder, the '.csv' extension file of the Heart disease dataset is present.
  • Breast Cancer folder - In this folder, the '.csv' extension file of the Breast cancer dataset is present.

knn's People

Contributors

rohankumawat avatar

Watchers

 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.