layer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package layer provides SOM layers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layer

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

Layer represents a layer of data in a Self-organizing Map.

func New

func New(name string, columns []string, normalizers []norm.Normalizer, size Size, metric distance.Distance, weight float64, categorical bool) (*Layer, error)

New creates a new Layer.

func NewWithData

func NewWithData(name string, columns []string, normalizers []norm.Normalizer, size Size, metric distance.Distance, weight float64, categorical bool, data []float64) (*Layer, error)

NewWithData creates a new Layer with the given initial data.

func (*Layer) Column

func (l *Layer) Column(col string) int

Column returns the index of the column with the given name in the Layer. If the column is not found, it returns -1.

func (*Layer) ColumnMatrix

func (l *Layer) ColumnMatrix(col int) [][]float64

ColumnMatrix returns a 2D slice of float64 values representing the data for the specified column in the Layer. Each inner slice represents a row in the Layer, and the values in the slice correspond to the values in that column.

func (*Layer) ColumnNames

func (l *Layer) ColumnNames() []string

ColumnNames returns the names of the columns in the Layer.

func (*Layer) Columns

func (l *Layer) Columns() int

Columns returns the number of columns in the Layer.

func (*Layer) CoordsAt

func (l *Layer) CoordsAt(idx int) (int, int)

CoordsAt returns the (x, y) coordinates of the node at the specified index.

func (*Layer) DeNormalize

func (l *Layer) DeNormalize()

DeNormalize all weight vectors in place. Applies the inverse of each column's normalizer to the column's values.

func (*Layer) Get

func (l *Layer) Get(x, y, col int) float64

Get returns the value at the specified column and coordinate in the Layer.

func (*Layer) GetAt

func (l *Layer) GetAt(idx, col int) float64

GetAt returns the value at the specified column and node index in the Layer.

func (*Layer) GetNode

func (l *Layer) GetNode(x, y int) []float64

GetNode returns a slice of float64 values representing the data for the node at the specified (x, y) coordinates in the Layer. The slice contains the values for each column in the Layer, in the same order as the columns slice.

func (*Layer) GetNodeAt

func (l *Layer) GetNodeAt(idx int) []float64

GetNodeAt returns a slice of float64 values representing the data for the node at the index in the Layer. The slice contains the values for each column in the Layer, in the same order as the columns slice.

func (*Layer) IsCategorical

func (l *Layer) IsCategorical() bool

IsCategorical returns whether the Layer contains categorical data.

func (*Layer) Metric

func (l *Layer) Metric() distance.Distance

Metric returns the distance metric used by the Layer.

func (*Layer) Name

func (l *Layer) Name() string

Name returns the name of the Layer.

func (*Layer) Nodes

func (l *Layer) Nodes() int

Nodes returns the total number of nodes in the Layer.

func (*Layer) Normalizers

func (l *Layer) Normalizers() []norm.Normalizer

Normalizers returns the list of normalizers used by the Layer.

func (*Layer) Set

func (l *Layer) Set(x, y, col int, value float64)

Set sets the value at the specified column and coordinate in the Layer.

func (*Layer) SetAt

func (l *Layer) SetAt(idx, col int, value float64)

SetAt sets the value at the specified column and node index in the Layer.

func (*Layer) Weight

func (l *Layer) Weight() float64

Weight returns the weight value of the Layer. The weight value is used in distance calculations for multi-layer SOMs.

func (*Layer) Weights

func (l *Layer) Weights() []float64

Weights returns the weight values for the layer.

type Size

type Size struct {
	Width  int
	Height int
}

Size represents the width and height of a 2D layer or grid.

func (*Size) Coords

func (s *Size) Coords(idx int) (int, int)

Coords returns the (x, y) coordinates of the node at the given index.

func (*Size) Index

func (s *Size) Index(x, y int) int

func (*Size) Nodes

func (s *Size) Nodes() int

Jump to

Keyboard shortcuts

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