All Projects → muesli → Kmeans

muesli / Kmeans

Licence: mit
k-means clustering algorithm implementation written in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Kmeans

Tql
TQL is a compile-time Rust ORM
Stars: ✭ 327 (-1.51%)
Mutual labels:  hacktoberfest
Limonengine
3D FPS game engine with full dynamic lighting and shadows
Stars: ✭ 331 (-0.3%)
Mutual labels:  hacktoberfest
Rf24mesh
OSI Layer 7 Mesh Networking for RF24Network & nrf24L01+ devices
Stars: ✭ 329 (-0.9%)
Mutual labels:  hacktoberfest
Openfoodfacts Server
Open Food Facts database and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff
Stars: ✭ 325 (-2.11%)
Mutual labels:  hacktoberfest
Valgrind Macos
A valgrind mirror with latest macOS support
Stars: ✭ 324 (-2.41%)
Mutual labels:  hacktoberfest
Quantumkatas
Tutorials and programming exercises for learning Q# and quantum computing
Stars: ✭ 3,713 (+1018.37%)
Mutual labels:  hacktoberfest
Bulma Admin Dashboard Template
🐝 Free admin dashboard template with bulma css
Stars: ✭ 327 (-1.51%)
Mutual labels:  hacktoberfest
Nnstreamer
🔀 Neural Network (NN) Streamer, Stream Processing Paradigm for Neural Network Apps/Devices.
Stars: ✭ 329 (-0.9%)
Mutual labels:  hacktoberfest
Betaflight Tx Lua Scripts
Collection of scripts to configure Betaflight from your TX (currently only supported in OpenTx)
Stars: ✭ 330 (-0.6%)
Mutual labels:  hacktoberfest
Chaos Mesh
A Chaos Engineering Platform for Kubernetes.
Stars: ✭ 4,265 (+1184.64%)
Mutual labels:  hacktoberfest
Patternfly
This repo contains core (HTML/CSS) implementation for PatternFly. Issues related to CSS/HTML and layout should be filed here.
Stars: ✭ 328 (-1.2%)
Mutual labels:  hacktoberfest
Animatedgradientview
🎞 Powerful gradient animations made simple for iOS.
Stars: ✭ 329 (-0.9%)
Mutual labels:  hacktoberfest
Home Assistantconfig
🏠 Home Assistant configuration & Documentation for my Smart House. Write-ups, videos, part lists, and links throughout. Be sure to ⭐ it. Updated FREQUENTLY!
Stars: ✭ 3,687 (+1010.54%)
Mutual labels:  hacktoberfest
Personalsit.es
📇 A little directory of people's personal sites
Stars: ✭ 329 (-0.9%)
Mutual labels:  hacktoberfest
Iproute2 Cheatsheet
iproute2 command reference
Stars: ✭ 330 (-0.6%)
Mutual labels:  hacktoberfest
Vue Storefront Api
Vue.js storefront for Magento2 (and not only) - data backend
Stars: ✭ 328 (-1.2%)
Mutual labels:  hacktoberfest
Ack3
ack is a grep-like search tool optimized for source code.
Stars: ✭ 330 (-0.6%)
Mutual labels:  hacktoberfest
Dev Ios
DEV Community iOS App
Stars: ✭ 334 (+0.6%)
Mutual labels:  hacktoberfest
Open Pixel Art
A collaborative pixel art project to teach people how to contribute to open-source
Stars: ✭ 331 (-0.3%)
Mutual labels:  hacktoberfest
Fastadapter
The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
Stars: ✭ 3,512 (+957.83%)
Mutual labels:  hacktoberfest

kmeans

Latest Release Build Status Coverage Status Go ReportCard GoDoc

k-means clustering algorithm implementation written in Go

What It Does

k-means clustering partitions a multi-dimensional data set into k clusters, where each data point belongs to the cluster with the nearest mean, serving as a prototype of the cluster.

kmeans animation

When Should I Use It?

  • When you have numeric, multi-dimensional data sets
  • You don't have labels for your data
  • You know exactly how many clusters you want to partition your data into

Example

import (
	"github.com/muesli/kmeans"
	"github.com/muesli/clusters"
)

// set up a random two-dimensional data set (float64 values between 0.0 and 1.0)
var d clusters.Observations
for x := 0; x < 1024; x++ {
	d = append(d, clusters.Coordinates{
		rand.Float64(),
		rand.Float64(),
	})
}

// Partition the data points into 16 clusters
km := kmeans.New()
clusters, err := km.Partition(d, 16)

for _, c := range clusters {
	fmt.Printf("Centered at x: %.2f y: %.2f\n", c.Center[0], c.Center[1])
	fmt.Printf("Matching data points: %+v\n\n", c.Observations)
}

Complexity

If k (the amount of clusters) and d (the dimensions) are fixed, the problem can be exactly solved in time O(ndk+1), where n is the number of entities to be clustered.

The running time of the algorithm is O(nkdi), where n is the number of d-dimensional vectors, k the number of clusters and i the number of iterations needed until convergence. On data that does have a clustering structure, the number of iterations until convergence is often small, and results only improve slightly after the first dozen iterations. The algorithm is therefore often considered to be of "linear" complexity in practice, although it is in the worst case superpolynomial when performed until convergence.

Options

You can greatly reduce the running time by adjusting the required delta threshold. With the following options the algorithm finishes when less than 5% of the data points shifted their cluster assignment in the last iteration:

km, err := kmeans.NewWithOptions(0.05, nil)

The default setting for the delta threshold is 0.01 (1%).

If you are working with two-dimensional data sets, kmeans can generate beautiful graphs (like the one above) for each iteration of the algorithm:

km, err := kmeans.NewWithOptions(0.01, kmeans.SimplePlotter{})

Careful: this will generate PNGs in your current working directory.

You can write your own plotters by implementing the kmeans.Plotter interface.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].