Documentation
¶
Index ¶
- func ReadBinf(reader *bufio.Reader)
- func ReadFloat32Slice(reader *bufio.Reader) ([]float32, error)
- func ReadInt32Slice(reader *bufio.Reader) ([]int32, error)
- func ReadString(reader *bufio.Reader) (string, error)
- func ReadStruct(reader *bufio.Reader, dst interface{}) error
- type GBLinearModel
- type GBLinearModelParam
- type GBTreeModel
- type GBTreeModelParam
- type LearnerModelParamLegacy
- type ModelHeader
- type Node
- type RTreeNodeStat
- type TreeModel
- type TreeParam
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadFloat32Slice ¶
ReadFloat32Slice - read vector of floats from binary stream from dmlc-core/include/dmlc/serializer.h
func ReadInt32Slice ¶
ReadInt32Slice - read vector of int from binary stream from dmlc-core/include/dmlc/serializer.h
func ReadString ¶
ReadString - read ascii string from binary stream from dmlc-core/include/dmlc/serializer.h
func ReadStruct ¶
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 `json:"num_trees,string"`
// number of roots
DeprecatedNumRoots int32
// number of features to be used by trees
DeprecatedNumFeature int32
// pad this space, for backward compatibility reason
Pad32bit int32
// deprecated padding space.
DeprecatedNumPbufferDeprecated 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
DeprecatedNumOutputGroup int32
// size of leaf vector needed in tree
SizeLeafVector int32 `json:"size_leaf_vector,string"`
// reserved parameters
Reserved [32]int32
}
GBTreeModelParam - model parameters from src/gbm/gbtree_model.h
type LearnerModelParamLegacy ¶
type LearnerModelParamLegacy struct {
// global bias
BaseScore float32 `json:"base_score,string"`
// number of features
NumFeatures uint32 `json:"num_feature,string"`
// number of classes, if it is multi-class classification
NumClass int32 `json:"num_class,string"`
// Model contain additional properties
ContainExtraAttrs int32
// Model contain eval metrics
ContainEvalMetrics int32
MajorVersion uint32
MinorVersion uint32
// reserved field
Reserved [27]int32
}
LearnerModelParamLegacy - training parameter for regression. from src/learner.cc
type ModelHeader ¶
type ModelHeader struct {
Param LearnerModelParamLegacy
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 `json:"tree_param"`
}
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
type TreeParam ¶
type TreeParam struct {
// number of start root
NumRoots int32
// total number of nodes
NumNodes int32 `json:"num_nodes,string"`
// 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 `json:"num_feature,string"`
// leaf vector size, used for vector tree
// used to store more than one dimensional information in tree
SizeLeafVector int32 `json:"size_leaf_vector,string"`
// reserved part, make sure alignment works for 64bit
Reserved [31]int32
}
TreeParam - meta parameters of the tree from include/xgboost/tree_model.h