Skip to main content

https://github.com/bauxn/kernel-kmeans

Project description

Kernel K-Means

Implementation of a Kernel K-Means clustering framework in Python. Utilizes Cython to generate efficient C code.
https://github.com/bauxn/kernel-kmeans

Installation

Installation via Pip does not allow OpenMP. To use OpenMP, see github installation.

Pip

Ensure pip is updated, then run:

pip install KKMeans

Github

Install via:

git clone https://github.com/bauxn/kernel-kmeans

Then open the project folder and run

pip install .

Enabling OpenMP: There is a clearly marked line in setup.py that contains the compiler arguments. Before installing, these need to be edited so that they contain whichever command your compiler uses to enable OpenMP. There already is a outcommented line which contains the correct arguments (and some additional ones for efficiency) for the msvc compiler.

Basic Usage

from KKMeans import KKMeans

kkm = KKMeans(n_clusters=3, kernel="rbf")
kkm.fit(data)
print(kkm.labels_) # shows label for each datapoint
print(kkm.quality_) # print quality (default is inertia) of clustering

predictions = kkm.predict(data_to_predict) # returns labels of points in data_to_predict

KKMeans also contains the modules kernels (provides functionality to build kernel matrices / calculate kernels), elkan and lloyd which allow to calculate single iterations of the respective algorithms and quality, which contains functionality to calculate the silhouette coefficient. For more elaborate usage consult the thesis on github or the docstrings.

Limitations

As the computations happen C, in extreme cases overflows and other datatype errors may occur. Critical points are:

values datatype
kernel_matrix double
n_clusters long
cluster_sizes long
labels long
  1. The kernel matrix consists of the results of the kernel function, which usually is applied pairwise on the dataset. So ensuring the results are able to fit in a double is necessary.
  2. Ensure the number of clusters fits in a long.
  3. Ensure the number of points fits in a long.

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

KKMeans-0.1.0.tar.gz (848.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

KKMeans-0.1.0-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9Windows x86-64

File details

Details for the file KKMeans-0.1.0.tar.gz.

File metadata

  • Download URL: KKMeans-0.1.0.tar.gz
  • Upload date:
  • Size: 848.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for KKMeans-0.1.0.tar.gz
Algorithm Hash digest
SHA256 64bcfb5977a6e8311619cb70d72d0f0dcb38721709155870a1bfff4a0463c5e0
MD5 2764bb0e059a9f01ccd9cbdc29ad26e0
BLAKE2b-256 66495166f1e820e3b664833043406493a48c80381892fead97f4f3c4686a3949

See more details on using hashes here.

File details

Details for the file KKMeans-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: KKMeans-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for KKMeans-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3c12fcf1ddba5ba542daa064eb633631d1653d46bf06faa2e0b9db45ffc2515f
MD5 9bd3e3ea1af6b8a19b24cd78a948fe52
BLAKE2b-256 dbb56d2bc79cc7166c768780e9e80817dd9e7f4e2b809e0d8325d87b9d71110e

See more details on using hashes here.

Supported by

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