Skip to main content

Simple kNN algorithm with k-Fold Cross Validation

Project description

simple-kNN

pypi ci

This repository is for Continuous Integration of my simple k-Nearest Neighbors (kNN) algorithm to pypi package.

For notebook version please visit this repository

k-Nearest Neighbors

k-Nearest Neighbors, kNN for short, is a very simple but powerful technique used for making predictions. The principle behind kNN is to use “most similar historical examples to the new data.”

k-Nearest Neighbors in 4 easy steps

  • Choose a value for k
  • Find the distance of the new point to each record of training data
  • Get the k-Nearest Neighbors
  • Making Predictions
    • For classification problem, the new data point belongs to the class that most of the neighbors belong to.
    • For regression problem, the prediction can be average or weighted average of the label of k-Nearest Neighbors

Finally, we evaluate the model using k-Fold Cross Validation technique

k-Fold Cross Validation

This technique involves randomly dividing the dataset into k-groups or folds of approximately equal size. The first fold is kept for testing and the model is trained on remaining k-1 folds.

Installation

pip install simple-kNN

Usage

from simple_kNN.distanceMetrics import distanceMetrics
from simple_kNN.kFoldCV import kFoldCV
from simple_kNN.kNNClassifier import kNNClassifier

References

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

simple_kNN-1.1.6.tar.gz (137.8 kB view details)

Uploaded Source

File details

Details for the file simple_kNN-1.1.6.tar.gz.

File metadata

  • Download URL: simple_kNN-1.1.6.tar.gz
  • Upload date:
  • Size: 137.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for simple_kNN-1.1.6.tar.gz
Algorithm Hash digest
SHA256 658608ccf826d9ed71bd9370ef222fa43ed4423047f4e0686d9b3f369c3d4199
MD5 a50a0f38953ccc5fbae5bfbd16b8d4e5
BLAKE2b-256 5740cfc197edba96a0fa68367ddb540e675411d771fe60a43950b0c9a6353742

See more details on using hashes here.

Supported by

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