Package biz.k11i.xgboost.gbm
Class GBTree
- java.lang.Object
-
- biz.k11i.xgboost.gbm.GBBase
-
- biz.k11i.xgboost.gbm.GBTree
-
- All Implemented Interfaces:
GradBooster,java.io.Serializable
- Direct Known Subclasses:
Dart
public class GBTree extends GBBase
Gradient boosted tree implementation.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classGBTree.ModelParam-
Nested classes/interfaces inherited from interface biz.k11i.xgboost.gbm.GradBooster
GradBooster.Factory
-
-
Field Summary
Fields Modifier and Type Field Description (package private) RegTree[][]_groupTrees(package private) GBTree.ModelParammparamprivate RegTree[]trees-
Fields inherited from class biz.k11i.xgboost.gbm.GBBase
num_class, num_feature, num_output_group
-
-
Constructor Summary
Constructors Constructor Description GBTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RegTree[][]getGroupedTrees()voidloadModel(PredictorConfiguration config, ModelReader reader, boolean with_pbuffer)Loads model from stream.(package private) floatpred(FVec feat, int bst_group, int root_index, int ntree_limit, float base_score)private longpredBufferSize()float[]predict(FVec feat, int ntree_limit, float base_score)Generates predictions for given feature vector.int[]predictLeaf(FVec feat, int ntree_limit)Predicts the leaf index of each tree.java.lang.String[]predictLeafPath(FVec feat, int ntree_limit)Predicts the path to leaf of each tree.floatpredictSingle(FVec feat, int ntree_limit, float base_score)Generates a prediction for given feature vector.-
Methods inherited from class biz.k11i.xgboost.gbm.GBBase
setNumClass, setNumFeature
-
-
-
-
Field Detail
-
mparam
GBTree.ModelParam mparam
-
trees
private RegTree[] trees
-
_groupTrees
RegTree[][] _groupTrees
-
-
Method Detail
-
loadModel
public void loadModel(PredictorConfiguration config, ModelReader reader, boolean with_pbuffer) throws java.io.IOException
Description copied from interface:GradBoosterLoads model from stream.- Parameters:
config- predictor configurationreader- input streamwith_pbuffer- whether the incoming data contains pbuffer- Throws:
java.io.IOException- If an I/O error occurs
-
predict
public float[] predict(FVec feat, int ntree_limit, float base_score)
Description copied from interface:GradBoosterGenerates predictions for given feature vector.- Parameters:
feat- feature vectorntree_limit- limit the number of trees used in predictionbase_score- base score to initialize prediction- Returns:
- prediction result
-
predictSingle
public float predictSingle(FVec feat, int ntree_limit, float base_score)
Description copied from interface:GradBoosterGenerates a prediction for given feature vector.This method only works when the model outputs single value.
- Parameters:
feat- feature vectorntree_limit- limit the number of trees used in predictionbase_score- base score to initialize prediction- Returns:
- prediction result
-
pred
float pred(FVec feat, int bst_group, int root_index, int ntree_limit, float base_score)
-
predictLeaf
public int[] predictLeaf(FVec feat, int ntree_limit)
Description copied from interface:GradBoosterPredicts the leaf index of each tree. This is only valid in gbtree predictor.- Parameters:
feat- feature vectorntree_limit- limit the number of trees used in prediction- Returns:
- predicted leaf indexes
-
predictLeafPath
public java.lang.String[] predictLeafPath(FVec feat, int ntree_limit)
Description copied from interface:GradBoosterPredicts the path to leaf of each tree. This is only valid in gbtree predictor.- Parameters:
feat- feature vectorntree_limit- limit the number of trees used in prediction- Returns:
- predicted path to leaves
-
predBufferSize
private long predBufferSize()
-
getGroupedTrees
public RegTree[][] getGroupedTrees()
- Returns:
- A two-dim array, with trees grouped into classes.
-
-