adjust the API signature as well as the docs

This commit is contained in:
CodingCat
2016-03-11 15:22:44 -05:00
parent 97e4dcde98
commit 400b1faecc
23 changed files with 58 additions and 52 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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))
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)}")

View File

@@ -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)

View File

@@ -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)