{"id":8245,"library":"jenkspy","title":"jenkspy","description":"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.","status":"active","version":"0.4.1","language":"python","source_language":"en","source_url":"https://github.com/mthh/jenkspy.git","tags":["geospatial","data-analysis","clustering","statistics","natural-breaks","fisher-jenks"],"install":[{"cmd":"pip install jenkspy","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Mandatory dependency for numerical operations, required since version 0.3.0.","package":"numpy","optional":false}],"imports":[{"wrong":"import jenkspy","symbol":"jenks_breaks","correct":"from jenkspy import jenks_breaks"}],"quickstart":{"code":"import jenkspy\nimport random\n\n# Generate some sample data\ndata = [random.uniform(0, 100) for _ in range(100)]\n\n# Compute natural breaks with 5 classes using the function API\nbreaks_func = jenkspy.jenks_breaks(data, n_classes=5)\nprint(f\"Jenks breaks (function API): {breaks_func}\")\n\n# Alternatively, use the scikit-learn inspired class API\nfrom jenkspy import JenksNaturalBreaks\nclassifier = JenksNaturalBreaks(n_classes=5)\nclassifier.fit(data)\n\n# Get the breaks and group labels\nbreaks_class = classifier.breaks_\ngroups = classifier.groups_ # Groups elements into corresponding class indices\n\nprint(f\"Jenks breaks (class API): {breaks_class}\")\nprint(f\"First 10 group labels: {groups[:10]}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Replace `nb_class` with `n_classes` in your function calls. E.g., `jenkspy.jenks_breaks(data, n_classes=5)`.","message":"The `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.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Ensure `numpy` is installed: `pip install numpy`.","message":"NumPy became a mandatory dependency starting from version 0.3.0. Installations without NumPy will fail or raise import errors.","severity":"breaking","affected_versions":">=0.3.0"},{"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.","message":"Attempting 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).","severity":"breaking","affected_versions":">=0.2.3"},{"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.","message":"If 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).","severity":"gotcha","affected_versions":">=0.4.1"}],"env_vars":null,"search_vec":"'0.4.1':55 '1':25 'activ':58 'algorithm':16 'analysi':48,66 'array':31 'boundari':41 'break':20,71 'cartographi':45 'class':40 'cluster':27,67 'comput':18 'current':52 'data':47,65 'data-analysi':64 'design':23 'determin':38 'dimension':26 'fast':9 'fisher':14,73 'fisher-jenk':13,72 'geospati':63 'implement':10 'integers/floats':36 'jenk':15,74 'jenkspi':1,2 'librari':6,50 'list':29 'maintain':59 'natur':19,70 'natural-break':69 'ndarray':34 'numpi':33 'optim':39 'provid':7 'python':5 'recent':61 'statist':68 'tupl':30 'updat':62 'use':43 'version':54 'wide':42","created_at":"2026-04-16T17:01:11.331035+00:00","updated_at":"2026-04-16T17:01:11.331035+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mthh/jenkspy","docs":null,"changelog":"https://github.com/mthh/jenkspy/blob/master/CHANGES.rst","pypi":"https://pypi.org/project/jenkspy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}