xgbin

package
v0.0.0-...-03247f1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFloat32Slice

func ReadFloat32Slice(reader *bufio.Reader) ([]float32, error)

ReadFloat32Slice - read vector of floats from binary stream from dmlc-core/include/dmlc/serializer.h

func ReadInt32Slice

func ReadInt32Slice(reader *bufio.Reader) ([]int32, error)

ReadInt32Slice - read vector of int from binary stream from dmlc-core/include/dmlc/serializer.h

func ReadString

func ReadString(reader *bufio.Reader) (string, error)

ReadString - read ascii string from binary stream from dmlc-core/include/dmlc/serializer.h

func ReadStruct

func ReadStruct(reader *bufio.Reader, dst interface{}) error

ReadStruct - read arbitrary data structure from binary stream

Types

type GBLinearModel

type GBLinearModel struct {
	Param   GBLinearModelParam
	Weights []float32
}

GBLinearModel contains all data about gblinear model read from binary file. Used just as a container of input data for go implementation. Objects layout could be arbitrary

func ReadGBLinearModel

func ReadGBLinearModel(reader *bufio.Reader) (*GBLinearModel, error)

ReadGBLinearModel reads gblinear model from binary model file

type GBLinearModelParam

type GBLinearModelParam struct {
	// number of feature dimension
	NumFeature uint32
	// number of output group
	NumOutputGroup int32
	// reserved field
	Reserved [32]int32
}

GBLinearModelParam - model parameters from src/gbm/gblinear_model.h

type GBTreeModel

type GBTreeModel struct {
	Param GBTreeModelParam
	Trees []*TreeModel
	// some information indicator of the tree, reserved
	TreeInfo []int32
}

GBTreeModel contains all input data related to gbtree model. Used just as a container of input data for go implementation. Objects layout could be arbitrary

func ReadGBTreeModel

func ReadGBTreeModel(reader *bufio.Reader) (*GBTreeModel, error)

ReadGBTreeModel reads gbtree model from binary model file

type GBTreeModelParam

type GBTreeModelParam struct {
	// number of trees
	NumTrees int32
	// number of roots
	NumRoots int32
	// number of features to be used by trees
	NumFeature int32
	// pad this space, for backward compatibility reason
	Pad32bit int32
	// deprecated padding space.
	NumPbufferDeprecated int64
	// how many output group a single instance can produce
	// this affects the behavior of number of output we have:
	// suppose we have n instance and k group, output will be k * n
	NumOutputGroup int32
	// size of leaf vector needed in tree
	SizeLeafVector int32
	// reserved parameters
	Reserved [32]int32
}

GBTreeModelParam - model parameters from src/gbm/gbtree_model.h

type LearnerModelParam

type LearnerModelParam struct {
	// global bias
	BaseScore float32
	// number of features
	NumFeatures uint32
	// number of classes, if it is multi-class classification
	NumClass int32
	// Model contain additional properties
	ContainExtraAttrs int32
	// Model contain eval metrics
	ContainEvalMetrics int32
	// reserved field
	Reserved [29]int32
}

LearnerModelParam - training parameter for regression. from src/learner.cc

type ModelHeader

type ModelHeader struct {
	Param   LearnerModelParam
	NameObj string
	NameGbm string
}

ModelHeader contains all input data related to top records of model binary file. Used just as a container of input data for go implementation. Objects layout could be arbitrary

func ReadModelHeader

func ReadModelHeader(reader *bufio.Reader) (*ModelHeader, error)

ReadModelHeader reads header info from binary model file

type Node

type Node struct {
	// pointer to parent, highest bit is used to
	// indicate whether it's a left child or not
	Parent int32
	// pointer to left, right
	// NOTE: CLeft == -1 means leaf node
	CLeft  int32
	CRight int32
	// split feature index, left split or right split depends on the highest bit
	SIndex uint32
	// extra info
	// union Info{
	//   bst_float leaf_value;
	//   TSplitCond split_cond;
	// };
	Info float32
}

Node - tree Node for XGBoost's RegTree class from include/xgboost/tree_model.h

type RTreeNodeStat

type RTreeNodeStat struct {
	// loss change caused by current split
	LossChg float32
	// sum of hessian values, used to measure coverage of data
	SumHess float32
	// weight of current node
	BaseWeight float32
	// number of child that is leaf node known up to now
	LeafChildCnt int32
}

RTreeNodeStat - node statistics used in regression tree from include/xgboost/tree_model.h

type TreeModel

type TreeModel struct {
	Nodes []Node
	Stats []RTreeNodeStat
	// // leaf vector, that is used to store additional information
	// LeafVector []float32
	Param TreeParam
}

TreeModel contains all input data related to particular tree. Used just as a container of input data for go implementation. Objects layout could be arbitrary

func ReadTreeModel

func ReadTreeModel(reader *bufio.Reader) (*TreeModel, error)

ReadTreeModel reads particular tree data from binary model file

type TreeParam

type TreeParam struct {
	// number of start root
	NumRoots int32
	// total number of nodes
	NumNodes int32
	// number of deleted nodes
	NumDeleted int32
	// maximum depth, this is a statistics of the tree
	MaxDepth int32
	// number of features used for tree construction
	NumFeature int32
	// leaf vector size, used for vector tree
	// used to store more than one dimensional information in tree
	SizeLeafVector int32
	// reserved part, make sure alignment works for 64bit
	Reserved [31]int32
}

TreeParam - meta parameters of the tree from include/xgboost/tree_model.h

Jump to

Keyboard shortcuts

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