An implementation of KNNN algorithm
Project description
knnn
K-Nearest Neighbors of Neighbors - for Anomaly Detection
pip install knnn
k-NN
k-NNN
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, 5)
x_test = np.random.rand(20, 5) + 1
# Create a KNNN object
knnn = KNNN(number_of_neighbors=3, number_of_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
Cite
@inproceedings{nizan2024k,
title={k-NNN: Nearest Neighbors of Neighbors for Anomaly Detection},
author={Nizan, Ori and Tal, Ayellet},
booktitle={Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision},
pages={1005--1014},
year={2024}
}
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 knnn-0.0.9.tar.gz.
File metadata
- Download URL: knnn-0.0.9.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1d7df34bd39927e2e225a888bb4f4aef2e5a5cfa61b7d4a04239d9ae27072ae
|
|
| MD5 |
a281313dcee93c2d0dfbf6e9b7969837
|
|
| BLAKE2b-256 |
a784948e01a7697ab6747c3b0387b7a9458c17e924aa1cfbf9a8979cffd2baa3
|
File details
Details for the file knnn-0.0.9-py3-none-any.whl.
File metadata
- Download URL: knnn-0.0.9-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af24b3ec9b6bffac92c91bf5f1212bbb6265c5500db7e16d5711517f6b44ed37
|
|
| MD5 |
10404adfbc82b3325ec7e8ed00115c21
|
|
| BLAKE2b-256 |
2b7d60d3d380206125641593c1ab422bb760c1bd3c6a16e8ef8bfbc3cb2ec825
|