An implementation of KNNN algorithm
Project description
knnn
K-Nearest Neighbors of Neighbors
pip install knnn
Description
This package provides a simple implementation of the K-Nearest Neighbors of Neighbors algorithm. The algorithm is a simple extension of the K-Nearest Neighbors algorithm, which is used for anomaly detection. The algorithm is based on the idea that the neighbors of the neighbors of a point gives more information than its neighbors. The algorithm can be used to improve the accuracy of the KNN algorithm.
Usage
from knnn import KNNN
import numpy as np
# Random data
x_normal = np.random.rand(100, 2)
x_test = np.random.rand(20, 2) + 1
# Create a KNNN object
knnn = KNNN(num_neighbors=3, num_neighbors_of_neighbors=25)
# Fit the model
knnn.fit(x_normal)
# Predict the labels of the test data
y_pred = knnn.predict(x_test)
Installation
The simplest way to install the package is to run:
pip install knnn
If you want to install the latest version from the master branch:
(-e option will allow you to change the code without reinstalling the package)
git clone https:\\github.com\knnn
cd knnn
python3 -m pip install -e .
If you want to build the package from source, run:
python3 -m build
and to install the built package, run:
python3 -m pip install --force-reinstall dist/*.whl
To run the tests, run:
pytest
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
File details
Details for the file knnn-0.0.8.tar.gz
.
File metadata
- Download URL: knnn-0.0.8.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb1d5659edb0705aed3fbbf4af9d518fba57e901d00190a8218400fb3db2f7de |
|
MD5 | 9591472c91ed12c38836eb8e65b6bdbe |
|
BLAKE2b-256 | 52d4717d22dc1f09b900d8e0bb6a289dd5ccc5405d8b4817c0d684b3c273478b |
File details
Details for the file knnn-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: knnn-0.0.8-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebaeb68d86132f1760e4ce4b945e114ce44da92cf7114c9175d06a333a3dc41e |
|
MD5 | f1007d197d3e9a2445656445a058b8c0 |
|
BLAKE2b-256 | 8a8fd8cd76df148c68778d31897931d7b5d4e8609c27b0585c148bf0407db456 |