model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C

type C interface {
	ToCollection() (Collection, error)
}

TODO : consider removing this abstraction (see usages)

type Collection

type Collection interface {
	Iterator
	Size() int
	Edge() (min, max Vector)
	Labels() []string
}

Collection represents a collection of data points

type Filter

type Filter func(Collection) bool
var Size Filter = func(collection Collection) bool {
	return collection.Size() > 0
}

type Iterator

type Iterator interface {
	Next() (vector Vector, ok, hasNext bool)
	Reset()
}

Iterator iterates over all vectors it is used to read the records of a collection

type Series

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

Series is a collection of vectors

func NewSeries

func NewSeries(labels ...string) *Series

NewSeries creates a new series of the specified dimension

func (*Series) Add

func (s *Series) Add(vector Vector)

Add adds a vector to the series the call should fail if the vectors dimensions are not the same as the ones of the defined series

func (*Series) Edge

func (s *Series) Edge() (min, max Vector)

Edge returns the edge values of the series this is useful for quick comparisons of collections of data, as well as drawing and scaling

func (*Series) Labels

func (s *Series) Labels() []string

Reset resets the iterator to the start of the collection

func (*Series) Next

func (s *Series) Next() (vector Vector, ok, hasNext bool)

Next returns the next vector in the series

func (*Series) Reset

func (s *Series) Reset()

Reset resets the iterator to the start of the collection

func (*Series) Size

func (s *Series) Size() int

Size returns the size of the series

func (Series) String

func (s Series) String() string

type V

type V interface {
	ToVector() (Vector, error)
}

TODO : consider removing this abstraction (see usages)

type Vector

type Vector struct {
	Label  []string
	Coords []float64
}

Vector defines a point in n dimensional space

func NewVector

func NewVector(label []string, x ...float64) Vector

NewVector creates a new point at the specified coordinates

func (Vector) Dim

func (p Vector) Dim() int

Dim returns the dimensions of the point

func (Vector) Distance

func (p Vector) Distance(element Vector) float64

Distance calculates the distance of the point to another vector

func (Vector) Norm

func (p Vector) Norm() float64

Norm returns the norm of the point e.g. the distance to the start of the coordinate system

Jump to

Keyboard shortcuts

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