matrix

package
v0.0.0-...-584ee08 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CosineLabeledMatrix

type CosineLabeledMatrix struct {
	*mat.Dense
	Label LabelMap
}

CosineLabeledMatrix is a CosineMatrix including a label -> row/col index mapping

func NewCosineLabeledMatrix

func NewCosineLabeledMatrix(matrix *LabeledMatrix) *CosineLabeledMatrix

NewCosineLabeledMatrix creates a new indexed cosine similarity matrix of size col x col

func (*CosineLabeledMatrix) Width

func (matrix *CosineLabeledMatrix) Width() int

Width returns the width of the matrix (matrix is size width x width)

type CosineMatrix

type CosineMatrix struct {
	*mat.Dense
}

CosineMatrix is an item x item matrix where the cells contain the cosine similarity between the two items

func NewCosineMatrix

func NewCosineMatrix(matrix *mat.Dense) *CosineMatrix

NewCosineMatrix creates a new cosine similarity matrix of size col x col

type LabelMap

type LabelMap []string

LabelMap is a slice of strings

func (*LabelMap) Filter

func (im *LabelMap) Filter(indexes []int) LabelMap

Filter creates a new LabelMap only returning items at indexes

func (*LabelMap) FilterVector

func (im *LabelMap) FilterVector(vector mat.Vector) LabelMap

FilterVector creates a new LabelMap only returning items at vector

func (*LabelMap) IndexOf

func (im *LabelMap) IndexOf(search string) int

IndexOf searches for label in the LabelMap

type LabeledMatrix

type LabeledMatrix struct {
	*mat.Dense
	ColumnLabel LabelMap
	RowLabel    LabelMap
}

LabeledMatrix is a dense matrix where columns and rows are indexed using label -> index mapping

func LabelMatrixFromCSV

func LabelMatrixFromCSV(r io.Reader) *LabeledMatrix

LabelMatrixFromCSV creates a new LabeledMatrix from a CSV file The file needs to contain both a header and a first column containing unique labels

func NewLabeledMatrix

func NewLabeledMatrix(data []float64, columnLabel LabelMap, rowLabel LabelMap) *LabeledMatrix

NewLabeledMatrix creates a new Dense labeled matrix

type LabeledVector

type LabeledVector []*vectorItem

LabeledVector is a vector that keeps a reference from each value to it's original index. Common usecase is to sort the vector and get get all top indexes

func NewLabelVector

func NewLabelVector() LabeledVector

NewLabelVector creates an empty indexed vector.

func (*LabeledVector) Append

func (v *LabeledVector) Append(index int, value float64)

Append adds a single entry in the vector with index, value

func (*LabeledVector) AppendVector

func (v *LabeledVector) AppendVector(vector mat.Vector)

AppendVector appends all non zero items to this vector

func (LabeledVector) HeadLabeles

func (v LabeledVector) HeadLabeles(length int) []int

HeadLabeles return length indexes, 0 returns all

func (LabeledVector) HeadValues

func (v LabeledVector) HeadValues(length int) []float64

HeadValues return length values, 0 returns all

func (LabeledVector) Len

func (v LabeledVector) Len() int

func (LabeledVector) Less

func (v LabeledVector) Less(i, j int) bool

func (LabeledVector) Swap

func (v LabeledVector) Swap(i, j int)

func (LabeledVector) Visit

func (v LabeledVector) Visit(do func(index int, value float64))

Visit each entry in the vector with a callback

Jump to

Keyboard shortcuts

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