Documentation
¶
Index ¶
- func AddToCol(D *mat.Dense, s []float64, col int)
- func ArgSort(a []float64) ([]int, []float64)
- func CrossValidationSamples(data *DataBunch, nfold int, usecopies ...bool) (int, func() (*DataBunch, *DataBunch), error)
- func DenseCol(D *mat.Dense, col int) *mat.Dense
- func DoNothingDense(O, D *mat.Dense) *mat.Dense
- func JSONTree(t JTree, ids ...*idGiver) ([][]byte, uint, error)
- func MemArgSort(target []float64, tmpint []int, tmpval []float64) ([]int, []float64)
- func Normalization(p, probs []float64) []float64
- func NormalizationDense(O, D *mat.Dense) *mat.Dense
- func OWArgSort(a []float64, in []int) ([]int, []float64)
- func PrintDenseMatrix(m *mat.Dense) string
- func SampleColAndTranspose(m [][]float64, target []float64, targetindexes, rowIndexes []int, colIndex int) ([]float64, []int)
- func SampleMatrix(m [][]float64, rowIndexes, colIndexes []int) [][]float64
- func SampleSlice(s []float64, indexes []int) []float64
- func SoftMax(p, probs []float64) []float64
- func SoftMaxDense(O, D *mat.Dense) *mat.Dense
- func ToOnes(m *mat.Dense)
- func TransposeFloats(m [][]float64) [][]float64
- type DataBunch
- func DataBunchFromCSVFile(filename string, hasHeader, hasLabels bool, separator ...rune) (*DataBunch, error)
- func DataBunchFromLibSVMFile(filename string, hasHeader ...bool) (*DataBunch, error)
- func ParseCSVFromReader(r io.Reader, hasHeader, hasLabels bool, sep rune) (*DataBunch, error)
- func ParseLibSVMFromReader(r io.Reader, hasHeader bool, zerobased ...bool) (*DataBunch, error)
- type Encodeable
- type JSONNode
- type JTree
- type LossFunc
- type MSELoss
- func (m *MSELoss) Gradients(yohelabels, probabilities, results *mat.Dense) *mat.Dense
- func (m *MSELoss) Hessian(probabilities, hessian *mat.Dense) *mat.Dense
- func (mse *MSELoss) Loss(y, pred, loss *mat.Dense) float64
- func (m *MSELoss) Name() string
- func (m *MSELoss) NegGradients(yohelabels, probabilities, results *mat.Dense) *mat.Dense
- type SQErrLoss
- func (m *SQErrLoss) Gradients(yohelabels, pred, results *mat.Dense) *mat.Dense
- func (m *SQErrLoss) Hessian(probabilities, hessian *mat.Dense) *mat.Dense
- func (sq *SQErrLoss) Loss(y, pred, loss *mat.Dense) float64
- func (sq *SQErrLoss) Name() string
- func (m *SQErrLoss) NegGradients(yohelabels, pred, results *mat.Dense) *mat.Dense
- type Slice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddToCol ¶
adds the i-th number in s to the ith row to the col column of D. s must have as many elements as D has rows.
func ArgSort ¶
Returns the indexes that would sort the given slice and also the sorted slice. It doesn't touch the original slice!
func CrossValidationSamples ¶
func CrossValidationSamples(data *DataBunch, nfold int, usecopies ...bool) (int, func() (*DataBunch, *DataBunch), error)
Returns an int "n", and a function that the first n times is called, will return a "folded" training set and test set. After the function has been called n times, it will return nil, nil. If the fold requested is too large for the dataset, an error will be returned and a smaller fold will be used. If not nfold is requested, 5-fold will be used.
func DoNothingDense ¶
DoNothingDense is an 'activation function' that does nothing, but simply returns the O matrix. The D matrix is only required to comply with the activation function signature
func JSONTree ¶
takes a JSON-able tree and returns it as a slice of json-serialized []byte, where each element in the slice is a node.
func MemArgSort ¶
Returns the indexes that would sort the given slice and also the sorted slice. It doesn't touch the original slice!
func Normalization ¶
puts in probs the normalization output for the inputs in p. allocates a new slice if probs is nil.
func NormalizationDense ¶
puts in D the normalization output for the inputs in O. allocates a new matrix if D is nil.
func OWArgSort ¶
Returns the indexes that would sort the given slice and also the sorted slice, which is the same given (i.e. it gets overwritten)
func PrintDenseMatrix ¶
Produces a printable version of m
func SampleColAndTranspose ¶
func SampleColAndTranspose(m [][]float64, target []float64, targetindexes, rowIndexes []int, colIndex int) ([]float64, []int)
takes a sub-matrix of m, consisting in its rows with indexes present in rowIndexes and the columns present in colIndexes, inthe order in which they appear in the 2 int slices.
func SampleMatrix ¶
takes a sub-matrix of m, consisting in its rows with indexes present in rowIndexes and the columns present in colIndexes, inthe order in which they appear in the 2 int slices.
func SampleSlice ¶
Produces a slice that contains each ith element (zero-based) in the slice s, where i is an element in indexes in the order in which they appear in indexes.
func SoftMax ¶
puts in probs the softmax output for the inputs in p. allocates a new matrix if probs is nil.
func SoftMaxDense ¶
puts in D the softmax output for the inputs in O. allocates a new matrix if D is nil.
func TransposeFloats ¶
Transposes the matrix represented by the [][]m slice of slices.
Types ¶
type DataBunch ¶
type DataBunch struct {
Data [][]float64
Keys []string
Labels []int
FloatLabels []float64 //for now we keep both
}
A simple structure for data Keys are the feature names, Lables are the classification of each Data vector, if available
func DataBunchFromCSVFile ¶
func DataBunchFromCSVFile(filename string, hasHeader, hasLabels bool, separator ...rune) (*DataBunch, error)
reads a libSVM-formatted file and returns a DataBunch. It's a pretty poor reader right now as it doesn't support sparse-libSVM files.
func DataBunchFromLibSVMFile ¶
reads a libSVM-formatted file and returns a DataBunch. It's a pretty poor reader right now as it doesn't support sparse-libSVM files. The file has to have missing data points explitly (say, set to 0) and it needs to have labels.
func ParseCSVFromReader ¶
func ParseLibSVMFromReader ¶
Parses a reader containing a libSVM-formatted file into a DataBunch. The file may or may not have a header with the feature names. The indexes in the file are assumed to be 1-based unless at least zero based its given and true (the rest are ignored).
func (*DataBunch) CSV ¶
returns the data in CSV format, using whatever string is given as a separator (comma if no string is given)
func (*DataBunch) LabelsRegression ¶
Returns a one-hot-encoded representation of the labels of the data bunch.
func (*DataBunch) LibSVM ¶
returns the data in libSVM format not very good as it doesn't omit the zero-valued data, but I'll get there.
type Encodeable ¶
type JSONNode ¶
type JSONNode struct {
Id uint
Nsamples int
Samples []int
SplitFeatureIndex int
BestScoreSoFar float64
Leaf bool
Threshold float64
Leftid uint
Rightid uint
Branches int
Value float64
XGB bool
}
Structure for serializing a tree node.
type JTree ¶
type JTree interface {
JNode(uint, ...bool) *JSONNode
//sets the left or right node to the given JTree and return it
//if given nil, just returns the current value for the node
Leftf(JTree) JTree
Rightf(JTree) JTree
Leaf() bool
}
A tree that can "pack" itself as a JSONNode
type LossFunc ¶
type LossFunc interface {
Loss(*mat.Dense, *mat.Dense, *mat.Dense) float64
Name() string
NegGradients(*mat.Dense, *mat.Dense, *mat.Dense) *mat.Dense
Gradients(*mat.Dense, *mat.Dense, *mat.Dense) *mat.Dense
Hessian(*mat.Dense, *mat.Dense) *mat.Dense
}
Interface for loss functions used in the package.
type MSELoss ¶
type MSELoss struct {
}
the error used in regular gradient boosting
func (*MSELoss) Gradients ¶
Returns the results matrix filled with the gradients. if a nil results is given, it will allocate a new matrix and return it.
type SQErrLoss ¶
type SQErrLoss struct {
}
Square error
func (*SQErrLoss) Gradients ¶
Returns the results matrix filled with the gradients. if a nil results is given, it will allocate a new matrix and return it.