Skip to content

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

License

Notifications You must be signed in to change notification settings

tushar-zomato/clusters

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%