kmodes
Python implementations of the k-modes and k-prototypes clustering algorithms for clustering categorical data.
Decision gist · record as of 2026-08-14
Yes, if you need to cluster categorical or mixed-type data and want a scikit-learn-compatible interface. The low install friction and permissive license make it a straightforward choice. However, the dormant maintenance status (last release 2022-09-06) warrants checking compatibility with your current numpy and scikit-learn versions before committing to production use.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Input data must have consistent data types within columns; NaN values are not accepted and must be handled before clustering.
- Low friction install with standard dependencies (numpy, scikit-learn, scipy, joblib).
- Maintenance is dormant—last release was 2022-09-06, though the repository remains active with recent commits and no archived status.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; you must include the license text in distributions.
last release 2022-09-06 (1438 days) · last repo commit 2024-06-19 · 1,285 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 561,891 downloads/mo, #5,992 on PyPI
Alternatives
Verify before relying
pip install kmodes
import numpy as np
from kmodes.kmodes import KModes
data = np.random.choice(20, (100, 10))
km = KModes(n_clusters=4, init='Huang', n_init=5, verbose=1)
clusters = km.fit_predict(data)- Whether the dormant maintenance status affects compatibility with current numpy/scikit-learn versions.
- Performance characteristics and scalability limits for large datasets relative to alternatives.
What it is and what it does
kmodes provides Python implementations of k-modes and k-prototypes clustering, specialized for categorical and mixed data types. Unlike k-means, which clusters numerical data by Euclidean distance, k-modes clusters categorical variables by counting matching categories between points. k-prototypes extends this to handle datasets with both numerical and categorical features. The library mirrors scikit-learn's clustering API, making it familiar to users of that ecosystem.
The package relies on numpy for computation and supports parallel execution via joblib for multiple initialization runs. It includes initialization strategies such as Huang's method and density-based approaches. All runtime dependencies (numpy, scikit-learn, scipy, joblib) are standard data-science libraries with low installation friction.
Use it for
- Cluster customer records with mixed demographic (categorical) and behavioral (numerical) attributes.
- Segment product categories or survey responses where most features are discrete or nominal.
- Analyze categorical genomic or medical data where Euclidean distance is not meaningful.
- Reduce dimensionality or find patterns in text-encoded or one-hot-encoded feature sets.
- Benchmark or compare k-modes results against k-means on datasets with predominantly categorical features.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to cluster categorical or mixed-type data and want a scikit-learn-compatible interface.
The low install friction and permissive license make it a straightforward choice. However, the dormant maintenance status (last release 2022-09-06) warrants checking compatibility with your current numpy and scikit-learn versions before committing to production use.
Install
kmodes on PyPI
Before you install
Low friction install with standard dependencies (numpy, scikit-learn, scipy, joblib). Maintenance is dormant—last release was 2022-09-06, though the repository remains active with recent commits and no archived status.
Input data must have consistent data types within columns; NaN values are not accepted and must be handled before clustering.
License in practice
MIT license permits commercial and private use with minimal restrictions; you must include the license text in distributions.
Quickstart
pip install kmodes
import numpy as np
from kmodes.kmodes import KModes
data = np.random.choice(20, (100, 10))
km = KModes(n_clusters=4, init='Huang', n_init=5, verbose=1)
clusters = km.fit_predict(data)
Verify before relying
- Whether the dormant maintenance status affects compatibility with current numpy/scikit-learn versions.
- Performance characteristics and scalability limits for large datasets relative to alternatives.
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagesnumpyscikit-learnscipyjoblib |
| Maintenance | Dormant 1,438 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 561,891 / month, #5,992 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering |
Evidence: kmodes-0.12.2-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “categorical clustering”
- kmodesImplements k-modes and k-prototypes clustering algorithms for…
- esdaesda computes global and local spatial autocorrelation statistics,…
- category-encodersTransforms categorical variables into numeric representations using…
Give your agent the search over MCP, or paste the wish link into any chat.
More Scientific/Engineering packages
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
pandas provides fast, flexible data structures (Series and DataFrame) for loading, cleaning, transforming, and analyzing labeled or relational data in Python.
scipy provides numerical algorithms for mathematics, science, and engineering—including optimization, integration, linear algebra, Fourier transforms, signal and image processing, and ODE solvers—built on numpy arrays.
scikit-learn provides a comprehensive Python library for supervised and unsupervised machine learning, including classification, regression, clustering, dimensionality reduction, and model evaluation tools built on NumPy and SciPy.
Install it if you need to train, evaluate, or deploy supervised or unsupervised learning models.
dill extends Python's pickle module to serialize and deserialize a much wider range of Python objects, including functions, lambdas, classes, and interpreter sessions, to byte streams for storage or network transmission.
Multiprocess is an enhanced fork of Python's standard multiprocessing library that uses dill for better serialization, allowing you to spawn processes with a threading-like API and share complex objects between them.
Install it if you use multiprocessing and encounter pickle serialization limits with lambdas or complex objects.
See also jenkspy · k-means-constrained · gmr · hdbscan · category-encoders · prince · formulaic-contrasts · phik · kneed