Online K-Means

From Emcap


Online K-means Model

by Amaury Hazan <>

Pompeu Fabra University


Online K-means code

What is the Module?

This is a module for performing online K-means clustering

What are the inputs and outputs?

Inputs: A sequence of points in n dimension, eg: [[0,1,2],[3,0,1],...,[2,3,5]]

Outputs: The output is a clustering assignment for each point in the sequence

What are the parameters?

The parameters are

  • eps: learning rate
  • dim: dimensions of points to be procesed

What are the system requirements?

  • Python 2.4 or higher:

Follow the instructions at:

  • matplotlib 0.87 or higher (for graphical example)

How to Cite


 author    = 	{Hazan, Amaury and Brossier, Paul and Marxer, Ricard and Purwins, Hendrik},
 title     = 	{What/when causal expectation modelling in monophonic pitched and percussive audio},
 address   =   {Vancouver, Canada},
 booktitle =   {Music, Brain and Cognition. Part 2: Models of Sound and Cognition, 
               part of the Neural Information Processing Conference)},
 year      =   {2007}


How to Use, graphical example

 # import the online k-means
 import online_kmeans
 # launch the example
 # it draws randomly n points from k gaussians
 # and tries to cluster them sequentially using learning rate eps
 online_kmeans.example2(k=4, epsilon=0.5, n=100, order='ordered', dim=2)