simat

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: BSD-3-Clause Imports: 4 Imported by: 1

README

simat

simat provides similarity / distance matrix functions that create a SimMat matrix from Tensor or Table data. Any metric function defined in metric package (or user-created) can be used.

The SimMat contains the Tensor of the similarity matrix values, and labels for the Rows and Columns.

The etview package provides a SimMatGrid widget that displays the SimMat with the labels.

Documentation

Overview

Package simat provides similarity / distance matrix functions that create a SimMat matrix from Tensor or Table data. Any metric function defined in metric package (or user-created) can be used.

The SimMat contains the Tensor of the similarity matrix values, and labels for the Rows and Columns.

The etview package provides a SimMatGrid widget that displays the SimMat with the labels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlankRepeat

func BlankRepeat(str []string) []string

BlankRepeat returns string slice with any sequentially repeated strings blanked out

func Tensor

func Tensor(smat tensor.Tensor, a tensor.Tensor, mfun metric.Func64) error

Tensor computes a similarity / distance matrix on tensor using given metric function. Outer-most dimension ("rows") is used as "indexical" dimension and all other dimensions within that are compared. Results go in smat which is ensured to have proper square 2D shape (rows * rows).

func TensorStd

func TensorStd(smat tensor.Tensor, a tensor.Tensor, met metric.StdMetrics) error

TensorStd computes a similarity / distance matrix on tensor using given Std metric function. Outer-most dimension ("rows") is used as "indexical" dimension and all other dimensions within that are compared. Results go in smat which is ensured to have proper square 2D shape (rows * rows). This Std version is usable e.g., in Python where the func cannot be passed.

func Tensors

func Tensors(smat tensor.Tensor, a, b tensor.Tensor, mfun metric.Func64) error

Tensors computes a similarity / distance matrix on two tensors using given metric function. Outer-most dimension ("rows") is used as "indexical" dimension and all other dimensions within that are compared. Resulting reduced 2D shape of two tensors must be the same (returns error if not). Rows of smat = a, cols = b

func TensorsStd

func TensorsStd(smat tensor.Tensor, a, b tensor.Tensor, met metric.StdMetrics) error

TensorsStd computes a similarity / distance matrix on two tensors using given Std metric function. Outer-most dimension ("rows") is used as "indexical" dimension and all other dimensions within that are compared. Resulting reduced 2D shape of two tensors must be the same (returns error if not). Rows of smat = a, cols = b This Std version is usable e.g., in Python where the func cannot be passed.

Types

type SimMat

type SimMat struct {

	// the similarity / distance matrix (typically an tensor.Float64)
	Mat tensor.Tensor

	// labels for the rows -- blank rows trigger generation of grouping lines
	Rows []string

	// labels for the columns -- blank columns trigger generation of grouping lines
	Columns []string
}

SimMat is a similarity / distance matrix with additional row and column labels for display purposes.

func (*SimMat) Init

func (smat *SimMat) Init()

Init initializes SimMat with default Matrix and nil rows, cols

func (*SimMat) TableCol

func (smat *SimMat) TableCol(ix *table.IndexView, column, labNm string, blankRepeat bool, mfun metric.Func64) error

TableCol generates a similarity / distance matrix from given column name in given IndexView of an table.Table, and given metric function. if labNm is not empty, uses given column name for labels, which if blankRepeat is true are filtered so that any sequentially repeated labels are blank.

func (*SimMat) TableColStd

func (smat *SimMat) TableColStd(ix *table.IndexView, column, labNm string, blankRepeat bool, met metric.StdMetrics) error

TableColStd generates a similarity / distance matrix from given column name in given IndexView of an table.Table, and given standard metric function. if labNm is not empty, uses given column name for labels, which if blankRepeat is true are filtered so that any sequentially repeated labels are blank. This Std version is usable e.g., in Python where the func cannot be passed.

Jump to

Keyboard shortcuts

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