fastcluster
Fast hierarchical clustering routines for R and Python.
What it is and what it does
fastcluster is a Python library for hierarchical agglomerative clustering that reimplements scipy.cluster.hierarchy functions (linkage, single, complete, average, weighted, centroid, median, ward) with faster C++ algorithms. It accepts either distance matrices or raw vector data and generates hierarchical clusters represented as dendrograms. The interface mirrors MATLAB's Statistics Toolbox to ease code porting.
The package is a stable, mature tool designed as a drop-in replacement for scipy when speed matters. It depends only on numpy and requires Python 3 or later. Recent versions track scipy's distance function definitions—notably the Jaccard and Yule distance changes in version 1.3.0—so version pairing with scipy is recommended to avoid inconsistencies.
Use it for:
- Cluster datasets faster than scipy.cluster.hierarchy when hierarchical agglomerative methods are needed.
- Generate dendrograms from distance matrices or vector data for exploratory data analysis.
- Port MATLAB clustering code to Python with minimal API changes.
- Memory-efficient clustering of vector data via the linkage_vector function.
- Perform bioinformatics clustering where hierarchical methods are standard.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Performs fast hierarchical agglomerative clustering from distance matrices or vector data, replacing scipy.cluster.hierarchy functions with optimized C++ implementations.
Yes, if you need hierarchical clustering and scipy's performance is insufficient. The package is stable, has no known vulnerabilities, and offers a straightforward scipy-compatible API. The aging maintenance status is not a concern given the author's stated design philosophy (infrequent updates by design). Verify scipy version compatibility using the documented pairings to avoid distance function mismatches.
Install
fastcluster on PyPI
pip
pip install fastclusteruv
uv add fastclusterpoetry
poetry add fastclusterInstalling fastcluster
Before you install
Medium install friction due to compiled C++ components; prebuilt wheels available for Python 3.10–3.13 on macOS, Linux, and Windows. Package marked as aging (465 days since last release), but described as stable with infrequent updates by design rather than abandonment.
License in practice
Dual-licensed under BSD-2-clause OR GPL-2.0-or-later (copyleft). Users must comply with one of these licenses; GPL-2.0-or-later imposes source-sharing obligations if distributed.
Quickstart
import numpy as np
from fastcluster import linkage
X = np.random.rand(10, 5)
Z = linkage(X, method='ward')
Requires numpy; C++ compilation needed if prebuilt wheel unavailable for your platform.
Verify before relying
- Actual performance gains over scipy.cluster.hierarchy in typical workloads.
- Compatibility with scipy versions outside the documented pairings.
- Whether the package maintainer actively monitors bug reports at daniel@danifold.net or GitHub.
Package facts
| License | BSD-2-clause OR GPL-2.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | aging — 465 days since the last release |
| First released | |
| Downloads | 116,614/month — #12,198 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fastcluster-1.3.0-cp310-cp310-macosx_10_9_universal2.whl; fastcluster-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl; fastcluster-1.3.0-cp310-cp310-macosx_11_0_arm64.whl; fastcluster-1.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; fastcluster-1.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl; fastcluster-1.3.0-cp310-cp310-win_amd64.whl; fastcluster-1.3.0-cp311-cp311-macosx_10_9_universal2.whl; fastcluster-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl; fastcluster-1.3.0-cp311-cp311-macosx_11_0_arm64.whl; fastcluster-1.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; fastcluster-1.3.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl; fastcluster-1.3.0-cp311-cp311-win_amd64.whl; fastcluster-1.3.0-cp312-cp312-macosx_10_13_universal2.whl; fastcluster-1.3.0-cp312-cp312-macosx_10_13_x86_64.whl; fastcluster-1.3.0-cp312-cp312-macosx_11_0_arm64.whl; fastcluster-1.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; fastcluster-1.3.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl; fastcluster-1.3.0-cp312-cp312-win_amd64.whl; fastcluster-1.3.0-cp313-cp313-macosx_10_13_universal2.whl; fastcluster-1.3.0-cp313-cp313-macosx_10_13_x86_64.whl
Keywords: dendrogram, linkage, cluster, agglomerative, hierarchical, hierarchy, ward
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
scikit-fuzzyscikit-fuzzy provides fuzzy logic algorithms…
unclear · top 15,000 on PyPI
libcuvs-cu12GPU-accelerated vector search and clustering…
permissive · top 15,000 on PyPI
cuvs-cu12Provides GPU-accelerated approximate nearest…
permissive · top 15,000 on PyPI
pyspark-hnswProvides a PySpark-compatible implementation of…
unclear · top 15,000 on PyPI
crickCrick provides approximate and streaming…
permissive · top 15,000 on PyPI
faiss-gpuFaiss provides GPU-accelerated similarity…
permissive · top 15,000 on PyPI
kmodesImplements k-modes and k-prototypes clustering…
permissive · top 15,000 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
k-means-constrainedK-means clustering with enforced minimum and…
permissive · top 15,000 on PyPI