Skip to main content

Knee or elbow detection for curves

Project description

kneebow

Find the knee of a curve or the elbow of a curve.

Codacy Badge Build Status codecov

How it works

kneebow builds upon a very simple idea: if we want to find the elbow of a curve, we can simply rotate the data so that curve looks down and then take the minimum value. If we want to find the knee of the curve, we take the maximum value instead. It's as simple as that.

Installation

You can install the package via pip:

pip install kneebow

Alternatively, you can also install the latest version from GitHub:

pip install git+https://github.com/georg-un/kneebow.git

Usage

Let's assume, we try to find the elbow of the following data:

import numpy as np
data = np.array([[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8],  # linear until (8,8)
                 [9, 16], [10, 32], [11, 64], [12, 128], [13, 256], [14, 512]])   # exponential afterwards

Let's have a peak how this data looks like:

data_plot

To find the elbow, we create an instance of the Rotor class and use its fit_rotate method:

from kneebow.rotor import Rotor
 
rotor = Rotor()
rotor.fit_rotate(data)

Now we can get the index of the elbow as follows:

elbow_idx = rotor.get_elbow_index()
print(elbow_idx)  # 11

The Rotor class also comes with plot methods to inspect the data visually together with the estimated elbow/knee:

rotor.plot_elbow()

rotor_plot

License

Distributed under the MIT License. See LICENSE for more information.

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

kneebow-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

kneebow-1.0.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file kneebow-1.0.0.tar.gz.

File metadata

  • Download URL: kneebow-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for kneebow-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ed4e5acc0da0bf274091f5138e7909f752ac319a4189ac1a8c07a100d17df22a
MD5 5994afb0b728b369a90d4e10c5ed2579
BLAKE2b-256 78f03578ac52231a840e1e33f06b70bb67a111f54316ee92fa591728e4bf3d97

See more details on using hashes here.

File details

Details for the file kneebow-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kneebow-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for kneebow-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b19d8c7bb8a7dd9e6380a67a10cc8ac866699a6ccaa77f16e203a61321c444e7
MD5 76ddadbb3a667be4e3bd914aa59cf024
BLAKE2b-256 b452d0b0b4ac9aab1f9c4bebe350248785f9583fb1c16f7d7f865fca8dfa7612

See more details on using hashes here.

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