tscluster

package module
v0.0.0-...-fe28737 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2019 License: MIT Imports: 6 Imported by: 0

README

tscluster

tscluster is time-series clustering implemented in Go.

Usage

Installation
$ go get github.com/tsurubee/tscluster
Example
func main() {
	var dataset [][]float64
	dataset = append(dataset, []float64{1, 1, 1, 1, 1, 1})
	dataset = append(dataset, []float64{1, 1, 1, 1, 1, 1, 1})
	dataset = append(dataset, []float64{2, 2, 2, 2, 2})
	dataset = append(dataset, []float64{2, 2, 2, 2, 2, 2, 2})

	tc := tscluster.NewTscluster(tscluster.DTW)
	labels, err := tc.Kmedoids(dataset, 2, 20)
	if err != nil {
	log.Fatal(err)
	}
	fmt.Println(labels)
}

#=>
[0 0 2 2]

It returns the label of the result of clustering on the given data array.
The numerical value of the label returns the index number of medoid of the cluster to which the data belongs.

License

MIT

Author

tsurubee

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DTW

func DTW(firstVec, secondVec []float64) (float64, error)

func EuclideanDistance

func EuclideanDistance(firstVec, secondVec []float64) (float64, error)

Types

type DistFunc

type DistFunc func([]float64, []float64) (float64, error)

type Point

type Point struct {
	X, Y int
}

type Tscluster

type Tscluster struct {
	DistFunc DistFunc
}

func NewTscluster

func NewTscluster(distance DistFunc) *Tscluster

func (*Tscluster) Kmedoids

func (tc *Tscluster) Kmedoids(data [][]float64, k int, maxIterations int) ([]int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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