Giter Site home page Giter Site logo

stratzilla / k-means-clustering Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 413 KB

An implementation of K-Means clustering with K-Means++ initialization strategy

Python 100.00%
machine-learning unsupervised-learning k-means-clustering k-means k-means-plus-plus cluster-analysis

k-means-clustering's Introduction

K-Means Clustering

This is a Python implementation of the K-Means clustering algorithm using K-Means++ centroid initialization strategy.

K-Means clustering is a form of unsupervised learning where you have data and know its attributes but not its classification. It relies on the fact that similar data will stick together to form clusters, and the KM algorithm is meant to identify these clusters.

Here's an example visualization:

Dependencies

  • pandas
  • matplotlib
  • Python (3.6+)
  • GNU/Linux

Execution

You can clone these files to your computer with the below:

$ git clone https://github.com/stratzilla/k-means-clustering

Execute the script as the below:

$ ./k-means.py <File> <Type> <K> <Epochs>

Where the following are the arguments:

 <File> -- the data to perform k-means clustering upon
 <Type> -- the type of metric space to use:
        -- 1 - Euclidean Metric
        -- 2 - Manhattan Metric
        -- 3 - Chebyshev Metric
 <K> -- k-parameter, or how many clusters [2, 25]
 <Epochs> -- how many epochs for k-means to perform [1, 100]

Each epoch frame will be saved as an image in ./plots/. This directory will be made if it does not exist.

Using no arguments will remind the user of this. If the arguments are appropriate, the output to console will be the Dunn Index of the clustering.

Data

In /data are a few data sets as found here, each with a nomimal k=15.

Tutorial

I wrote a tutorial to go alongside this repository: here!

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.