Skip to content

A sample implementation of Naive Bayes and K-Nearest Neighbors (KNN) algorithms for Iris dataset.

License

Notifications You must be signed in to change notification settings

burakekici/Naive-Bayes-and-KNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Naive-Bayes-and-KNN

In this project, Naive Bayes classifi er and K-Nearest Neighbors classifi er are implemented with using Iris dataset.

First steps (applied for both algorithms)

  1. Numpy, scipy and sklearn libraries are downloaded.
  2. Dataset is shuffled.
  3. 5-fold cross validation is implemented. (4 parts are train set; 1 part is test set)

part1.py - Naive Bayes Classifier

  1. Iris dataset values are converted from float to integer.
  2. The model is trained.
  3. The class is predicted for each item in test set.

part2.py - K-Nearest Neighbors Classifier

  1. K-Nearest Neighbors are calculated.

To calculate KNN for k=3, it is needed to calculate the nearest three neighbors of the given item. Euclidian distance function is used to do this. Then, the most frequent class value is selected for the item in test set.

About

A sample implementation of Naive Bayes and K-Nearest Neighbors (KNN) algorithms for Iris dataset.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages