skillfed

fastcluster

Fast hierarchical clustering routines for R and Python.

fastcluster v1.3.0 116.6K downloads/30d#12,198 on PyPI
Copyleft license BSD-2-clause OR GPL-2.0-or-later AGING released

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 fastcluster

uv

uv add fastcluster

poetry

poetry add fastcluster

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseLicense :: OSI Approved :: GNU General Public License v2 (GPLv2)Operating System :: OS IndependentProgramming Language :: C++Programming Language :: PythonProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: Bio-InformaticsTopic :: Scientific/Engineering :: Information AnalysisTopic :: Scientific/Engineering :: Mathematics

Tags

hierarchical clusteringagglomerative clusteringlinkage clusteringdendrogram generationfast clustering algorithmsdistance matrix clusteringward clusteringvector data clustering
clusteringhierarchical-methodsperformance-optimized

More Artificial Intelligence packages