An implementation of the k-means algorithm in C.
This implementation of the k-means algorithm contains functions for training and outputting the learned cluster centers. It also outputs the total dispersion of clustering, so you can run it multiple times with multiple different K and find the simplest solution that gives the least dispersion.
Clone the repository:
git clone https://github.com/czonios/c-kmeans.git
Change your directory and compile:
cd c-kmeans/src
make
Clean the intermediate objects and debugging derivative files:
make clean
The main.c
file contains the defined settings of the algorithm.
./main
The scripts
directory includes a Python script that generates an example dataset. You can call it by using:
python create_clustering_dataset.py
You can readily use GDB debugger by running:
make debug
gdb debug
- 0.1-alpha
- Work in progress
- 1.0.0 2020-10-09
- Initial full release
Christos A. Zonios – @czonios – czonios (at) gmail (dot) com
Distributed under the MIT license. See LICENSE
for more information.
https://github.com/czonios/c-kmeans
- Fork it (https://github.com/czonios/c-kmeans/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
- Add command line params (dataset file, K)