Coder Social home page Coder Social logo

spectral's Introduction

Spectral Clustering
-------------------
Tim Nugent 2014

Performs K-means clustering using top K eigenvectors of an affinity (kernel) matrix. Kernel matrix is generated using the radial basis function kernel before being normalised. Input is an nXp data matrix in CSV format via the read_data function, or an nXp Eigen MatrixXd object via the constructor.


Build
-----

Install Eigen, e.g.:

sudo apt-get install libeigen3-dev

or download from http://eigen.tuxfamily.org/.

Make sure the include path is set right in the Makefile.

Compile with 'make' or:

g++ -O3 --std=c++11 -Wall -Wextra -I/usr/include/eigen3 src/*.cpp -o bin/sc

On OS X using brew:

brew install eigen

Then:

g++ -O3 --std=c++11 -Wall -Wextra -I/usr/local/include/eigen3 src/*.cpp -o bin/sc


Run
---

Run with 'make test', or:

bin/sc

Spirals test CSV file is read from the data directory.


Output
------

bin/sc
Read data/spirals.csv
Iterations 1 : Error 1.7881 : Error delta 1.7881 : Centroid movement 0.0711
Iterations 2 : Error 0.4435 : Error delta 1.3446 : Centroid movement 0.0197
Iterations 3 : Error 0.2425 : Error delta 0.2010 : Centroid movement 0.0122
Iterations 4 : Error 0.2130 : Error delta 0.0295 : Centroid movement 0.0000
Iterations 5 : Error 0.2130 : Error delta 0.0000 : Centroid movement 0.0000
Wrote data/spirals_clustered.csv
Cluster assignments:
1 1 2 2 1 2 2 2 1 2 2 1 1 2 2 1 1 1 1 1 2 2 1 2 2 2 2 1 1 1 2 1 2 2 1 2 1 2 1 1 2 2 2 2 1 1 1 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 2 2 1 2 1 1 1 2 2 1 2 2 2 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 2 1 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 2 2 2 1 2 1 1 1 1 2 2 1 1 2 1 1 1 2 1 2 1 1 1 1 1 2 2 2 2 2 1 1 1 2 2 1 2 1 1 1 2 2 2 1 2 2 2 2 2 2 1 1 1 1 2 1 2 1 1 1 2 1 1 1 1 2 1 2 1 1 1 2 2 1 1 1 2 2 2 1 1 2 2 2 2 2 2 2 2 1 1 1 1 2 1 2 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 1 1 1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 2 1 1 2 2 2 2 1 1 1 2 2 2 2 2 2 1 1 2 2 1 1 1 1 1 1 1 2 2 2 2 1 2 1 2 1 1 2 2 2 1 2 1 1 1 1 2 2 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 2 1 
Plotting data using R...
src/plot.R

If R is installed, see spirals_clustered.png. A new CSV file (spirals_clustered.csv) is also written to data/ containing the cluster assignments.


To-do
-----

-Add more kernels
-Add automatic gamma tuning for RBF kernel


References
----------

K-means code adapted from:
https://github.com/pthimon/clustering

Useful info:
http://charlesmartin14.wordpress.com/2012/10/09/spectral-clustering/


Bugs
----

[email protected]

spectral's People

Contributors

timnugent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.