Giter Site home page Giter Site logo

clustering's Introduction

LibClustering

This is a C++ port of the MATLAB code by L. Zelnik-Manor and P. Perona http://www.vision.caltech.edu/lihi/Demos/SelfTuningClustering.html. The self-tuning spectral clustering automatically finds the ideal number of clusters of an affinity matrix.

Build

You will need the Eigen2 library (libeigen2-devel) and CMake (only tested under Linux).

$ mkdir build
$ cd build
$ cmake ../
$ make

Overview

Spectral clustering derives its name from spectral analysis of a graph, which is how the data is represented. Each object to be clustered can initially be represented as an n-dimensional numeric vector, but there must also be some method for performing a comparison between each object and expressing this comparison as a scalar.

This n by n comparison of all objects with all others forms the affinity matrix, which can be intuitively thought of as a rough representation of an underlying undirected, weighted, and fully-connected graph whose edges express the relative relationships, or affinities, between each pair of objects in the original data.

This affinity matrix is then decomposed into its eigenvectors, forming a matrix where each column is an eigenvector.

Using K-means, each row of this matrix is clustered using a standard K-means algorithm.

Using self-tuning clustering, this matrix is Givens rotated to try to get each row with only one non-zero element. The algorithm then removes the smallest eigenvector and performs the same rotation. The number of eigenvectors where first rotation exists with only one non-zero element is the ideal number of clusters. For details on the algorithm, see http://www.vision.caltech.edu/lihi/Publications/SelfTuningClustering.pdf.

Example

Follow the instructions to build the library, then:

$ cd ../example
$ cmake .
$ make

Implementation Details

Due to the algorithm being ported from MATLAB, the evrot.cpp implementation uses a slightly odd style where objects are allocated on the heap, but passed around as references rather than pointers. This is so that the operator overloads provided by the Eigen2 library could be used naturally, but the structure of the program kept the same as in MATLAB.

clustering's People

Contributors

pthimon avatar

Watchers

James Cloos 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.