Documentation ¶
Overview ¶
Package gosom implements the self organizing map algorithm.
Index ¶
- func DrawDimensions(som *SOM, nodeWidth int) []image.Image
- func DrawUMatrix(som *SOM, nodeWidth int) image.Image
- type Lattice
- type Matrix
- type Node
- type SOM
- func (som *SOM) CF(progress float64) float64
- func (som *SOM) Classify(input []float64) []float64
- func (som *SOM) Closest(input []float64) *Node
- func (som *SOM) D(from, to []float64) float64
- func (som *SOM) Dimensions() int
- func (som *SOM) InitializeWithDataPoints(data *Matrix)
- func (som *SOM) InitializeWithRandomValues(data *Matrix)
- func (som *SOM) InitializeWithZeroes(dimensions int)
- func (som *SOM) Interpolate(input []float64, K int) []float64
- func (som *SOM) N(x, y int) *Node
- func (som *SOM) NI(distance float64) float64
- func (som *SOM) Neighbors(input []float64, K int) []*Node
- func (som *SOM) SaveAsJSON(destination io.Writer) error
- func (som *SOM) Step(data *Matrix, step int, training *Training)
- func (som *SOM) String() string
- func (som *SOM) Train(data *Matrix, training *Training)
- func (som *SOM) WeightMatrix() *Matrix
- func (som *SOM) WeightedInterpolate(input []float64, K int) []float64
- type Training
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawDimensions ¶
DrawDimensions draws the dimensions of the SOM as images.
Types ¶
type Lattice ¶
type Lattice []*Node
A Lattice is a collection of nodes arranged in a two dimensional space.
func NewLattice ¶
NewLattice returns an initialized lattice.
type Matrix ¶
type Matrix struct { Data [][]float64 Rows int Columns int Minimums []float64 Maximums []float64 Minimum float64 Maximum float64 NaNs bool }
A Matrix holds and extends a two dimensional float slice.
func LoadMatrixFromCSV ¶
LoadMatrixFromCSV reads CSV data and returns a new matrix.
func LoadMatrixFromJSON ¶
LoadMatrixFromJSON read JSON data and returns a new matrix.
func NewMatrix ¶
NewMatrix will create a new Matrix and work out the meta information. The function expects the float slice to be consistent in columns.
type Node ¶
A Node is a single neuron in a self organizing map.
type SOM ¶
type SOM struct { Width int Height int Nodes Lattice CoolingFunction string DistanceFunction string NeighborhoodFunction string }
SOM holds an instance of a self organizing map.
func LoadSOMFromJSON ¶
LoadSOMFromJSON reads data from source and returns a SOM.
func (*SOM) Dimensions ¶
Dimensions returns the dimensions of the nodes.
func (*SOM) InitializeWithDataPoints ¶
InitializeWithDataPoints initializes the nodes with random data points.
Note: Do not use this function if your data set includes null values. Use InitializeWithRandomValues instead.
func (*SOM) InitializeWithRandomValues ¶
InitializeWithRandomValues initializes the nodes with random values between the calculated minimums and maximums per dimension.
func (*SOM) InitializeWithZeroes ¶
InitializeWithZeroes initializes the nodes with zero initialized dimensions.
func (*SOM) Interpolate ¶
Interpolate interpolates the input using K neighbors.
func (*SOM) SaveAsJSON ¶
SaveAsJSON writes the SOM as a JSON file to destination.
func (*SOM) WeightMatrix ¶
WeightMatrix returns a matrix based on the weights of the nodes.
type Training ¶
type Training struct { SOM *SOM Steps int InitialLearningRate float64 FinalLearningRate float64 InitialRadius float64 FinalRadius float64 }
A Training holds settings for a SOM training.
func NewTraining ¶
NewTraining returns a new Training.
func (*Training) LearningRate ¶
LearningRate calculates the current learning rate.