gpt4 book ai didi

ml.dmlc.xgboost4j.java.XGBoost.train()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 04:25:05 26 4
gpt4 key购买 nike

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

XGBoost.train介绍

[英]Train a booster given parameters.
[中]在给定的参数下训练助推器。

代码示例

代码示例来源: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: 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: 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;

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

@Override
public Booster call() throws XGBoostError {
 if ((_booster == null) && _tid == 0) {
  HashMap<String, DMatrix> watches = new HashMap<>();
  // Create empty Booster
  _booster = ml.dmlc.xgboost4j.java.XGBoost.train(_trainMat,
      _boosterParms.get(),
      0,
      watches,
      null,
      null);
  // Force Booster initialization; we can call any method that does "lazy init"
  byte[] boosterBytes = _booster.toByteArray();
  Log.info("Initial (0 tree) Booster created, size=" + boosterBytes.length);
 } else {
  // Do one iteration
  assert _booster != null;
  _booster.update(_trainMat, _tid);
 }
 return _booster;
}

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

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 {
 //collect eval matrixs
 String[] evalNames;
 DMatrix[] evalMats;
 List<String> names = new ArrayList<String>();
 List<DMatrix> mats = new ArrayList<DMatrix>();
 for (Map.Entry<String, DMatrix> evalEntry : watches.entrySet()) {
  names.add(evalEntry.getKey());
  mats.add(evalEntry.getValue());
 }
 evalNames = names.toArray(new String[names.size()]);
 evalMats = mats.toArray(new DMatrix[mats.size()]);
 metrics = metrics == null ? new float[evalNames.length][round] : metrics;
 //collect all data matrixs
 DMatrix[] allMats;
 if (evalMats.length > 0) {
  allMats = new DMatrix[evalMats.length + 1];
  allMats[0] = dtrain;

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

Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);
watches2.put("train", trainMat2);
watches2.put("test", testMat2);
Booster booster3 = XGBoost.train(trainMat2, params, round, watches2, null, null);
float[][] predicts3 = booster3.predict(testMat2);

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

IEvaluation eval,
   int earlyStoppingRound) throws XGBoostError {
return train(dtrain, params, round, watches, metrics, obj, eval, earlyStoppingRound, null);

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

IEvaluation eval,
   int earlyStoppingRound) throws XGBoostError {
return train(dtrain, params, round, watches, metrics, obj, eval, earlyStoppingRound, null);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com