https://github.com/bauxn/kernel-kmeans. openMP is not enabled when installing via PiPy
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 are outcommented lines which contain the correct arguments (and some additional ones for efficiency) for the msvc and the gcc 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 |
- 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.
- Ensure the number of clusters fits in a long.
- Ensure the number of points fits in a long.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for KKMeans-0.0.9-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9220c671fe4baf474db551b32309d771a1f818b80b97c3ccdf696545f7c6ef13 |
|
MD5 | 4529ecb89eef1754ea4586c57f3caa84 |
|
BLAKE2b-256 | 1db72ceb227576696e5d6b4167ebad4f209e729a86105da62ad2e89acfe7f236 |