https://github.com/muesli/clusters
Data structs and algorithms for clustering data observations and basic computations in n-dimensional spaces
https://github.com/muesli/clusters
hacktoberfest
Last synced: about 1 month ago
JSON representation
Data structs and algorithms for clustering data observations and basic computations in n-dimensional spaces
- Host: GitHub
- URL: https://github.com/muesli/clusters
- Owner: muesli
- License: mit
- Created: 2018-06-02T11:31:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-16T10:34:05.000Z (about 2 years ago)
- Last Synced: 2025-04-19T12:13:47.790Z (about 2 months ago)
- Topics: hacktoberfest
- Language: Go
- Size: 8.79 KB
- Stars: 18
- Watchers: 2
- Forks: 19
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clusters
Data structs and algorithms for clustering data observations and basic
computations in n-dimensional spaces.## Example
```go
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
[](https://godoc.org/github.com/muesli/clusters)
[](https://travis-ci.org/muesli/clusters)
[](https://coveralls.io/github/muesli/clusters?branch=master)
[](http://goreportcard.com/report/muesli/clusters)