Skip to content

A simple implementation for K nearest neighbor algorithm with k-fold cross-validation.

License

Notifications You must be signed in to change notification settings

mozi22/KNN-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KNN-implementation

A matlab implementation for the K-nearest neighbor algorithm (KNN) with K-fold cross validation. This implementation was part of our coursework.

For calculating data accuracy. I've used 3 different formulas for nearest neighbor distance calculation and did the k-fold cross validation for each of them.

  1. Manhattan Distance
  2. Chebychev Distance
  3. Euclidean Distance

The KNN is implemented for K=5, K=10 and K=15 respectively.

You can simply run the program by importing the dataset given in circular.txt and passing it to the KNN_crossvalidation function. Using the following statements.

KNN_crossvalidation(importdata(path_to_circular.txt))

The exercise sheet is given for your ease to understand what we were required to accomplish and how. This is the implementation for the first two questions mentioned in exercise.pdf.

I've also uploaded the topic slides, if anyone is interested in understanding the topic.

License

Copyright © 2018 Muazzam Ali

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A simple implementation for K nearest neighbor algorithm with k-fold cross-validation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages