Skip to main content

knnn

K-Nearest Neighbors of Neighbors - for Anomaly Detection

pip install knnn
k-NN

k-NN

k-NNN

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}
}

Metadata

Release files for knnn 0.0.9

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

Source distribution (sdist)

Source distribution for knnn 0.0.9
File Size Uploaded
knnn-0.0.9.tar.gz 19.4 kB Details

Built distribution (wheel)

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

Total release size: 40.5 kB

Release files / knnn-0.0.9.tar.gz

Download URL knnn-0.0.9.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d1d7df34bd39927e2e225a888bb4f4aef2e5a5cfa61b7d4a04239d9ae27072ae
BLAKE2b-256 checksum
How to use checksums
a784948e01a7697ab6747c3b0387b7a9458c17e924aa1cfbf9a8979cffd2baa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / knnn-0.0.9-py3-none-any.whl

Download URL knnn-0.0.9-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af24b3ec9b6bffac92c91bf5f1212bbb6265c5500db7e16d5711517f6b44ed37
BLAKE2b-256 checksum
How to use checksums
2b7d60d3d380206125641593c1ab422bb760c1bd3c6a16e8ef8bfbc3cb2ec825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.0.9 This release

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