ml.dmlc.xgboost4j.java

## Class XGBoost

- java.lang.Object
- - ml.dmlc.xgboost4j.java.XGBoost

-     public class XGBoost
      extends Object

  trainer for xgboost
  Author:
    hzx

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XGBoost()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String[]` | `crossValidation(DMatrix data, Map<String,Object> params, int round, int nfold, String[] metrics, IObjective obj, IEvaluation eval)` Cross-validation with given parameters.
    `static Booster` | `loadModel(InputStream in)` Load a new Booster model from a file opened as input stream.
    `static Booster` | `loadModel(String modelPath)` load model from modelPath
    `static Booster` | `train(DMatrix dtrain, Map<String,Object> params, int round, Map<String,DMatrix> watches, float[][] metrics, IObjective obj, IEvaluation eval, int earlyStoppingRound)` Train a booster given parameters.
    `static Booster` | `train(DMatrix dtrain, Map<String,Object> params, int round, Map<String,DMatrix> watches, float[][] metrics, IObjective obj, IEvaluation eval, int earlyStoppingRound, Booster booster)` Train a booster given parameters.
    `static Booster` | `train(DMatrix dtrain, Map<String,Object> params, int round, Map<String,DMatrix> watches, IObjective obj, IEvaluation eval)` Train a booster given parameters.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### XGBoost

          public XGBoost()

  - ### Method Detail

    - #### loadModel

          public static Booster loadModel(String modelPath)
                                   throws XGBoostError

      load model from modelPath
      Parameters:
        `modelPath` - booster modelPath (model generated by booster.saveModel)
      Throws:
        `XGBoostError` - native error

    - #### loadModel

          public static Booster loadModel(InputStream in)
                                   throws XGBoostError,
                                          IOException

      Load a new Booster model from a file opened as input stream. The assumption is the input stream only contains one XGBoost Model. This can be used to load existing booster models saved by other xgboost bindings.
      Parameters:
        `in` - The input stream of the file, will be closed after this function call.
      Returns:
        The create boosted
      Throws:
        `XGBoostError`
        `IOException`

    - #### train

          public static Booster train(DMatrix dtrain,
                                      Map<String,Object> params,
                                      int round,
                                      Map<String,DMatrix> watches,
                                      IObjective obj,
                                      IEvaluation eval)
                               throws XGBoostError

      Train a booster given parameters.
      Parameters:
        `dtrain` - Data to be trained.
        `params` - Parameters.
        `round` - Number of boosting iterations.
        `watches` - a group of items to be evaluated during training, this allows user to watch performance on the validation set.
        `obj` - customized objective
        `eval` - customized evaluation
      Returns:
        The trained booster.
      Throws:
        `XGBoostError`

    - #### train

          public static Booster train(DMatrix dtrain,
                                      Map<String,Object> params,
                                      int round,
                                      Map<String,DMatrix> watches,
                                      float[][] metrics,
                                      IObjective obj,
                                      IEvaluation eval,
                                      int earlyStoppingRound)
                               throws XGBoostError

      Train a booster given parameters.
      Parameters:
        `dtrain` - Data to be trained.
        `params` - Parameters.
        `round` - Number of boosting iterations.
        `watches` - a group of items to be evaluated during training, this allows user to watch performance on the validation set.
        `metrics` - array containing the evaluation metrics for each matrix in watches for each iteration
        `earlyStoppingRound` - if non-zero, training would be stopped after a specified number of consecutive increases in any evaluation metric.
        `obj` - customized objective
        `eval` - customized evaluation
      Returns:
        The trained booster.
      Throws:
        `XGBoostError`

    - #### train

          public static Booster train(DMatrix dtrain,
                                      Map<String,Object> params,
                                      int round,
                                      Map<String,DMatrix> watches,
                                      float[][] metrics,
                                      IObjective obj,
                                      IEvaluation eval,
                                      int earlyStoppingRound,
                                      Booster booster)
                               throws XGBoostError

      Train a booster given parameters.
      Parameters:
        `dtrain` - Data to be trained.
        `params` - Parameters.
        `round` - Number of boosting iterations.
        `watches` - a group of items to be evaluated during training, this allows user to watch performance on the validation set.
        `metrics` - array containing the evaluation metrics for each matrix in watches for each iteration
        `earlyStoppingRound` - if non-zero, training would be stopped after a specified number of consecutive increases in any evaluation metric.
        `obj` - customized objective
        `eval` - customized evaluation
        `booster` - train from scratch if set to null; train from an existing booster if not null.
      Returns:
        The trained booster.
      Throws:
        `XGBoostError`

    - #### crossValidation

          public static String[] crossValidation(DMatrix data,
                                                 Map<String,Object> params,
                                                 int round,
                                                 int nfold,
                                                 String[] metrics,
                                                 IObjective obj,
                                                 IEvaluation eval)
                                          throws XGBoostError

      Cross-validation with given parameters.
      Parameters:
        `data` - Data to be trained.
        `params` - Booster params.
        `round` - Number of boosting iterations.
        `nfold` - Number of folds in CV.
        `metrics` - Evaluation metrics to be watched in CV.
        `obj` - customized objective (set to null if not used)
        `eval` - customized evaluation (set to null if not used)
      Returns:
        evaluation history
      Throws:
        `XGBoostError` - native error

Copyright © 2018. All rights reserved.