Skip to content
Partitional data clustering around centers
Branch: master
Clone or download
Latest commit 7673554 Jun 27, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake add hint for finding Cython May 8, 2018
data Initial commit Sep 15, 2016
python update experiments and plotting Nov 26, 2017
testsexamples clang warning changes Sep 18, 2017
zentas add missing header Jun 27, 2019
.clang-format format file add Sep 13, 2017
.gitignore ignore data/output.txt Sep 18, 2017
COPYING Initial commit Sep 15, 2016 update README Nov 26, 2017


A C++ and (optional) Python tool for partitional clustering. Optimised implementations of K-Medoids and K-Means, for various data types. More information is in our paper at arXiv 1609.04723.

K-Medoids a.k.a. K-Centers

Given N elements x(1)...x(N), select K elements indexed by c(1)...c(K), to minimise sum(i=1...N) min(k=1...K) E(distance (x(i), x(c(k)))) where distance is a valid distance and E is a non-decreasing function with E(0) = 0.

distance options are

  • for sparse and dense vectors : l-0, l-1, l-2, l-infinity
  • for sequence data : Levenshtein and Normalised Levenshtein.

Energy E options are

  • identity, quadratic, cubic, square-potential, exponential, and logarithmic.

K-Means for dense and sparse vector data

  • minimise sum of squares of l2 distances to cluster mean
  • minimise sum of l1 distances to cluster dimension-wise median


  • CMake
  • for the Python library: Cython and Python


Create a build directory:

mkdir build; cd build;

If you do NOT want the Python library,


If you do want the Python library,

cmake ..


The library can be built, from the build directory

make -j5

The shared library should now be in ./build/zentas ( in Linux) and the Python shared library in ./build/python ( in Linux). These can be moved/copied elsewhere manually, there is currently no install option for zentas.


Example use cases of the C++ library and headers are in testsexamples, with the corresponding executables in build/testsexamples. There is an example of clustering dense vectors (exdense.cpp), sparse vectors (exsparse.cpp), and sequences (exwords.cpp).

To use the Python library, make sure is on PYTHONPATH, for example you can use sys.path.append(/path/to/ Examples using pyzentas are in python/ More information can be obtained from the doc strings, try

import pyzentas

Doesn't work, or missing a feature?

Please raise an issue in the zentas repository

You can’t perform that action at this time.