Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AverageDistance ¶
func AverageDistance(o Observation, observations Observations) float64
AverageDistance returns the average distance between o and all observations
Types ¶
type Cluster ¶
type Cluster struct { Center Coordinates Observations Observations }
A Cluster which data points gravitate around
func (*Cluster) Append ¶
func (c *Cluster) Append(point Observation)
Append adds an observation to the Cluster
func (Cluster) PointsInDimension ¶
func (c Cluster) PointsInDimension(n int) Coordinates
PointsInDimension returns all coordinates in a given dimension
type Clusters ¶
type Clusters []Cluster
Clusters is a slice of clusters
func New ¶
func New(k int, dataset Observations) (Clusters, error)
New sets up a new set of clusters and randomly seeds their initial positions
func (Clusters) CentersInDimension ¶
func (c Clusters) CentersInDimension(n int) Coordinates
CentersInDimension returns all cluster centroids' coordinates in a given dimension
func (Clusters) Nearest ¶
func (c Clusters) Nearest(point Observation) int
Nearest returns the index of the cluster nearest to point
type Coordinates ¶
type Coordinates []float64
Coordinates is a slice of float64
func (Coordinates) Coordinates ¶
func (c Coordinates) Coordinates() Coordinates
Coordinates implements the Observation interface for a plain set of float64 coordinates
func (Coordinates) Distance ¶
func (c Coordinates) Distance(p2 Coordinates) float64
Distance returns the euclidean distance between two coordinates
type Observation ¶
type Observation interface { Coordinates() Coordinates Distance(point Coordinates) float64 }
Observation is a data point (float64 between 0.0 and 1.0) in n dimensions
type Observations ¶
type Observations []Observation
Observations is a slice of observations
func (Observations) Center ¶
func (c Observations) Center() (Coordinates, error)
Center returns the center coordinates of a set of Observations