public class Booster extends Object implements Serializable, com.esotericsoftware.kryo.KryoSerializable
Modifier and Type | Class and Description |
---|---|
static class |
Booster.FeatureImportanceType
Supported feature importance types
WEIGHT = Number of nodes that a feature was used to determine a split
GAIN = Average information gain per split for a feature
COVER = Average cover per split for a feature
TOTAL_GAIN = Total information gain over all splits of a feature
TOTAL_COVER = Total cover over all splits of a feature
|
Modifier and Type | Method and Description |
---|---|
void |
boost(DMatrix dtrain,
float[] grad,
float[] hess)
update with give grad and hess
|
void |
dispose() |
String |
evalSet(DMatrix[] evalMatrixs,
String[] evalNames,
IEvaluation eval)
evaluate with given customized Evaluation class
|
String |
evalSet(DMatrix[] evalMatrixs,
String[] evalNames,
IEvaluation eval,
float[] metricsOut) |
String |
evalSet(DMatrix[] evalMatrixs,
String[] evalNames,
int iter)
evaluate with given dmatrixs.
|
String |
evalSet(DMatrix[] evalMatrixs,
String[] evalNames,
int iter,
float[] metricsOut)
evaluate with given dmatrixs.
|
protected void |
finalize() |
Map<String,Integer> |
getFeatureScore(String featureMap)
Get importance of each feature
|
Map<String,Integer> |
getFeatureScore(String[] featureNames)
Get importance of each feature with specified feature names.
|
String[] |
getModelDump(String[] featureNames,
boolean withStats)
Get the dump of the model as a string array with specified feature names.
|
String[] |
getModelDump(String[] featureNames,
boolean withStats,
String format) |
String[] |
getModelDump(String featureMap,
boolean withStats)
Get the dump of the model as a string array
|
String[] |
getModelDump(String featureMap,
boolean withStats,
String format) |
Map<String,Double> |
getScore(String[] featureNames,
String importanceType)
Get the feature importances for gain or cover (average or total)
|
Map<String,Double> |
getScore(String featureMap,
String importanceType)
Get the feature importances for gain or cover (average or total), with feature names
|
int |
getVersion() |
float[][] |
predict(DMatrix data)
Predict with data
|
float[][] |
predict(DMatrix data,
boolean outputMargin)
Predict with data
|
float[][] |
predict(DMatrix data,
boolean outputMargin,
int treeLimit)
Advanced predict function with all the options.
|
float[][] |
predictContrib(DMatrix data,
int treeLimit)
Output feature contributions toward predictions of given data
|
float[][] |
predictLeaf(DMatrix data,
int treeLimit)
Predict leaf indices given the data
|
void |
read(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Input input) |
void |
saveModel(OutputStream out)
Save the model to file opened as output stream.
|
void |
saveModel(String modelPath)
Save model to modelPath
|
void |
setParam(String key,
Object value)
Set parameter to the Booster.
|
void |
setParams(Map<String,Object> params)
Set parameters to the Booster.
|
void |
setVersion(int version) |
byte[] |
toByteArray() |
void |
update(DMatrix dtrain,
int iter)
Update the booster for one iteration.
|
void |
update(DMatrix dtrain,
IObjective obj)
Update with customize obj func
|
void |
write(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Output output) |
public final void setParam(String key, Object value) throws XGBoostError
key
- param namevalue
- param valueXGBoostError
- native errorpublic void setParams(Map<String,Object> params) throws XGBoostError
params
- parameters key-value mapXGBoostError
- native errorpublic void update(DMatrix dtrain, int iter) throws XGBoostError
dtrain
- training dataiter
- current iteration numberXGBoostError
- native errorpublic void update(DMatrix dtrain, IObjective obj) throws XGBoostError
dtrain
- training dataobj
- customized objective classXGBoostError
- native errorpublic void boost(DMatrix dtrain, float[] grad, float[] hess) throws XGBoostError
dtrain
- training datagrad
- first order of gradienthess
- seconde order of gradientXGBoostError
- native errorpublic String evalSet(DMatrix[] evalMatrixs, String[] evalNames, int iter) throws XGBoostError
evalMatrixs
- dmatrixs for evaluationevalNames
- name for eval dmatrixs, used for check resultsiter
- current eval iterationXGBoostError
- native errorpublic String evalSet(DMatrix[] evalMatrixs, String[] evalNames, int iter, float[] metricsOut) throws XGBoostError
evalMatrixs
- dmatrixs for evaluationevalNames
- name for eval dmatrixs, used for check resultsiter
- current eval iterationmetricsOut
- output array containing the evaluation metrics for each evalMatrixXGBoostError
- native errorpublic String evalSet(DMatrix[] evalMatrixs, String[] evalNames, IEvaluation eval) throws XGBoostError
evalMatrixs
- evaluation matrixevalNames
- evaluation nameseval
- custom evaluatorXGBoostError
- native errorpublic String evalSet(DMatrix[] evalMatrixs, String[] evalNames, IEvaluation eval, float[] metricsOut) throws XGBoostError
XGBoostError
public float[][] predictLeaf(DMatrix data, int treeLimit) throws XGBoostError
data
- The input data.treeLimit
- Number of trees to include, 0 means all trees.XGBoostError
public float[][] predictContrib(DMatrix data, int treeLimit) throws XGBoostError
data
- The input data.treeLimit
- Number of trees to include, 0 means all trees.XGBoostError
public float[][] predict(DMatrix data) throws XGBoostError
data
- dmatrix storing the inputXGBoostError
- native errorpublic float[][] predict(DMatrix data, boolean outputMargin) throws XGBoostError
data
- dataoutputMargin
- output marginXGBoostError
public float[][] predict(DMatrix data, boolean outputMargin, int treeLimit) throws XGBoostError
data
- dataoutputMargin
- output margintreeLimit
- limit number of trees, 0 means all trees.XGBoostError
public void saveModel(String modelPath) throws XGBoostError
modelPath
- model pathXGBoostError
public void saveModel(OutputStream out) throws XGBoostError, IOException
out
- The output streamXGBoostError
IOException
public String[] getModelDump(String featureMap, boolean withStats) throws XGBoostError
withStats
- Controls whether the split statistics are output.XGBoostError
- native errorpublic String[] getModelDump(String featureMap, boolean withStats, String format) throws XGBoostError
XGBoostError
public String[] getModelDump(String[] featureNames, boolean withStats) throws XGBoostError
featureNames
- Names of the features.XGBoostError
public String[] getModelDump(String[] featureNames, boolean withStats, String format) throws XGBoostError
XGBoostError
public Map<String,Integer> getFeatureScore(String[] featureNames) throws XGBoostError
XGBoostError
- native errorpublic Map<String,Integer> getFeatureScore(String featureMap) throws XGBoostError
XGBoostError
- native errorpublic Map<String,Double> getScore(String[] featureNames, String importanceType) throws XGBoostError
XGBoostError
- native errorpublic Map<String,Double> getScore(String featureMap, String importanceType) throws XGBoostError
XGBoostError
- native errorpublic int getVersion()
public void setVersion(int version)
public byte[] toByteArray() throws XGBoostError
XGBoostError
- native errorprotected void finalize() throws Throwable
public void dispose()
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
write
in interface com.esotericsoftware.kryo.KryoSerializable
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
read
in interface com.esotericsoftware.kryo.KryoSerializable
Copyright © 2019. All rights reserved.