Class XGBoostRegressionTrainer
java.lang.Object
org.tribuo.common.xgboost.XGBoostTrainer<Regressor>
org.tribuo.regression.xgboost.XGBoostRegressionTrainer
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<TrainerProvenance>
,Trainer<Regressor>
,WeightedExamples
A
Trainer
which wraps the XGBoost training procedure.
This only exposes a few of XGBoost's training parameters.
It uses pthreads outside of the JVM to parallelise the computation.
Each output dimension is trained independently (and so contains a separate XGBoost ensemble).
See:
Chen T, Guestrin C. "XGBoost: A Scalable Tree Boosting System" Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2016.and for the original algorithm:
Friedman JH. "Greedy Function Approximation: a Gradient Boosting Machine" Annals of statistics, 2001.
Note: XGBoost requires a native library, on macOS this library requires libomp (which can be installed via homebrew), on Windows this native library must be compiled into a jar as it's not contained in the official XGBoost binary on Maven Central.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Types of regression loss.Nested classes/interfaces inherited from class org.tribuo.common.xgboost.XGBoostTrainer
XGBoostTrainer.BoosterType, XGBoostTrainer.DMatrixTuple<T extends Output<T>>, XGBoostTrainer.XGBoostTrainerProvenance
-
Field Summary
Fields inherited from class org.tribuo.common.xgboost.XGBoostTrainer
numTrees, parameters, trainInvocationCounter
Fields inherited from interface org.tribuo.Trainer
DEFAULT_SEED
-
Constructor Summary
ConstructorsConstructorDescriptionXGBoostRegressionTrainer
(int numTrees) XGBoostRegressionTrainer
(XGBoostRegressionTrainer.RegressionType rType, int numTrees) XGBoostRegressionTrainer
(XGBoostRegressionTrainer.RegressionType rType, int numTrees, double eta, double gamma, int maxDepth, double minChildWeight, double subsample, double featureSubsample, double lambda, double alpha, int nThread, boolean silent, long seed) Create an XGBoost trainer.XGBoostRegressionTrainer
(XGBoostRegressionTrainer.RegressionType rType, int numTrees, int numThreads, boolean silent) XGBoostRegressionTrainer
(XGBoostRegressionTrainer.RegressionType rType, int numTrees, Map<String, Object> parameters) This gives direct access to the XGBoost parameter map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Used by the OLCUT configuration system, and should not be called by external code.train
(Dataset<Regressor> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance) Trains a predictive model using the examples in the given data set.Methods inherited from class org.tribuo.common.xgboost.XGBoostTrainer
convertDataset, convertDataset, convertExample, convertExample, convertExamples, convertExamples, convertSingleExample, convertSparseVector, convertSparseVectors, createModel, getInvocationCount, toString
-
Constructor Details
-
XGBoostRegressionTrainer
-
XGBoostRegressionTrainer
-
XGBoostRegressionTrainer
public XGBoostRegressionTrainer(XGBoostRegressionTrainer.RegressionType rType, int numTrees, int numThreads, boolean silent) -
XGBoostRegressionTrainer
public XGBoostRegressionTrainer(XGBoostRegressionTrainer.RegressionType rType, int numTrees, double eta, double gamma, int maxDepth, double minChildWeight, double subsample, double featureSubsample, double lambda, double alpha, int nThread, boolean silent, long seed) Create an XGBoost trainer.- Parameters:
rType
- The type of regression to build.numTrees
- Number of trees to boost.eta
- Step size shrinkage parameter (default 0.3, range [0,1]).gamma
- Minimum loss reduction to make a split (default 0, range [0,inf]).maxDepth
- Maximum tree depth (default 6, range [1,inf]).minChildWeight
- Minimum sum of instance weights needed in a leaf (default 1, range [0, inf]).subsample
- Subsample size for each tree (default 1, range (0,1]).featureSubsample
- Subsample features for each tree (default 1, range (0,1]).lambda
- L2 regularization term on weights (default 1).alpha
- L1 regularization term on weights (default 0).nThread
- Number of threads to use (default 4).silent
- Silence the training output text.seed
- RNG seed.
-
XGBoostRegressionTrainer
public XGBoostRegressionTrainer(XGBoostRegressionTrainer.RegressionType rType, int numTrees, Map<String, Object> parameters) This gives direct access to the XGBoost parameter map.It lets you pick things that we haven't exposed like dropout trees, binary classification etc.
This sidesteps the validation that Tribuo provides for the hyperparameters, and so can produce unexpected results.
- Parameters:
rType
- The type of the regression.numTrees
- Number of trees to boost.parameters
- A map from string to object, where object can be Number or String.
-
-
Method Details
-
postConfig
Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfig
in interfacecom.oracle.labs.mlrg.olcut.config.Configurable
- Overrides:
postConfig
in classXGBoostTrainer<Regressor>
-
train
public XGBoostModel<Regressor> train(Dataset<Regressor> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance) Description copied from interface:Trainer
Trains a predictive model using the examples in the given data set.- Parameters:
examples
- the data set containing the examples.runProvenance
- Training run specific provenance (e.g., fold number).- Returns:
- a predictive model that can be used to generate predictions for new examples.
-
getProvenance
-