Skip to main content

An implementation of the Kernel k-means algorithm for a bachelorthesis.

Project description



Implementation of the Kernel k-means clustering algorithm for multiple dimensions (including as well one-dimensional data) in Python. The results are visualized in plots and measured with quality metrics (e.g. Silhouette Coefficient). The algorithm can be used as a framework.

The related bachelor thesis can be found here: (read only) or as an exported .pdf here Bachelor_Thesis____Kernel_k_means_clustering_framework_in_Python.pdf


pip install python-kkmeans

The package can also be installed directly from this repository using pip install git+ssh://


from sklearn.datasets import make_blobs
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt

from kkmeans import kkmeans

n_clusters = 3
X, _ = make_blobs(n_samples=100, n_features=3, centers=n_clusters)
X_scaled = StandardScaler().fit_transform(X)

cluster_assignments = kkmeans(X, n_clusters=n_clusters)
plt.scatter(X_scaled[:,0], X_scaled[:,1], c=cluster_assignments)


Take a look at the examples folder to see benchmarking and plotted examples of the algorithm in action. The playground notebook should give you a comprehensive overview of the evaluation of the algorithm. It can be run after installing jupyter and running jupyter notebook from this folder.

Local Development

The following commands assume you run on a Linux or Mac, for Windows instructions take a look at the official documentations.

  • (optional) Create a venv python3 -m venv .venv
  • (optional) Active venv source .venv/bin/activate
  • (optional) Update pip pip install --upgrade pip
  • Install all required packages pip install -r requirements.txt


Testing is set up using pytest. Run all tests running the command pytest in the root directory. For detailed description on pytest see: Full pytest documentation

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-kkmeans-0.1.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

python_kkmeans-0.1.0-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page