Skip to content

D3.js | Visualization of the k-means clustering algorithm

Notifications You must be signed in to change notification settings

nl-hugo/d3-kmeans

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visualization of the k-means clustering algorithm in D3.js

============================================================

k-means clustering is a method of vector quantization, originally from signal processing, that is popular for cluster analysis in data mining. k-means clustering aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean, serving as a prototype of the cluster. This results in a partitioning of the data space into Voronoi cells.

source: wikipedia

k-means clustering

See the algorithm in action here.

Source Code Layout

media\				media files
kmeans.css          CSS stylesheet
index.html          webpage demonstrating the algorithm
kmeans.js           JavaScript file with the source code for the algorithm visualization
README.md           README file that appears on the website's github page

Raw Data

Data are randomly generated x,y-coordinates between 0 and the width/height of the canvas.

The Algorithm

  1. The algorithm is initialized with n random points, along with k randomly generated 'means' (centroid) within the data domain.
  2. When the algorithm starts, each point is assigned the color of the closest centroid, forming k clusters. Closest is defined as the smallest Euclidean distance between two points.
  3. The centroids are moved to the center of the cluster.
  4. Steps 2 and 3 are repeated until the maximum number of iterations is reached.

About

D3.js | Visualization of the k-means clustering algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published