Name | knarrow JSON |
Version |
0.8.0
JSON |
| download |
home_page | None |
Summary | Shoot a knarrow to the knee |
upload_time | 2023-07-01 17:11:12 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
elbow
knee
kneedle
optimization
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# knarrow
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/knarrow)
![PyPI - Downloads](https://img.shields.io/pypi/dm/knarrow)
![PyPI - License](https://img.shields.io/pypi/l/knarrow)
![PyPI](https://img.shields.io/pypi/v/knarrow)
![PyPI - Format](https://img.shields.io/pypi/format/knarrow)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/InCogNiTo124/knarrow)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/InCogNiTo124/knarrow/.github/workflows/lint-and-test.yml?branch=master)
![Read the Docs](https://img.shields.io/readthedocs/knarrow)
![Website](https://img.shields.io/website?url=https%3A%2F%2Fknarrow.readthedocs.org)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
Shoot a `knarrow` to the knee ;)
_(The lib is better than this pun, I swear.)_
Detect knee points in various scenarios using a plethora of methods
## Usage
Just plug in your values in a `list`, `tuple` or an `np.ndarray` and watch `knarrow` hit the knee:
```pycon
>>> from knarrow import find_knee
>>> find_knee([1, 2, 3, 4, 6]) # use a list
3
>>> find_knee((1, 2, 3, 4, 6)) # or a tuple
3
>>> import numpy as np
>>> y = np.array([1.0, 1.05, 1.15, 1.28, 1.30, 2.5, 3.6, 4.9])
>>> find_knee(y) # provide just the values
4
>>> x = np.arange(8)
>>> find_knee(x, y) # or both x and y
4
>>> A = np.vstack((x, y))
>>> A
array([[0. , 1. , 2. , 3. , 4. , 5. , 6. , 7. ],
[1. , 1.05, 1.15, 1.28, 1.3 , 2.5 , 3.6 , 4.9 ]])
>>> find_knee(A) # works with x in first row, y in the second
4
>>> A.T
array([[0. , 1. ],
[1. , 1.05],
[2. , 1.15],
[3. , 1.28],
[4. , 1.3 ],
[5. , 2.5 ],
[6. , 3.6 ],
[7. , 4.9 ]])
>>> find_knee(A.T) # also works with x in the first column, y in the second column
4
>>> find_knee(x, y, smoothing=0.01) # for better results use cubic spline smoothing
4
```
### CLI
This library can also come with a handy CLI if you install it with the `cli` extra:
```shell
$ pip install "knarrow[cli]"
$ cat data.txt | knarrow -
<stdin> 11
$ cat data.txt | knarrow -o value -
<stdin> 59874.14171519781845532648
$ knarrow --sort -d ',' -o value shuf_delim.txt
shuf_delim.txt 20
```
_(the `-` for stdin is, unfortunately, mandatory)_
Try writing `knarrow --help` for more info.
## Similar projects
While I've come up with most of these methods by myself, I am not the only one. Here is a (non-comprehensive) list of projects I've found that implement a similar functionality and may have been an inspiration for me:
- [mariolpantunes/knee](https://github.com/mariolpantunes/knee)
Note: this project was bootstrapped by [python-blueprint](https://github.com/johnthagen/python-blueprint). Since then, it has been heavily modified, though.
Raw data
{
"_id": null,
"home_page": null,
"name": "knarrow",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "elbow,knee,kneedle,optimization",
"author": null,
"author_email": "Marijan Smetko <msmetko@msmetko.xyz>",
"download_url": "https://files.pythonhosted.org/packages/e3/22/5b6d03bade8899072df246ab17f598e2a1a1fe0114974204c09308538afb/knarrow-0.8.0.tar.gz",
"platform": null,
"description": "# knarrow\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/knarrow)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/knarrow)\n![PyPI - License](https://img.shields.io/pypi/l/knarrow)\n![PyPI](https://img.shields.io/pypi/v/knarrow)\n![PyPI - Format](https://img.shields.io/pypi/format/knarrow)\n![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/InCogNiTo124/knarrow)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/InCogNiTo124/knarrow/.github/workflows/lint-and-test.yml?branch=master)\n![Read the Docs](https://img.shields.io/readthedocs/knarrow)\n![Website](https://img.shields.io/website?url=https%3A%2F%2Fknarrow.readthedocs.org)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nShoot a `knarrow` to the knee ;)\n\n_(The lib is better than this pun, I swear.)_\n\nDetect knee points in various scenarios using a plethora of methods\n\n\n## Usage\nJust plug in your values in a `list`, `tuple` or an `np.ndarray` and watch `knarrow` hit the knee:\n\n```pycon\n>>> from knarrow import find_knee\n>>> find_knee([1, 2, 3, 4, 6]) # use a list\n3\n>>> find_knee((1, 2, 3, 4, 6)) # or a tuple\n3\n>>> import numpy as np\n>>> y = np.array([1.0, 1.05, 1.15, 1.28, 1.30, 2.5, 3.6, 4.9])\n>>> find_knee(y) # provide just the values\n4\n>>> x = np.arange(8)\n>>> find_knee(x, y) # or both x and y\n4\n>>> A = np.vstack((x, y))\n>>> A\narray([[0. , 1. , 2. , 3. , 4. , 5. , 6. , 7. ],\n [1. , 1.05, 1.15, 1.28, 1.3 , 2.5 , 3.6 , 4.9 ]])\n>>> find_knee(A) # works with x in first row, y in the second\n4\n>>> A.T\narray([[0. , 1. ],\n [1. , 1.05],\n [2. , 1.15],\n [3. , 1.28],\n [4. , 1.3 ],\n [5. , 2.5 ],\n [6. , 3.6 ],\n [7. , 4.9 ]])\n>>> find_knee(A.T) # also works with x in the first column, y in the second column\n4\n>>> find_knee(x, y, smoothing=0.01) # for better results use cubic spline smoothing\n4\n```\n\n### CLI\nThis library can also come with a handy CLI if you install it with the `cli` extra:\n```shell\n$ pip install \"knarrow[cli]\"\n$ cat data.txt | knarrow -\n<stdin> 11\n$ cat data.txt | knarrow -o value -\n<stdin> 59874.14171519781845532648\n$ knarrow --sort -d ',' -o value shuf_delim.txt\nshuf_delim.txt 20\n```\n_(the `-` for stdin is, unfortunately, mandatory)_\nTry writing `knarrow --help` for more info.\n\n## Similar projects\n\nWhile I've come up with most of these methods by myself, I am not the only one. Here is a (non-comprehensive) list of projects I've found that implement a similar functionality and may have been an inspiration for me:\n- [mariolpantunes/knee](https://github.com/mariolpantunes/knee)\n\nNote: this project was bootstrapped by [python-blueprint](https://github.com/johnthagen/python-blueprint). Since then, it has been heavily modified, though.\n",
"bugtrack_url": null,
"license": null,
"summary": "Shoot a knarrow to the knee",
"version": "0.8.0",
"project_urls": {
"Documentation": "https://github.com/InCogNiTo124/knarrow#readme",
"Issues": "https://github.com/InCogNiTo124/knarrow/issues",
"Source": "https://github.com/InCogNiTo124/knarrow"
},
"split_keywords": [
"elbow",
"knee",
"kneedle",
"optimization"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c03c739588b09dcf4decde1e3e0c53f0debcbfe161cf57cdedfc245c466454f6",
"md5": "55f7387042ef68297dbd97bc1366084d",
"sha256": "cba0f7e4fc2601773bc5c3f737d4dfda068410afdac4ae894793b8da604548c3"
},
"downloads": -1,
"filename": "knarrow-0.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "55f7387042ef68297dbd97bc1366084d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 21326,
"upload_time": "2023-07-01T17:11:13",
"upload_time_iso_8601": "2023-07-01T17:11:13.816262Z",
"url": "https://files.pythonhosted.org/packages/c0/3c/739588b09dcf4decde1e3e0c53f0debcbfe161cf57cdedfc245c466454f6/knarrow-0.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e3225b6d03bade8899072df246ab17f598e2a1a1fe0114974204c09308538afb",
"md5": "f73ee925a0c5a3c40f2efbf6a95bd9a8",
"sha256": "0a17ebdcc27c37cc198165ee43ebd2dbfd03318d433777a4aeebaa0707657a66"
},
"downloads": -1,
"filename": "knarrow-0.8.0.tar.gz",
"has_sig": false,
"md5_digest": "f73ee925a0c5a3c40f2efbf6a95bd9a8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 18524,
"upload_time": "2023-07-01T17:11:12",
"upload_time_iso_8601": "2023-07-01T17:11:12.343605Z",
"url": "https://files.pythonhosted.org/packages/e3/22/5b6d03bade8899072df246ab17f598e2a1a1fe0114974204c09308538afb/knarrow-0.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-01 17:11:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "InCogNiTo124",
"github_project": "knarrow#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "knarrow"
}