kmeans

package module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2019 License: GPL-3.0 Imports: 4 Imported by: 2

README

KMeans-Go

Implementation of KMeans Clustering in Golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LabelCount added in v0.1.2

func LabelCount(Labels []int, K int) []int

LabelCount - Returns the number of Points per centroid

Types

type KMeans

type KMeans struct {
	//number of clusters
	K int
	//max number of iterations
	MaxIter int
	//Centroids of the clustering
	Centroids []Point
	//Points for clustering
	Points []Point
	//Labels of the corresponding point
	Labels []int
}

KMeans - Struct for KMeans Algorithm

func (*KMeans) AddPoint added in v0.1.2

func (kmeans *KMeans) AddPoint(point Point)

AddPoint - Add a new Point to the list and recalculate Centroids

func (*KMeans) AddPointList added in v0.1.2

func (kmeans *KMeans) AddPointList(Points []Point)

AddPointList - Add a list of Points to the list and recalculate Centroids

func (*KMeans) CentroidsToString added in v0.1.2

func (kmeans *KMeans) CentroidsToString() string

CentroidsToString - returns the string of Centroids

func (*KMeans) ComputeClosestCentroidIdx added in v0.1.4

func (kmeans *KMeans) ComputeClosestCentroidIdx(point Point) int

ComputeClosestCentroidIdx - returns the index of the closest centroid for that point

func (*KMeans) ComputeLabels added in v0.1.2

func (kmeans *KMeans) ComputeLabels() []int

ComputeLabels - Computes Labels of the Points

func (*KMeans) ComputeSSE added in v0.1.2

func (kmeans *KMeans) ComputeSSE() float64

ComputeSSE - computes Sum of Squared Erros

func (*KMeans) Fit added in v0.1.2

func (kmeans *KMeans) Fit(pointList []Point) bool

Fit - Fits the Points into K Centroids

func (*KMeans) GetPointIdxOfCentroid added in v0.1.2

func (kmeans *KMeans) GetPointIdxOfCentroid(centroidIdx int) []int

GetPointIdxOfCentroid - return indexes of Points of a certain centroid

func (*KMeans) InitCentroids added in v0.1.2

func (kmeans *KMeans) InitCentroids() bool

InitCentroids - Inits the Centroids for random

func (*KMeans) LabelCount added in v0.1.2

func (kmeans *KMeans) LabelCount() []int

LabelCount - Returns the number of Points per centroid

func (*KMeans) LabelsToString added in v0.1.2

func (kmeans *KMeans) LabelsToString() string

LabelsToString - Returns the string of Labels

func (*KMeans) PointsToString added in v0.1.2

func (kmeans *KMeans) PointsToString() string

PointsToString - Returns the String of the Points

type Point

type Point []float64

Point - Slice of Float64 Values

func ComputeCentroids added in v0.1.2

func ComputeCentroids(pointList []Point, distIndex []int, K int) []Point

ComputeCentroids - Recalculates Centroids position

func (Point) Norm added in v0.1.2

func (point Point) Norm() float64

Norm - returns the point norm

func (Point) PointDist added in v0.1.2

func (point Point) PointDist(p2 Point) float64

PointDist - returns the distance between to Points

func (Point) PointEqual added in v0.1.2

func (point Point) PointEqual(p2 Point) bool

PointEqual - Checks if a point is equal to another

func (Point) Print added in v0.1.2

func (point Point) Print()

Print - Prints the point vaues

func (Point) Subtract added in v0.1.2

func (point Point) Subtract(p2 Point) Point

Subtract - returns the value by value subtraction of two points

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL