Registry / data / jenkspy

jenkspy

JSON →
library0.4.1pypypi✓ verified 82d ago

Jenkspy is a Python library providing a fast implementation of the Fisher-Jenks algorithm for computing 'natural breaks'. It's designed for 1-dimensional clustering on lists, tuples, arrays, or NumPy ndarrays of integers/floats to determine optimal class boundaries. Widely used in cartography and data analysis, the library is currently at version 0.4.1 and is actively maintained with recent updates.

pip install jenkspy
INSTALL
IMPORT
SIG · JENKSPY
J
jenkspy
datapythonv0.4.1
Install
3.7s avg
Import
270ms
Disk
89MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.7s · import 0.270s · 88MB
89MB installed
● package 89MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jenks_breaks
from jenkspy import jenks_breaks
import jenkspy

This quickstart demonstrates both the functional (`jenks_breaks`) and object-oriented (`JenksNaturalBreaks`) ways to compute natural breaks. The functional approach directly returns the break points, while the class-based API provides a scikit-learn-like interface with `fit` and `groups_` methods for more complex workflows.

import jenkspy import random # Generate some sample data data = [random.uniform(0, 100) for _ in range(100)] # Compute natural breaks with 5 classes using the function API breaks_func = jenkspy.jenks_breaks(data, n_classes=5) print(f"Jenks breaks (function API): {breaks_func}") # Alternatively, use the scikit-learn inspired class API from jenkspy import JenksNaturalBreaks classifier = JenksNaturalBreaks(n_classes=5) classifier.fit(data) # Get the breaks and group labels breaks_class = classifier.breaks_ groups = classifier.groups_ # Groups elements into corresponding class indices print(f"Jenks breaks (class API): {breaks_class}") print(f"First 10 group labels: {groups[:10]}")
Debug
Known issues
breakingThe `nb_class` parameter for `jenks_breaks` was renamed to `n_classes` in version 0.3.0 to align with scikit-learn conventions. Using `nb_class` in newer versions will raise an error.
fix
Replace `nb_class` with `n_classes` in your function calls. E.g., `jenkspy.jenks_breaks(data, n_classes=5)`.
affects: >=0.3.0
breakingNumPy became a mandatory dependency starting from version 0.3.0. Installations without NumPy will fail or raise import errors.
fix
Ensure `numpy` is installed: `pip install numpy`.
affects: >=0.3.0
breakingAttempting to compute breaks on data containing non-finite values (NaN, Inf) or a non-one-dimensional NumPy array will now raise an error instead of a warning (since 0.2.3).
fix
Filter out or handle non-finite values in your data, and ensure NumPy arrays are 1-dimensional before passing them to `jenkspy` functions or classes.
affects: >=0.2.3
gotchaIf the requested `n_classes` is greater than the number of unique values in the input data, `jenkspy` will raise an exception (since 0.4.1).
fix
Ensure that `n_classes` is less than or equal to the number of unique values in your dataset. Consider pre-processing your data to count unique elements.
affects: >=0.4.1
Upgrade
Version history
0.4.1latest on PyPI · released Jun 3, 2024
Audit
Dependencies
numpyrequiredMandatory dependency for numerical operations, required since version 0.3.0.
Agent activity
4 hits · last 30 days
node
4
Resources
jenkspy — pip install jenkspy · libregistry