|
| 1 | +### Felzenszwalb Clustering |
| 2 | + |
| 3 | +Using a distance matrix containing pairwise distances (which could use |
| 4 | +any measure) Felzenszwalb Clustering will print cluster membership per |
| 5 | +datapoint. |
| 6 | + |
| 7 | +The code is based on Felzenszwalb and Huttenlocher paper and shared |
| 8 | +C++ code. I simply took out the clustering code from inside the |
| 9 | +segmentation, so this project does not have any references to image |
| 10 | +processing, it simply does clustering with any given distance matrix. |
| 11 | + |
| 12 | +http://cs.brown.edu/~pff/segment/ |
| 13 | + |
| 14 | +The C++ version reads sparse matrices from mtx (money market |
| 15 | +format). Python version can be used as any clustering algorithm found |
| 16 | +in `scikit-learn`, through constructor and `fit` function. |
| 17 | + |
| 18 | +The main advantage of the algorithm is its ability to use any distance |
| 19 | +metric, its accuracy (as known from Felzenszwalb image segmentation), |
| 20 | +its speed, and determining the number of clusters on its own. The |
| 21 | +algorithm which is at the root of Felzenszwalb clustering is Minimum |
| 22 | +Spanning Tree which is known to have O(E log E) complexity where E is |
| 23 | +the number of edges in a graph. In comparison, other clustering |
| 24 | +methods presented here, |
| 25 | + |
| 26 | +http://scikit-learn.org/stable/modules/clustering.html |
| 27 | + |
| 28 | +such as Affinity Propagation, or Spectral Clustering do not enjoy the |
| 29 | +same level of performance and cannot handle large datasets. |
| 30 | + |
| 31 | + |
| 32 | +## Building |
| 33 | + |
| 34 | +`cd felzclust` |
| 35 | + |
| 36 | +`make` |
| 37 | + |
| 38 | +For Python version simple import is sufficient. |
| 39 | + |
| 40 | +## Running |
| 41 | + |
| 42 | +See `doc/test.pdf` or `felzclust/test.py` for details. The distance |
| 43 | +matrix should be in sparse form, in mtx format. A simple use case |
| 44 | + |
| 45 | +`felzclust/felzclust felzclust/simple.mtx 1.0 1` |
| 46 | + |
| 47 | +You will see output |
| 48 | + |
| 49 | +``` |
| 50 | +point;cluster |
| 51 | +0;2 |
| 52 | +1;2 |
| 53 | +2;2 |
| 54 | +3;4 |
| 55 | +4;4 |
| 56 | +``` |
| 57 | + |
| 58 | +A bigger example |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +## Pure Python |
| 65 | + |
| 66 | +Pure Python version of the code can be found under `felz.py` and `test_felz.py` |
| 67 | + |
| 68 | +## LICENSE |
| 69 | + |
| 70 | +The software is licensed under GPL v2. See COPYING for details. |
0 commit comments