kmeans

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package kmeans provides k-means based implementation of online clustering

Index

Constants

This section is empty.

Variables

View Source
var ErrNullSet = errors.New("cannot draw over an empty set")

ErrNullSet indicates that a draw over an empty set was attempted

Functions

func CreateInitializer

func CreateInitializer(name string) core.Initializer

CreateInitializer creates an initializer with a name

func GivenInitializer

func GivenInitializer(k int, elemts []core.Elemt, space core.Space, _ *rand.Rand) (centroids core.Clust, err error)

GivenInitializer initializes a clustering algorithm with the k first testPoints.

func NewAlgo

func NewAlgo(conf Conf, space core.Space, data []core.Elemt, initializer core.Initializer, args ...interface{}) *core.Algo

NewAlgo creates a new kmeans algo

func PPInitializer

func PPInitializer(k int, elemts []core.Elemt, space core.Space, src *rand.Rand) (centroids core.Clust, err error)

PPInitializer initializes a clustering algorithm with kmeans++

func PPIter

func PPIter(clust core.Clust, elemts []core.Elemt, space core.Space, src *rand.Rand) (core.Elemt, error)

PPIter runs a kmeans++ iteration : draw an element the does not belong to clust

func RandInitializer

func RandInitializer(k int, elemts []core.Elemt, space core.Space, src *rand.Rand) (centroids core.Clust, err error)

RandInitializer initializes a clustering with random testPoints

func WeightedChoice

func WeightedChoice(weights []float64, rand *rand.Rand) (int, error)

WeightedChoice returns random index given corresponding weights

Types

type Conf

type Conf struct {
	core.CtrlConf
	Par       bool
	K         int
	FrameSize int
	RGen      *rand.Rand
	NumCPU    int // maximal number of CPU to use
}

Conf of KMeans

func (*Conf) SetDefaultValues added in v0.2.0

func (conf *Conf) SetDefaultValues()

SetDefaultValues initializes nil configuration values

func (*Conf) Verify

func (conf *Conf) Verify() (err error)

Verify configuratio

type Impl

type Impl struct {
	// contains filtered or unexported fields
}

Impl algorithm abstract implementation

func NewParImpl

func NewParImpl(conf Conf, initializer core.Initializer, data []core.Elemt, args ...interface{}) (impl Impl)

NewParImpl parallelizes algorithm implementation

func NewSeqImpl

func NewSeqImpl(conf Conf, initializer core.Initializer, data []core.Elemt, args ...interface{}) Impl

NewSeqImpl returns a sequential algorithm execution

func (*Impl) Copy

func (impl *Impl) Copy(model core.OCModel) (core.Impl, error)

Copy impl

func (*Impl) Init

func (impl *Impl) Init(model core.OCModel) (clust core.Clust, err error)

Init Algorithm

func (*Impl) Iterate

func (impl *Impl) Iterate(model core.OCModel) (clust core.Clust, runtimeFigures core.RuntimeFigures, err error)

Iterate the algorithm until signal received on closing channel or iteration number is reached

func (*Impl) Push

func (impl *Impl) Push(elemt core.Elemt, model core.OCModel) error

Push input element in the buffer

type ParStrategy

type ParStrategy struct {
	Degree int
}

ParStrategy parallelizes algorithm strategy

func (ParStrategy) Iterate

func (strategy ParStrategy) Iterate(space core.Space, centroids core.Clust, data []core.Elemt) core.Clust

Iterate processes input cluster

type SeqStrategy

type SeqStrategy struct {
}

SeqStrategy defines strategy for sequential execution

func (*SeqStrategy) Iterate

func (strategy *SeqStrategy) Iterate(space core.Space, centroids core.Clust, data []core.Elemt) core.Clust

Iterate processes input cluster

type Strategy

type Strategy interface {
	Iterate(space core.Space, centroids core.Clust, data []core.Elemt) core.Clust
}

Strategy Abstract Impl strategy to be implemented by concrete algorithms

Jump to

Keyboard shortcuts

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