ml.dmlc.xgboost4j.java.XGBoost类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(233)

本文整理了Java中ml.dmlc.xgboost4j.java.XGBoost类的一些代码示例,展示了XGBoost类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XGBoost类的具体详情如下:
包路径:ml.dmlc.xgboost4j.java.XGBoost
类名称:XGBoost

XGBoost介绍

[英]trainer for xgboost
[中]xgboost培训师

代码示例

代码示例来源:origin: io.github.myui/xgboost4j

/**
 * Train a booster given parameters.
 *
 * @param dtrain  Data to be trained.
 * @param params  Parameters.
 * @param round   Number of boosting iterations.
 * @param watches a group of items to be evaluated during training, this allows user to watch
 *                performance on the validation set.
 * @param obj     customized objective
 * @param eval    customized evaluation
 * @return The trained booster.
 */
public static Booster train(
    DMatrix dtrain,
    Map<String, Object> params,
    int round,
    Map<String, DMatrix> watches,
    IObjective obj,
    IEvaluation eval) throws XGBoostError {
 return train(dtrain, params, round, watches, null, obj, eval, 0);
}

代码示例来源:origin: org.apache.hivemall/hivemall-xgboost

@Nonnull
private static Booster initXgBooster(@Nonnull final byte[] input) throws HiveException {
  try {
    return XGBoost.loadModel(new ByteArrayInputStream(input));
  } catch (Exception e) {
    throw new HiveException(e);
  }
}

代码示例来源:origin: ml.dmlc/xgboost4j-example

public static void main(String[] args) throws IOException, XGBoostError {
  //load train mat
  DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");

  //set params
  HashMap<String, Object> params = new HashMap<String, Object>();

  params.put("eta", 1.0);
  params.put("max_depth", 3);
  params.put("silent", 1);
  params.put("nthread", 6);
  params.put("objective", "binary:logistic");
  params.put("gamma", 1.0);
  params.put("eval_metric", "error");

  //do 5-fold cross validation
  int round = 2;
  int nfold = 5;
  //set additional eval_metrics
  String[] metrics = null;

  String[] evalHist = XGBoost.crossValidation(trainMat, params, round, nfold, metrics, null,
      null);
 }
}

代码示例来源:origin: ml.dmlc/xgboost4j

IObjective obj,
 IEvaluation eval) throws XGBoostError {
CVPack[] cvPacks = makeNFold(data, nfold, params, metrics);
String[] evalHist = new String[round];
String[] results = new String[cvPacks.length];
 evalHist[i] = aggCVResults(results);
 logger.info(evalHist[i]);

代码示例来源:origin: ml.dmlc/xgboost4j-example

Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);
Booster booster2 = XGBoost.loadModel("./model/xgb.model");
DMatrix testMat2 = new DMatrix("./model/dtest.buffer");
float[][] predicts2 = booster2.predict(testMat2);
watches2.put("train", trainMat2);
watches2.put("test", testMat2);
Booster booster3 = XGBoost.train(trainMat2, params, round, watches2, null, null);
float[][] predicts3 = booster3.predict(testMat2);

代码示例来源:origin: ml.dmlc/xgboost4j

IEvaluation eval,
   int earlyStoppingRound) throws XGBoostError {
return train(dtrain, params, round, watches, metrics, obj, eval, earlyStoppingRound, null);
   boolean onTrack = judgeIfTrainingOnTrack(params, earlyStoppingRounds, metrics, iter);
   if (!onTrack) {
    String reversedDirection = getReversedDirection(params);
    Rabit.trackerPrint(String.format(
        "early stopping after %d %s rounds", earlyStoppingRounds, reversedDirection));

代码示例来源:origin: ai.h2o/xgboost4j

List<Integer> samples = genRandPermutationNums(0, (int) data.rowNum());
int step = samples.size() / nfold;
int[] testSlice = new int[step];

代码示例来源:origin: ai.h2o/xgboost4j

IObjective obj,
 IEvaluation eval) throws XGBoostError {
CVPack[] cvPacks = makeNFold(data, nfold, params, metrics);
String[] evalHist = new String[round];
String[] results = new String[cvPacks.length];
 evalHist[i] = aggCVResults(results);
 logger.info(evalHist[i]);

代码示例来源:origin: io.github.myui/xgboost4j

List<Integer> samples = genRandPermutationNums(0, (int) data.rowNum());
int step = samples.size() / nfold;
int[] testSlice = new int[step];

代码示例来源:origin: ml.dmlc/xgboost4j

/**
 * Train a booster given parameters.
 *
 * @param dtrain  Data to be trained.
 * @param params  Parameters.
 * @param round   Number of boosting iterations.
 * @param watches a group of items to be evaluated during training, this allows user to watch
 *                performance on the validation set.
 * @param obj     customized objective
 * @param eval    customized evaluation
 * @return The trained booster.
 */
public static Booster train(
    DMatrix dtrain,
    Map<String, Object> params,
    int round,
    Map<String, DMatrix> watches,
    IObjective obj,
    IEvaluation eval) throws XGBoostError {
 return train(dtrain, params, round, watches, null, obj, eval, 0);
}

代码示例来源:origin: io.github.myui/xgboost4j

IObjective obj,
 IEvaluation eval) throws XGBoostError {
CVPack[] cvPacks = makeNFold(data, nfold, params, metrics);
String[] evalHist = new String[round];
String[] results = new String[cvPacks.length];
 evalHist[i] = aggCVResults(results);
 logger.info(evalHist[i]);

代码示例来源:origin: ml.dmlc/xgboost4j

List<Integer> samples = genRandPermutationNums(0, (int) data.rowNum());
int step = samples.size() / nfold;
int[] testSlice = new int[step];

代码示例来源:origin: spotify/zoltar

/**
 * Note: Please use Models from zoltar-models module.
 *
 * <p>Returns a XGBoost model given a URI to the serialized model file.
 */
public static XGBoostModel create(final Model.Id id, final URI modelUri) throws IOException {
 try {
  GompLoader.start();
  final InputStream is = Files.newInputStream(FileSystemExtras.path(modelUri));
  return new AutoValue_XGBoostModel(id, XGBoost.loadModel(is));
 } catch (final XGBoostError xgBoostError) {
  throw new IOException(xgBoostError);
 }
}

代码示例来源:origin: ml.dmlc/xgboost4j-example

Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);

代码示例来源:origin: ml.dmlc/xgboost4j-example

Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);

代码示例来源:origin: ml.dmlc/xgboost4j-example

public static void main(String[] args) throws XGBoostError {
  //load train mat (svmlight format)
  DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");
  //load valid mat (svmlight format)
  DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test");

  HashMap<String, Object> params = new HashMap<String, Object>();
  params.put("eta", 1.0);
  params.put("max_depth", 2);
  params.put("silent", 1);

  //set round
  int round = 2;

  //specify watchList
  HashMap<String, DMatrix> watches = new HashMap<String, DMatrix>();
  watches.put("train", trainMat);
  watches.put("test", testMat);

  //user define obj and eval
  IObjective obj = new LogRegObj();
  IEvaluation eval = new EvalError();

  //train a booster
  System.out.println("begin to train the booster model");
  Booster booster = XGBoost.train(trainMat, params, round, watches, obj, eval);
 }
}

代码示例来源:origin: ml.dmlc/xgboost4j-example

Booster booster = XGBoost.train(trainMat, params, 1, watches, null, null);
Booster booster2 = XGBoost.train(trainMat, params, 1, watches, null, null);

代码示例来源:origin: ml.dmlc/xgboost4j-example

Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);

代码示例来源:origin: ml.dmlc/xgboost4j-example

Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);

代码示例来源:origin: ai.h2o/h2o-ext-xgboost

Map<String, String> localRabitEnv = new HashMap<>();
Rabit.init(localRabitEnv);
ml.dmlc.xgboost4j.java.XGBoost.train(trainMat, params, 1, watches, null, null);
GPUS.add(gpu_id);
return true;

相关文章