Compute Natural Breaks (Jenks algorythm)
Project description
Compute “natural breaks” (Fisher-Jenks algorithm) on list / tuple / array / numpy.ndarray of integers/floats.
Intented compatibility: CPython 3.4+
Wheels are provided via PyPI for windows users - Also available on conda-forge channel for Anaconda users
Usage :
This package consists of a single function (named jenks_breaks) which takes as input a list / tuple / array.array / numpy.ndarray of integers or floats. It returns a list of values that correspond to the limits of the classes (starting with the minimum value of the series - the lower bound of the first class - and ending with its maximum value - the upper bound of the last class).
>>> import jenkspy
>>> import random
>>> list_of_values = [random.random()*5000 for _ in range(12000)]
>>> breaks = jenkspy.jenks_breaks(list_of_values, nb_class=6)
>>> breaks
(0.1259707312994962, 1270.571003315598, 2527.460251085392, 3763.0374498649376, 4999.87456576267)
>>> import json
>>> with open('tests/test.json', 'r') as f:
... data = json.loads(f.read())
...
>>> jenkspy.jenks_breaks(data, nb_class=5) # Asking for 5 classes
(0.0028109620325267315, 2.0935479691252112, 4.205495140049607, 6.178148351609707, 8.09175917180255, 9.997982932254672)
# ^ ^ ^ ^ ^ ^
# Lower bound Upper bound Upper bound Upper bound Upper bound Upper bound
# 1st class 1st class 2nd class 3rd class 4th class 5th class
# (Minimum value) (Maximum value)
Installation
From pypi
pip install jenkspy
From source
git clone http://github.com/mthh/jenkspy
cd jenkspy/
python setup.py install
For anaconda users
conda install -c conda-forge jenkspy
Requirements (only for building from source):
C compiler
Python C headers
Motivation :
Making a painless installing C extension so it could be used more easily as a dependency in an other package (and so learning how to build wheels using appveyor).
Getting the break values! (and fast!). No fancy functionnality provided, but contributions/forks/etc are welcome.
Other python implementations are currently existing but not as fast nor available on PyPi.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for jenkspy-0.1.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a86f006889f30dff83509cd56efc86a3df77676f79e2c9feca4f5f98772d839 |
|
MD5 | 79987c798a1a86c8b03692adfe871e03 |
|
BLAKE2b-256 | 1a76faf3ce583d2dc8a44d56d003e268cfa90230e14ddb1bfb2db5acc8141c62 |
Hashes for jenkspy-0.1.6-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 766577ec6570a00f4b23736efa1c784387c9c29b2f0965d5170d5b8be500ef2a |
|
MD5 | 8dc6c7937998714f1443cffb91b3af5c |
|
BLAKE2b-256 | 63efc0cedcff2535c6fe8ce97bef60ae5f130d9469d39f899a8487822703bd3e |
Hashes for jenkspy-0.1.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa2f3aeba15d93e92c34398a0587df304619e62559e275582c3949ee271dfd63 |
|
MD5 | 0d0a1168eb419811a3308fc095d17081 |
|
BLAKE2b-256 | ac8b6ddad1350e329fe4e416e8057f9495aedef3e983b53895e1cd18b29b4a38 |
Hashes for jenkspy-0.1.6-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41e0fb171e57df7d8902e2913ca95a17c2d549cdda938fd9bc2ddb5da38d8852 |
|
MD5 | 9ed6cf89aec2174ec196a3b1cf8ff70c |
|
BLAKE2b-256 | 298b5f1efebb422ceaa29554aee9d87f394f548f641db6302f2cd582a07635bf |
Hashes for jenkspy-0.1.6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3775ffef4bdcc6dfd8dd13d63a81774664f23d5405e49f22d559eb4be927a0b1 |
|
MD5 | 97d71480aaea75e3e0aa7179ec9a0ae8 |
|
BLAKE2b-256 | 1871d6baa731b91a2adac129a2823f3faed19cab8d349ab40664800ffbb926e6 |
Hashes for jenkspy-0.1.6-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bbd124cfa5a52df55a78cf9eb868e611f4cc1068ddc8f3108d7d0fb24f3c8b4 |
|
MD5 | 3b5b6278703a21b22ab8d20ef6147b37 |
|
BLAKE2b-256 | abf49c1bbcefba0722c4e59a757c68bc2b6d4f484f7068cd17a4e6b9e42c7462 |
Hashes for jenkspy-0.1.6-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58e3b903e6fcbe5a2628b218ce21412c7d9ceb7ccee8c0b2488b37b32cc5b91f |
|
MD5 | 4e228af0478f76981552925d3901cc88 |
|
BLAKE2b-256 | 0766a1312d044db5ae09c9e8ca9f2f72609ad5276c47db1a919b655de8102c9d |
Hashes for jenkspy-0.1.6-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | def5d311749f1710ebc8b5cf2088b3f4a3e55393ddbc1910a6598c59a7aeaa8a |
|
MD5 | 20a8c0d51b40b227eb20d350fa8916c3 |
|
BLAKE2b-256 | 22798e4b5bcc4b418c35d6a7dd0eb476754e9601d44a7ffea2d0bed59c64f62c |
Hashes for jenkspy-0.1.6-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a19137fe531a5cd97d6fb62810a4bca0f62aefcb49d7f4d00d94fd3278e17c49 |
|
MD5 | 9b2477b07a03efa97f8ab0aa9bbf704b |
|
BLAKE2b-256 | 6a0656c741dd320b85f4d5f4eb839b89220b32246835a3afaf97a150d5150feb |
Hashes for jenkspy-0.1.6-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f91293e8723b547b909e084210ced94764db6c54c954d5896f0372e4d436a3db |
|
MD5 | 51c7388436c4b7c014022e7b3d5ca92d |
|
BLAKE2b-256 | e773d75cc378ee0db6ee0fa28cf68f716dafdc47a6e77b68387128114f2d000b |