Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michaelchughes/KMeansRex
Fast, vectorized C++ implementation of K-Means using the Eigen matrix template library. Includes Matlab and Python interfaces.
https://github.com/michaelchughes/KMeansRex
Last synced: 18 days ago
JSON representation
Fast, vectorized C++ implementation of K-Means using the Eigen matrix template library. Includes Matlab and Python interfaces.
- Host: GitHub
- URL: https://github.com/michaelchughes/KMeansRex
- Owner: michaelchughes
- License: bsd-3-clause
- Created: 2013-04-02T21:10:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-17T13:55:16.000Z (over 7 years ago)
- Last Synced: 2024-08-01T00:38:43.976Z (3 months ago)
- Language: C++
- Size: 48.8 KB
- Stars: 58
- Watchers: 6
- Forks: 19
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
KMeansRex : Fast C++ implementation of K-Means using the Eigen matrix template library, with hooks to Matlab and Python/Numpy
This toolbox is meant to be the tyrant lizard king of k-means implementations. It is at least 2x as fast as the native kmeans implementations provided by matlab and scipy. It provides smart modern kmeans++ initialization as a default. Code is fully vectorized using the excellent Eigen matrix template library.
# Repo Contents
* src/ : C++ source files and header files
* matlab/ : matlab MEX source files
* python/ : python package files# Dependencies
* Eigen Matrix Template Library (http://eigen.tuxfamily.org)
* Python 2.7 (for python functionality)
* * Requires numpy and other standard numerical packages.
* Matlab R2011 or greater (for matlab functionality)# Python Usage
Assuming your PYTHONPATH includes /path/to/KMeansRex/python/
```
>> import numpy as np
>> import KMeansRex
>> X = np.random.rand(1000,5)
>> Mu, Z = KMeansRex.RunKMeans(X, 3)
```# Matlab Usage
Assuming your current path includes /path/to/KMeansRex/matlab/
```
>> X = rand(1000, 5)
>> [Mu,Z] = KMeansRex( X, 3 );
```# C++ Usage
In your source file, include KMeansRexCoreInterface.h
```
#include "KMeansRexCoreInterface.h"
```Then you can call public functions like RunKMeans as needed.
# Compiling
To build everything for Matlab
```
$ cd /path/to/KMeansRex/
$ make matlab
```To build everything for Python
```
$ cd /path/to/KMeansRex/
$ make python
```To build a custom C++ application
When compiling, modify your include and library paths as necessary.
```
g++ main.cpp -o main \
-I/path/to/eigen \
-I/path/to/KMeansRex/src/ \
-L/path/to/KMeansRex/lib/ \
-Wl,-rpath=/path/to/KMeansRex/lib/ -lkmeansrex[32|64]
```All Makefile builds require a correct path to the Eigen library in the environment variable EIGEN_INCLUDE, which will be detected automatically via pkg-config if possible. See Makefile for details.
Useful flags for eigen to suppress many warnings:
* -Wno-ignored-attributes
* -Wno-misleading-indentation
* -Wno-deprecated-declarations# Author:
Mike Hughes (www.michaelchughes.com). Please email all comments/questions to mike AT michaelchughes.com# License
This software is released under a BSD 3-clause license. See the LICENSE file for details.# Acknowledgements
Thanks to Alexander Grebenyuk and Kaveh Vakili for many helpful suggestions which improved the organization and usefulness of this code.Includes the random number generation code provided by Makoto Matsumoto and Takuji Nishimura. Source: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html.