Skip to content

muesli/clusters

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

clusters

Data structs and algorithms for clustering data observations and basic computations in n-dimensional spaces.

Example

import "github.com/muesli/clusters"

// fake some observations
var o clusters.Observations
o = append(o, clusters.Coordinates{1, 1})
o = append(o, clusters.Coordinates{3, 2})
o = append(o, clusters.Coordinates{5, 3})

// seed a new set of clusters
c, err := clusters.New(2, o)

// add observations to clusters
c[0].Append(o[0])
c[1].Append(o[1])
c[1].Append(o[2])

// calculate the centroids for each cluster
c.Recenter()

// find the nearest cluster for an observation
i := c.Nearest(o[1])
// => returns index 1

// find the neighbouring cluster and its average distance for an observation
i, d := c.Neighbour(o[0], 0)
// => returns index 1 with euclidean distance 12.5

Development

GoDoc Build Status Coverage Status Go ReportCard

About

Data structs and algorithms for clustering data observations and basic computations in n-dimensional spaces

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages