Simple kNN algorithm with k-Fold Cross Validation
Project description
simple-kNN
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 a classification problem, the new data point belongs to the class that most of the neighbors belong to.
- For a regression problem, the prediction can be an average or weighted average of the labels of k-Nearest Neighbors
Finally, we evaluate the model using the k-Fold Cross Validation technique
k-Fold Cross Validation
This technique involves randomly dividing the dataset into k approximately equal-sized groups, or folds. The first fold is kept for testing, and the model is trained on the 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
- My medium article on building kNN from scratch
- More info on Cross Validation can be seen here
- kNN
- kFold Cross Validation
Coming soon
- Other variants of the kNN algorithm
- Recommendations using the kNN algorithm
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_knn-2.0.1.tar.gz.
File metadata
- Download URL: simple_knn-2.0.1.tar.gz
- Upload date:
- Size: 143.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
223a0cc39f638e84787c7d2407aaec5e4c0a5ff80811608839575454f8f6c861
|
|
| MD5 |
76d9bad05433b05d82a20923aecad79d
|
|
| BLAKE2b-256 |
60c579c096a7409aad8519c82483b62ed33c1c8d1ca80cf259d670407fab8303
|
File details
Details for the file simple_knn-2.0.1-py3-none-any.whl.
File metadata
- Download URL: simple_knn-2.0.1-py3-none-any.whl
- Upload date:
- Size: 141.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ef5b0f79a4c72faf13f4f2dc7ec4021b5fc8876fd1ea98c36fdab41781eada6
|
|
| MD5 |
f55285fcd62c6c5bac7eff1613d460a1
|
|
| BLAKE2b-256 |
22033abfa783515d296cbd4ac24213e8af2fdfa5a7611e5ddba97ec37c16574e
|