mat

package
v0.0.0-...-25d19a7 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mat provides matrix structures and loaders for `leaves` tests. `leaves` API doesn't depend on `mat.*`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSRMat

type CSRMat struct {
	RowHeaders []int
	ColIndexes []int
	Values     []float64
}

CSRMat is Compressed Sparse Row matrix data structure

func CSRMatFromArray

func CSRMatFromArray(values []float64, rows int, cols int) (CSRMat, error)

CSRMatFromArray converts arrays of `values` to CSRMat using shape information `rows` and `cols`. See also DenseMatFromArray to store dense data in matrix

func CSRMatFromLibsvm

func CSRMatFromLibsvm(reader *bufio.Reader, limit int, skipFirstColumn bool) (*CSRMat, error)

CSRMatFromLibsvm reads CSR (Compressed Sparse Row) matrix from libsvm format from `reader` stream. If `limit` > 0, reads only first limit `rows`. First colums is label, and usually you should set `skipFirstColumn` = true

func CSRMatFromLibsvmFile

func CSRMatFromLibsvmFile(filename string, limit int, skipFirstColumn bool) (*CSRMat, error)

CSRMatFromLibsvmFile reads CSR (Compressed Sparse Row) matrix from libsvm file `filename`. If `limit` > 0, reads only first limit `rows`. First colums is label, and usually you should set `skipFirstColumn` = true

func (*CSRMat) Rows

func (m *CSRMat) Rows() int

Rows returns number of rows in the matrix

type DenseMat

type DenseMat struct {
	Values []float64
	Cols   int
	Rows   int
}

DenseMat is dense matrix data structure

func DenseMatFromArray

func DenseMatFromArray(values []float64, rows int, cols int) (DenseMat, error)

DenseMatFromArray converts arrays of `values` to DenseMat using shape information `rows` and `cols`

func DenseMatFromCsv

func DenseMatFromCsv(reader *bufio.Reader,
	limit int,
	skipFirstColumn bool,
	delimiter string,
	defValue float64,
) (*DenseMat, error)

DenseMatFromCsv reads dense matrix from csv format with `delimiter` from `reader` stream. If `limit` > 0, reads only first limit `rows`. First colums is label, and usually you should set `skipFirstColumn` = true. If value is absent `defValue` will be used instead

func DenseMatFromCsvFile

func DenseMatFromCsvFile(filename string,
	limit int,
	skipFirstColumn bool,
	delimiter string,
	defValue float64,
) (*DenseMat, error)

DenseMatFromCsvFile reads dense matrix from csv file `filename` with `delimiter`. If `limit` > 0, reads only first limit `rows`. First colums is label, and usually you should set `skipFirstColumn` = true. If value is absent `defValue` will be used instead

func DenseMatFromLibsvm

func DenseMatFromLibsvm(reader *bufio.Reader, limit int, skipFirstColumn bool) (*DenseMat, error)

DenseMatFromLibsvm reads dense matrix from libsvm format from `reader` stream. If `limit` > 0, reads only first limit `rows`. First colums is label, and usually you should set `skipFirstColumn` = true

func DenseMatFromLibsvmFile

func DenseMatFromLibsvmFile(filename string, limit int, skipFirstColumn bool) (*DenseMat, error)

DenseMatFromLibsvmFile reads dense matrix from libsvm file `filename`. If `limit` > 0, reads only first limit `rows`. First colums is label, and usually you should set `skipFirstColumn` = true

func DenseMatZero

func DenseMatZero(rows int, cols int) DenseMat

DenseMatZero return DenseMat with shape `rows` by `cols` with all zero elements

func (*DenseMat) ToCsvFile

func (m *DenseMat) ToCsvFile(filename string, delimiter string) error

ToCsvFile writes matrix to CSV like file

func (*DenseMat) WriteStr

func (m *DenseMat) WriteStr(writer io.Writer, delimiter string) error

WriteStr writes matrix to CSV like format with field delimiter `delimiter`

Jump to

Keyboard shortcuts

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