Skip to content

Andersonsr/kmeanstool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K-Means Tool

This is a tool developed to be used as a graphical resource for educational purposes, enabling the visualization of each step taken during the execution of the k-means clustering algorithm.

Data file format

the function readData() expects a simple file containing a list of 2-dimensional points, one point per line and each coordinate separated by a blank space.

K-means

the file kmeans.py is executable and accept some arguments shown as follows.
  • -f : input filename
  • -k : number of clusters
  • -i : max iterations
  • -o : output filename

execution example:

python kmeans.py -k 3 -f 'datasets/data.dat'

the result of executing the commandline is shown below.

The red dots represent each centroid calculated in each iteration of the algorithm, while every other color represents one of the k classes.

Gif Generation

the code in gifGenerator.py takes a snapshot of the data in each of the iterations of the k-means process.

the gifGenerator.py file can receive some arguments as described below.

  • -f : input filename
  • -k : number of clusters
  • -i : max iterations
  • -o : output filename
  • -s : gif frames per second

execution example:

python gifGenerator.py -k 6 -s 1 -f datasets/data2.dat

the .gif output produced after running this command line can be seen below.

About

kmeans visualization tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages