adjust the API signature as well as the docs
This commit is contained in:
@@ -67,7 +67,7 @@ public class BasicWalkThrough {
|
||||
int round = 2;
|
||||
|
||||
//train a boost model
|
||||
Booster booster = XGBoost.train(params, trainMat, round, watches, null, null);
|
||||
Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);
|
||||
|
||||
//predict
|
||||
float[][] predicts = booster.predict(testMat);
|
||||
@@ -111,7 +111,7 @@ public class BasicWalkThrough {
|
||||
HashMap<String, DMatrix> watches2 = new HashMap<String, DMatrix>();
|
||||
watches2.put("train", trainMat2);
|
||||
watches2.put("test", testMat2);
|
||||
Booster booster3 = XGBoost.train(params, trainMat2, round, watches2, null, null);
|
||||
Booster booster3 = XGBoost.train(trainMat2, params, round, watches2, null, null);
|
||||
float[][] predicts3 = booster3.predict(testMat2);
|
||||
|
||||
//check predicts
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BoostFromPrediction {
|
||||
watches.put("test", testMat);
|
||||
|
||||
//train xgboost for 1 round
|
||||
Booster booster = XGBoost.train(params, trainMat, 1, watches, null, null);
|
||||
Booster booster = XGBoost.train(trainMat, params, 1, watches, null, null);
|
||||
|
||||
float[][] trainPred = booster.predict(trainMat, true);
|
||||
float[][] testPred = booster.predict(testMat, true);
|
||||
@@ -57,6 +57,6 @@ public class BoostFromPrediction {
|
||||
testMat.setBaseMargin(testPred);
|
||||
|
||||
System.out.println("result of running from initial prediction");
|
||||
Booster booster2 = XGBoost.train(params, trainMat, 1, watches, null, null);
|
||||
Booster booster2 = XGBoost.train(trainMat, params, 1, watches, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CrossValidation {
|
||||
//set additional eval_metrics
|
||||
String[] metrics = null;
|
||||
|
||||
String[] evalHist = XGBoost.crossValidation(params, trainMat, round, nfold, metrics, null,
|
||||
String[] evalHist = XGBoost.crossValidation(trainMat, params, round, nfold, metrics, null,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,6 @@ public class CustomObjective {
|
||||
|
||||
//train a booster
|
||||
System.out.println("begin to train the booster model");
|
||||
Booster booster = XGBoost.train(params, trainMat, round, watches, obj, eval);
|
||||
Booster booster = XGBoost.train(trainMat, params, round, watches, obj, eval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@ public class ExternalMemory {
|
||||
int round = 2;
|
||||
|
||||
//train a boost model
|
||||
Booster booster = XGBoost.train(params, trainMat, round, watches, null, null);
|
||||
Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class GeneralizedLinearModel {
|
||||
|
||||
//train a booster
|
||||
int round = 4;
|
||||
Booster booster = XGBoost.train(params, trainMat, round, watches, null, null);
|
||||
Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);
|
||||
|
||||
float[][] predicts = booster.predict(testMat);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PredictFirstNtree {
|
||||
|
||||
//train a booster
|
||||
int round = 3;
|
||||
Booster booster = XGBoost.train(params, trainMat, round, watches, null, null);
|
||||
Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);
|
||||
|
||||
//predict use 1 tree
|
||||
float[][] predicts1 = booster.predict(testMat, false, 1);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class PredictLeafIndices {
|
||||
|
||||
//train a booster
|
||||
int round = 3;
|
||||
Booster booster = XGBoost.train(params, trainMat, round, watches, null, null);
|
||||
Booster booster = XGBoost.train(trainMat, params, round, watches, null, null);
|
||||
|
||||
//predict using first 2 tree
|
||||
float[][] leafindex = booster.predictLeaf(testMat, 2);
|
||||
|
||||
@@ -43,7 +43,7 @@ class BasicWalkThrough {
|
||||
|
||||
val round = 2
|
||||
// train a model
|
||||
val booster = XGBoost.train(params.toMap, trainMax, round, watches.toMap)
|
||||
val booster = XGBoost.train(trainMax, params.toMap, round, watches.toMap)
|
||||
// predict
|
||||
val predicts = booster.predict(testMax)
|
||||
// save model to model path
|
||||
@@ -78,7 +78,7 @@ class BasicWalkThrough {
|
||||
val watches2 = new mutable.HashMap[String, DMatrix]
|
||||
watches2 += "train" -> trainMax2
|
||||
watches2 += "test" -> testMax2
|
||||
val booster3 = XGBoost.train(params.toMap, trainMax2, round, watches2.toMap, null, null)
|
||||
val booster3 = XGBoost.train(trainMax2, params.toMap, round, watches2.toMap, null, null)
|
||||
val predicts3 = booster3.predict(testMax2)
|
||||
println(checkPredicts(predicts, predicts3))
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class BoostFromPrediction {
|
||||
|
||||
val round = 2
|
||||
// train a model
|
||||
val booster = XGBoost.train(params.toMap, trainMat, round, watches.toMap)
|
||||
val booster = XGBoost.train(trainMat, params.toMap, round, watches.toMap)
|
||||
|
||||
val trainPred = booster.predict(trainMat, true)
|
||||
val testPred = booster.predict(testMat, true)
|
||||
@@ -48,6 +48,6 @@ class BoostFromPrediction {
|
||||
testMat.setBaseMargin(testPred)
|
||||
|
||||
System.out.println("result of running from initial prediction")
|
||||
val booster2 = XGBoost.train(params.toMap, trainMat, 1, watches.toMap, null, null)
|
||||
val booster2 = XGBoost.train(trainMat, params.toMap, 1, watches.toMap, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,6 @@ class CrossValidation {
|
||||
val metrics: Array[String] = null
|
||||
|
||||
val evalHist: Array[String] =
|
||||
XGBoost.crossValidation(params.toMap, trainMat, round, nfold, metrics, null, null)
|
||||
XGBoost.crossValidation(trainMat, params.toMap, round, nfold, metrics, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ class CustomObjective {
|
||||
|
||||
val round = 2
|
||||
// train a model
|
||||
val booster = XGBoost.train(params.toMap, trainMat, round, watches.toMap)
|
||||
XGBoost.train(params.toMap, trainMat, round, watches.toMap, new LogRegObj, new EvalError)
|
||||
val booster = XGBoost.train(trainMat, params.toMap, round, watches.toMap)
|
||||
XGBoost.train(trainMat, params.toMap, round, watches.toMap, new LogRegObj, new EvalError)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class ExternalMemory {
|
||||
|
||||
val round = 2
|
||||
// train a model
|
||||
val booster = XGBoost.train(params.toMap, trainMat, round, watches.toMap)
|
||||
val booster = XGBoost.train(trainMat, params.toMap, round, watches.toMap)
|
||||
|
||||
val trainPred = booster.predict(trainMat, true)
|
||||
val testPred = booster.predict(testMat, true)
|
||||
@@ -54,6 +54,6 @@ class ExternalMemory {
|
||||
testMat.setBaseMargin(testPred)
|
||||
|
||||
System.out.println("result of running from initial prediction")
|
||||
val booster2 = XGBoost.train(params.toMap, trainMat, 1, watches.toMap, null, null)
|
||||
val booster2 = XGBoost.train(trainMat, params.toMap, 1, watches.toMap, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class GeneralizedLinearModel {
|
||||
watches += "test" -> testMat
|
||||
|
||||
val round = 4
|
||||
val booster = XGBoost.train(params.toMap, trainMat, 1, watches.toMap, null, null)
|
||||
val booster = XGBoost.train(trainMat, params.toMap, 1, watches.toMap, null, null)
|
||||
val predicts = booster.predict(testMat)
|
||||
val eval = new CustomEval
|
||||
println(s"error=${eval.eval(predicts, testMat)}")
|
||||
|
||||
@@ -38,7 +38,7 @@ class PredictFirstNTree {
|
||||
|
||||
val round = 3
|
||||
// train a model
|
||||
val booster = XGBoost.train(params.toMap, trainMat, round, watches.toMap)
|
||||
val booster = XGBoost.train(trainMat, params.toMap, round, watches.toMap)
|
||||
|
||||
// predict use 1 tree
|
||||
val predicts1 = booster.predict(testMat, false, 1)
|
||||
|
||||
@@ -39,7 +39,7 @@ class PredictLeafIndices {
|
||||
watches += "test" -> testMat
|
||||
|
||||
val round = 3
|
||||
val booster = XGBoost.train(params.toMap, trainMat, round, watches.toMap)
|
||||
val booster = XGBoost.train(trainMat, params.toMap, round, watches.toMap)
|
||||
|
||||
// predict using first 2 tree
|
||||
val leafIndex = booster.predictLeaf(testMat, 2)
|
||||
|
||||
Reference in New Issue
Block a user