Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knnn-0.0.7.tar.gz (477.2 kB view hashes)

Uploaded Source

Built Distribution

knnn-0.0.7-py3-none-any.whl (21.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page