Skip to main content

A package for KNN Classification

Project description

KNN Classification Algorithm.

Anyone of you can use this library to do KNN Classification in Google Colab with a all numeric valued dataset. Github Open Source

Existing methods

  • KnnClassification(path,TargetAtLast) - It takes two parameter first one is a string of the csv file path and the second one is a boolean to specify, the position of the target coloum it target is at last then the value will be True.Returns a object of KnnClassification class
  • loadToList() - It returns the loaded dataset as a python list.
  • list_split(DataList) - It takes a single parameter the dataset list from the which is the return value of previous method,and it return a tuple containing three list Splited into Train(70%), Validation(15%), Test(15%).
  • knn(x_list,y_list,k) - It takes three parameter first one is either validation list or test list, second one is train list and the third one is value of k, It returns the accuracy of the dataset.

using process

1st need to add the library

pip install KnnClassificationRobGin

2nd You must need to mount your google drive if you want to load csv from your drive

from google.colab import drive
drive.mount('/content/gdrive')
# You must need to run this code script at first to mount your drive with colab 

Mount Drive with colab

3rd you need to copy the csv file path for further use

4th import KnnClassificationRobGin and set the file path and target position

import KnnClassificationRobGin as KNN
KNN = KNN.KnnClassification("/content/sample_data/file_name.csv",True) #set path

5th load the dataset into a list and split it

DataList = KNN.loadToList() #Loading the list of given dataset
Train,Validation,Test = KNN.list_split(DataList) # Spliting dataset into three

Run the knn to show the accuracy of the dataset

Accuracy = KNN.knn(Validation,Train,5) #Put Validation list to train or put test list to test.(here k=5)
print(Accuracy)

N.B: Its not neccessary to split your dataset using given method(fix size) you could split your dataset by your own custom size as well :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

KnnClassificationRobGin-1.0.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

KnnClassificationRobGin-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file KnnClassificationRobGin-1.0.0.tar.gz.

File metadata

  • Download URL: KnnClassificationRobGin-1.0.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for KnnClassificationRobGin-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a960e2c4548f7665b6ea61f5fdc51008afd1b2f909e1be14df2a1ecd27e2fc0c
MD5 b6b0d9e7c5dd851a911e85bea0377f8b
BLAKE2b-256 368c535cab5fb683f616caa31f6368d145f0caee9a7356b0376d5741a05b15d5

See more details on using hashes here.

File details

Details for the file KnnClassificationRobGin-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: KnnClassificationRobGin-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for KnnClassificationRobGin-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f432a079568c0d682bad63f7ee0078d14bc11d9fcab4197ff75790b468bf8a7
MD5 a17a2d643161ad62ea3e7eaad80576a4
BLAKE2b-256 ce5c1dfe949192f2a8beb99f4af2dbe42a0cc38b07b6b422641a473f95077218

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page