Skip to main content

py4knn

K-Nearest Neighbors Python Library

Getting Started

This project is simply an implementation of K-Nearest Neighbors algorithm in python programming language.

Prerequisites

This Project Has No Prerequisites

Installing

The easiest way to install py4knn is by using pip

pip install py4knn

Usage

There is only 1 public method of knn class. It is predict method, it takes 5 argument namely x_train, t_train, x_test, k, and distance calculation method. We provide 6 distances namely euclidean, squared_euclidean, manhattan, canberra, chebyshev, and bray_curtis.

from py4knn.k_nearest_neighbors import knn
classifier = knn()
x_train = [[0.23,0.54],[0.45,1.23],[1.54,0.23],[0.93,0.535]]
t_train = [0,1,0,1]
x_test = [[0.34,0.65],[0.90,0.50]]
y = classifier.predict(x_train,t_train,x_test,1,'euclidean')

Release files for py4knn 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py4knn 0.0.5
File Size Uploaded
py4knn-0.0.5.tar.gz 2.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py4knn 0.0.5
File Interpreter ABI Platform
py4knn-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 5.3 kB

Release files / py4knn-0.0.5.tar.gz

Download URL py4knn-0.0.5.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
91c1cf5d9c016d85357a8522d032f012bbba52d89e6831caa85fcc8c3be516d5
BLAKE2b-256 checksum
How to use checksums
d31f92ef9b4d0aa8ff057e3aac14358292abdee0cfe70dea75e3ded1470d002b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

Release files / py4knn-0.0.5-py3-none-any.whl

Download URL py4knn-0.0.5-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
173539824784c97dbf46aa7e90cf800c2c7001d2a59e28b5715518b60f370160
BLAKE2b-256 checksum
How to use checksums
35527a5399069c1341ba0f964f177d6099ceee5e3c50c2569be7633dc4e82f09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page