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 jenkspyVerified import paths — ran on the pinned version, not inferred.
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.
Replace `nb_class` with `n_classes` in your function calls. E.g., `jenkspy.jenks_breaks(data, n_classes=5)`.
Ensure `numpy` is installed: `pip install numpy`.
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.
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.