Name | kneed JSON |
Version |
0.8.5
JSON |
| download |
home_page | |
Summary | Knee-point detection in Python |
upload_time | 2023-07-09 01:51:08 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.5 |
license | |
keywords |
elbow-method
knee-detection
system
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# kneed
Knee-point detection in Python
[![Downloads](https://pepy.tech/badge/kneed)](https://pepy.tech/project/kneed) [![Downloads](https://pepy.tech/badge/kneed/week)](https://pepy.tech/project/kneed) ![Dependents](https://badgen.net/github/dependents-repo/arvkevi/kneed/?icon=github) [![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py) [![Build Status](https://travis-ci.com/arvkevi/kneed.svg?branch=main)](https://travis-ci.com/arvkevi/kneed) [![codecov](https://codecov.io/gh/arvkevi/kneed/branch/main/graph/badge.svg)](https://codecov.io/gh/arvkevi/kneed)[![DOI](https://zenodo.org/badge/113799037.svg)](https://zenodo.org/badge/latestdoi/113799037)
This repository is an attempt to implement the kneedle algorithm, published [here](https://www1.icsi.berkeley.edu/~barath/papers/kneedle-simplex11.pdf). Given a set of `x` and `y` values, `kneed` will return the knee point of the function. The knee point is the point of maximum curvature.
![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/functions_args_summary.png)
## Table of contents
- [Installation](#installation)
- [Usage](#usage)
- [Input Data](#input-data)
- [Find Knee](#find-knee)
- [Visualize](#visualize)
- [Documentation](#documentation)
- [Interactive](#interactive)
- [Contributing](#contributing)
- [Citation](#citation)
## Installation
`kneed` has been tested with Python 3.7, 3.8, 3.9, and 3.10.
**anaconda**
```bash
$ conda install -c conda-forge kneed
```
**pip**
```bash
$ pip install kneed # To install only knee-detection algorithm
$ pip install kneed[plot] # To also install plotting functions for quick visualizations
```
**Clone from GitHub**
```bash
$ git clone https://github.com/arvkevi/kneed.git && cd kneed
$ pip install -e .
```
## Usage
These steps introduce how to use `kneed` by reproducing Figure 2 from the manuscript.
### Input Data
The `DataGenerator` class is only included as a utility to generate sample datasets.
> Note: `x` and `y` must be equal length arrays.
```python
from kneed import DataGenerator, KneeLocator
x, y = DataGenerator.figure2()
print([round(i, 3) for i in x])
print([round(i, 3) for i in y])
[0.0, 0.111, 0.222, 0.333, 0.444, 0.556, 0.667, 0.778, 0.889, 1.0]
[-5.0, 0.263, 1.897, 2.692, 3.163, 3.475, 3.696, 3.861, 3.989, 4.091]
```
### Find Knee
The knee (or elbow) point is calculated simply by instantiating the `KneeLocator` class with `x`, `y` and the appropriate `curve` and `direction`.
Here, `kneedle.knee` and/or `kneedle.elbow` store the point of maximum curvature.
```python
kneedle = KneeLocator(x, y, S=1.0, curve="concave", direction="increasing")
print(round(kneedle.knee, 3))
0.222
print(round(kneedle.elbow, 3))
0.222
```
The knee point returned is a value along the `x` axis. The `y` value at the knee can be identified:
```python
print(round(kneedle.knee_y, 3))
1.897
```
### Visualize
The `KneeLocator` class also has two plotting functions for quick visualizations.
**Note that all (x, y) are transformed for the normalized plots**
```python
# Normalized data, normalized knee, and normalized distance curve.
kneedle.plot_knee_normalized()
```
![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/figure2.knee.png)
```python
# Raw data and knee.
kneedle.plot_knee()
```
![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/figure2.knee.raw.png)
## Documentation
Documentation of the parameters and a full API reference can be found [here](https://kneed.readthedocs.io/).
## Interactive
An interactive streamlit app was developed to help users explore the effect of tuning the parameters.
There are two sites where you can test out kneed by copy-pasting your own data:
1. https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py
2. https://ikneed.herokuapp.com/
You can also run your own version -- head over to the [source code for ikneed](https://github.com/arvkevi/ikneed).
![ikneed](images/ikneed.gif)
## Contributing
Contributions are welcome, please refer to [CONTRIBUTING](https://github.com/arvkevi/kneed/blob/main/CONTRIBUTING.md)
to learn more about how to contribute.
## Citation
Finding a “Kneedle” in a Haystack:
Detecting Knee Points in System Behavior
Ville Satopa
†
, Jeannie Albrecht†
, David Irwin‡
, and Barath Raghavan§
†Williams College, Williamstown, MA
‡University of Massachusetts Amherst, Amherst, MA
§
International Computer Science Institute, Berkeley, CA
Raw data
{
"_id": null,
"home_page": "",
"name": "kneed",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "elbow-method,knee-detection,system",
"author": "",
"author_email": "Kevin Arvai <arvkevi@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ba/0f/958e27a378042e0366dfea8baab4a53121cb37c114117666051390cd7bb8/kneed-0.8.5.tar.gz",
"platform": null,
"description": "# kneed\n Knee-point detection in Python\n\n[![Downloads](https://pepy.tech/badge/kneed)](https://pepy.tech/project/kneed) [![Downloads](https://pepy.tech/badge/kneed/week)](https://pepy.tech/project/kneed) ![Dependents](https://badgen.net/github/dependents-repo/arvkevi/kneed/?icon=github) [![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py) [![Build Status](https://travis-ci.com/arvkevi/kneed.svg?branch=main)](https://travis-ci.com/arvkevi/kneed) [![codecov](https://codecov.io/gh/arvkevi/kneed/branch/main/graph/badge.svg)](https://codecov.io/gh/arvkevi/kneed)[![DOI](https://zenodo.org/badge/113799037.svg)](https://zenodo.org/badge/latestdoi/113799037)\n\n\nThis repository is an attempt to implement the kneedle algorithm, published [here](https://www1.icsi.berkeley.edu/~barath/papers/kneedle-simplex11.pdf). Given a set of `x` and `y` values, `kneed` will return the knee point of the function. The knee point is the point of maximum curvature.\n\n![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/functions_args_summary.png)\n\n## Table of contents\n- [Installation](#installation)\n- [Usage](#usage)\n - [Input Data](#input-data)\n - [Find Knee](#find-knee)\n - [Visualize](#visualize)\n- [Documentation](#documentation)\n- [Interactive](#interactive)\n- [Contributing](#contributing)\n- [Citation](#citation)\n\n## Installation \n`kneed` has been tested with Python 3.7, 3.8, 3.9, and 3.10.\n\n**anaconda**\n```bash\n$ conda install -c conda-forge kneed\n```\n\n**pip**\n```bash\n$ pip install kneed # To install only knee-detection algorithm\n$ pip install kneed[plot] # To also install plotting functions for quick visualizations\n```\n\n**Clone from GitHub**\n```bash\n$ git clone https://github.com/arvkevi/kneed.git && cd kneed\n$ pip install -e .\n```\n\n## Usage\nThese steps introduce how to use `kneed` by reproducing Figure 2 from the manuscript.\n\n### Input Data\nThe `DataGenerator` class is only included as a utility to generate sample datasets. \n> Note: `x` and `y` must be equal length arrays.\n```python\nfrom kneed import DataGenerator, KneeLocator\n\nx, y = DataGenerator.figure2()\n\nprint([round(i, 3) for i in x])\nprint([round(i, 3) for i in y])\n\n[0.0, 0.111, 0.222, 0.333, 0.444, 0.556, 0.667, 0.778, 0.889, 1.0]\n[-5.0, 0.263, 1.897, 2.692, 3.163, 3.475, 3.696, 3.861, 3.989, 4.091]\n```\n\n### Find Knee \nThe knee (or elbow) point is calculated simply by instantiating the `KneeLocator` class with `x`, `y` and the appropriate `curve` and `direction`. \nHere, `kneedle.knee` and/or `kneedle.elbow` store the point of maximum curvature.\n\n```python\nkneedle = KneeLocator(x, y, S=1.0, curve=\"concave\", direction=\"increasing\")\n\nprint(round(kneedle.knee, 3))\n0.222\n\nprint(round(kneedle.elbow, 3))\n0.222\n```\n\nThe knee point returned is a value along the `x` axis. The `y` value at the knee can be identified:\n\n```python\nprint(round(kneedle.knee_y, 3))\n1.897\n```\n\n### Visualize\nThe `KneeLocator` class also has two plotting functions for quick visualizations.\n**Note that all (x, y) are transformed for the normalized plots**\n```python\n# Normalized data, normalized knee, and normalized distance curve.\nkneedle.plot_knee_normalized()\n```\n\n![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/figure2.knee.png)\n\n```python\n# Raw data and knee.\nkneedle.plot_knee()\n```\n\n![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/figure2.knee.raw.png)\n\n## Documentation\nDocumentation of the parameters and a full API reference can be found [here](https://kneed.readthedocs.io/).\n\n## Interactive\nAn interactive streamlit app was developed to help users explore the effect of tuning the parameters.\nThere are two sites where you can test out kneed by copy-pasting your own data:\n1. https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py\n2. https://ikneed.herokuapp.com/\n\nYou can also run your own version -- head over to the [source code for ikneed](https://github.com/arvkevi/ikneed).\n\n![ikneed](images/ikneed.gif)\n\n## Contributing\n\nContributions are welcome, please refer to [CONTRIBUTING](https://github.com/arvkevi/kneed/blob/main/CONTRIBUTING.md) \nto learn more about how to contribute. \n\n## Citation\n\nFinding a \u201cKneedle\u201d in a Haystack:\nDetecting Knee Points in System Behavior\nVille Satopa\n\u2020\n, Jeannie Albrecht\u2020\n, David Irwin\u2021\n, and Barath Raghavan\u00a7\n\u2020Williams College, Williamstown, MA\n\u2021University of Massachusetts Amherst, Amherst, MA\n\u00a7\nInternational Computer Science Institute, Berkeley, CA\n",
"bugtrack_url": null,
"license": "",
"summary": "Knee-point detection in Python",
"version": "0.8.5",
"project_urls": {
"Documentation": "https://kneed.readthedocs.io/en/latest/",
"Homepage": "https://github.com/arvkevi/kneed"
},
"split_keywords": [
"elbow-method",
"knee-detection",
"system"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9a1b7e726d8616e813007874468c61790099ba21493e0ea07561b7d9fc53151c",
"md5": "83e90dfba941e30701c9747639c02733",
"sha256": "2f3fbd4e9bd808e65052841448702c41ea64d5fc78735cbfc97ab25f08bd9815"
},
"downloads": -1,
"filename": "kneed-0.8.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "83e90dfba941e30701c9747639c02733",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 10290,
"upload_time": "2023-07-09T01:51:07",
"upload_time_iso_8601": "2023-07-09T01:51:07.548438Z",
"url": "https://files.pythonhosted.org/packages/9a/1b/7e726d8616e813007874468c61790099ba21493e0ea07561b7d9fc53151c/kneed-0.8.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ba0f958e27a378042e0366dfea8baab4a53121cb37c114117666051390cd7bb8",
"md5": "83cdebc06cf91ef8d71d29383c3733ac",
"sha256": "a4847ac4f1d04852fea278d5de7aa8bfdc3beb7fbca4a182fec0f0efee43f4b1"
},
"downloads": -1,
"filename": "kneed-0.8.5.tar.gz",
"has_sig": false,
"md5_digest": "83cdebc06cf91ef8d71d29383c3733ac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 12783,
"upload_time": "2023-07-09T01:51:08",
"upload_time_iso_8601": "2023-07-09T01:51:08.930223Z",
"url": "https://files.pythonhosted.org/packages/ba/0f/958e27a378042e0366dfea8baab4a53121cb37c114117666051390cd7bb8/kneed-0.8.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-09 01:51:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "arvkevi",
"github_project": "kneed",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "kneed"
}