Separate Depthwidth and Lossguide growing policy in fast histogram (#4102)
* add back train method but mark as deprecated * add back train method but mark as deprecated * add back train method but mark as deprecated * fix scalastyle error * fix scalastyle error * fix scalastyle error * fix scalastyle error * init * more changes * temp * update * udpate rabit * change the histogram * update kfactor * sync per node stats * temp * update * final * code clean * update rabit * more cleanup * fix errors * fix failed tests * enforce c++11 * broadcast subsampled feature correctly * init col * temp * col sampling * fix histmastrix init * fix col sampling * remove cout * fix out of bound access * fix core dump remove core dump file * disbale test temporarily * update * add fid * print perf data * update * revert some changes * temp * temp * pass all tests * bring back some tests * recover some changes * fix lint issue * enable monotone and interaction constraints * don't specify default for monotone and interactions * recover column init part * more recovery * fix core dumps * code clean * revert some changes * fix test compilation issue * fix lint issue * resolve compilation issue * fix issues of lint caused by rebase * fix stylistic changes and change variable names * use regtree internal function * modularize depth width * address the comments * fix failed tests * wrap perf timers with class * fix lint * fix num_leaves count * fix indention * Update src/tree/updater_quantile_hist.cc Co-Authored-By: CodingCat <CodingCat@users.noreply.github.com> * Update src/tree/updater_quantile_hist.h Co-Authored-By: CodingCat <CodingCat@users.noreply.github.com> * Update src/tree/updater_quantile_hist.cc Co-Authored-By: CodingCat <CodingCat@users.noreply.github.com> * Update src/tree/updater_quantile_hist.cc Co-Authored-By: CodingCat <CodingCat@users.noreply.github.com> * Update src/tree/updater_quantile_hist.cc Co-Authored-By: CodingCat <CodingCat@users.noreply.github.com> * Update src/tree/updater_quantile_hist.h Co-Authored-By: CodingCat <CodingCat@users.noreply.github.com> * merge * fix compilation
This commit is contained in:
@@ -342,7 +342,6 @@ public class BoosterImplTest {
|
||||
public void testBoosterEarlyStop() throws XGBoostError, IOException {
|
||||
DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");
|
||||
DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test");
|
||||
// testBoosterWithFastHistogram(trainMat, testMat);
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("max_depth", 3);
|
||||
@@ -375,7 +374,7 @@ public class BoosterImplTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void testWithFastHisto(DMatrix trainingSet, Map<String, DMatrix> watches, int round,
|
||||
private void testWithQuantileHisto(DMatrix trainingSet, Map<String, DMatrix> watches, int round,
|
||||
Map<String, Object> paramMap, float threshold) throws XGBoostError {
|
||||
float[][] metrics = new float[watches.size()][round];
|
||||
Booster booster = XGBoost.train(trainingSet, paramMap, round, watches,
|
||||
@@ -393,10 +392,9 @@ public class BoosterImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFastHistoDepthWise() throws XGBoostError {
|
||||
public void testQuantileHistoDepthWise() throws XGBoostError {
|
||||
DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");
|
||||
DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test");
|
||||
// testBoosterWithFastHistogram(trainMat, testMat);
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("max_depth", 3);
|
||||
@@ -410,14 +408,13 @@ public class BoosterImplTest {
|
||||
Map<String, DMatrix> watches = new HashMap<>();
|
||||
watches.put("training", trainMat);
|
||||
watches.put("test", testMat);
|
||||
testWithFastHisto(trainMat, watches, 10, paramMap, 0.0f);
|
||||
testWithQuantileHisto(trainMat, watches, 10, paramMap, 0.95f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFastHistoLossGuide() throws XGBoostError {
|
||||
public void testQuantileHistoLossGuide() throws XGBoostError {
|
||||
DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");
|
||||
DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test");
|
||||
// testBoosterWithFastHistogram(trainMat, testMat);
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("max_depth", 0);
|
||||
@@ -432,14 +429,13 @@ public class BoosterImplTest {
|
||||
Map<String, DMatrix> watches = new HashMap<>();
|
||||
watches.put("training", trainMat);
|
||||
watches.put("test", testMat);
|
||||
testWithFastHisto(trainMat, watches, 10, paramMap, 0.0f);
|
||||
testWithQuantileHisto(trainMat, watches, 10, paramMap, 0.95f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFastHistoLossGuideMaxBin() throws XGBoostError {
|
||||
public void testQuantileHistoLossGuideMaxBin() throws XGBoostError {
|
||||
DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");
|
||||
DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test");
|
||||
// testBoosterWithFastHistogram(trainMat, testMat);
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("max_depth", 0);
|
||||
@@ -454,7 +450,7 @@ public class BoosterImplTest {
|
||||
};
|
||||
Map<String, DMatrix> watches = new HashMap<>();
|
||||
watches.put("training", trainMat);
|
||||
testWithFastHisto(trainMat, watches, 10, paramMap, 0.0f);
|
||||
testWithQuantileHisto(trainMat, watches, 10, paramMap, 0.95f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -534,38 +530,33 @@ public class BoosterImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFastHistoDepthwiseMaxDepth() throws XGBoostError {
|
||||
public void testQuantileHistoDepthwiseMaxDepth() throws XGBoostError {
|
||||
DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");
|
||||
DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test");
|
||||
// testBoosterWithFastHistogram(trainMat, testMat);
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("max_depth", 3);
|
||||
put("silent", 1);
|
||||
put("objective", "binary:logistic");
|
||||
put("tree_method", "hist");
|
||||
put("max_depth", 2);
|
||||
put("grow_policy", "depthwise");
|
||||
put("eval_metric", "auc");
|
||||
}
|
||||
};
|
||||
Map<String, DMatrix> watches = new HashMap<>();
|
||||
watches.put("training", trainMat);
|
||||
testWithFastHisto(trainMat, watches, 10, paramMap, 0.85f);
|
||||
testWithQuantileHisto(trainMat, watches, 10, paramMap, 0.95f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFastHistoDepthwiseMaxDepthMaxBin() throws XGBoostError {
|
||||
public void testQuantileHistoDepthwiseMaxDepthMaxBin() throws XGBoostError {
|
||||
DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train");
|
||||
DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test");
|
||||
// testBoosterWithFastHistogram(trainMat, testMat);
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("max_depth", 3);
|
||||
put("silent", 1);
|
||||
put("objective", "binary:logistic");
|
||||
put("tree_method", "hist");
|
||||
put("max_depth", 2);
|
||||
put("max_bin", 2);
|
||||
put("grow_policy", "depthwise");
|
||||
put("eval_metric", "auc");
|
||||
@@ -573,7 +564,7 @@ public class BoosterImplTest {
|
||||
};
|
||||
Map<String, DMatrix> watches = new HashMap<>();
|
||||
watches.put("training", trainMat);
|
||||
testWithFastHisto(trainMat, watches, 10, paramMap, 0.85f);
|
||||
testWithQuantileHisto(trainMat, watches, 10, paramMap, 0.95f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,7 +77,7 @@ class ScalaBoosterImplSuite extends FunSuite {
|
||||
XGBoost.train(trainMat, paramMap, round, watches)
|
||||
}
|
||||
|
||||
private def trainBoosterWithFastHisto(
|
||||
private def trainBoosterWithQuantileHisto(
|
||||
trainMat: DMatrix,
|
||||
watches: Map[String, DMatrix],
|
||||
round: Int,
|
||||
@@ -146,57 +146,57 @@ class ScalaBoosterImplSuite extends FunSuite {
|
||||
XGBoost.crossValidation(trainMat, params, round, nfold)
|
||||
}
|
||||
|
||||
test("test with fast histo depthwise") {
|
||||
test("test with quantile histo depthwise") {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
val testMat = new DMatrix("../../demo/data/agaricus.txt.test")
|
||||
val paramMap = List("max_depth" -> "3", "silent" -> "0",
|
||||
"objective" -> "binary:logistic", "tree_method" -> "hist",
|
||||
"grow_policy" -> "depthwise", "eval_metric" -> "auc").toMap
|
||||
trainBoosterWithFastHisto(trainMat, Map("training" -> trainMat, "test" -> testMat),
|
||||
round = 10, paramMap, 0.0f)
|
||||
trainBoosterWithQuantileHisto(trainMat, Map("training" -> trainMat, "test" -> testMat),
|
||||
round = 10, paramMap, 0.95f)
|
||||
}
|
||||
|
||||
test("test with fast histo lossguide") {
|
||||
test("test with quantile histo lossguide") {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
val testMat = new DMatrix("../../demo/data/agaricus.txt.test")
|
||||
val paramMap = List("max_depth" -> "0", "silent" -> "0",
|
||||
"objective" -> "binary:logistic", "tree_method" -> "hist",
|
||||
"grow_policy" -> "lossguide", "max_leaves" -> "8", "eval_metric" -> "auc").toMap
|
||||
trainBoosterWithFastHisto(trainMat, Map("training" -> trainMat, "test" -> testMat),
|
||||
round = 10, paramMap, 0.0f)
|
||||
trainBoosterWithQuantileHisto(trainMat, Map("training" -> trainMat, "test" -> testMat),
|
||||
round = 10, paramMap, 0.95f)
|
||||
}
|
||||
|
||||
test("test with fast histo lossguide with max bin") {
|
||||
test("test with quantile histo lossguide with max bin") {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
val testMat = new DMatrix("../../demo/data/agaricus.txt.test")
|
||||
val paramMap = List("max_depth" -> "0", "silent" -> "0",
|
||||
"objective" -> "binary:logistic", "tree_method" -> "hist",
|
||||
"grow_policy" -> "lossguide", "max_leaves" -> "8", "max_bin" -> "16",
|
||||
"eval_metric" -> "auc").toMap
|
||||
trainBoosterWithFastHisto(trainMat, Map("training" -> trainMat),
|
||||
round = 10, paramMap, 0.0f)
|
||||
trainBoosterWithQuantileHisto(trainMat, Map("training" -> trainMat),
|
||||
round = 10, paramMap, 0.95f)
|
||||
}
|
||||
|
||||
test("test with fast histo depthwidth with max depth") {
|
||||
test("test with quantile histo depthwidth with max depth") {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
val testMat = new DMatrix("../../demo/data/agaricus.txt.test")
|
||||
val paramMap = List("max_depth" -> "0", "silent" -> "0",
|
||||
"objective" -> "binary:logistic", "tree_method" -> "hist",
|
||||
"grow_policy" -> "depthwise", "max_leaves" -> "8", "max_depth" -> "2",
|
||||
"eval_metric" -> "auc").toMap
|
||||
trainBoosterWithFastHisto(trainMat, Map("training" -> trainMat),
|
||||
round = 10, paramMap, 0.85f)
|
||||
trainBoosterWithQuantileHisto(trainMat, Map("training" -> trainMat),
|
||||
round = 10, paramMap, 0.95f)
|
||||
}
|
||||
|
||||
test("test with fast histo depthwidth with max depth and max bin") {
|
||||
test("test with quantile histo depthwidth with max depth and max bin") {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
val testMat = new DMatrix("../../demo/data/agaricus.txt.test")
|
||||
val paramMap = List("max_depth" -> "0", "silent" -> "0",
|
||||
"objective" -> "binary:logistic", "tree_method" -> "hist",
|
||||
"grow_policy" -> "depthwise", "max_depth" -> "2", "max_bin" -> "2",
|
||||
"eval_metric" -> "auc").toMap
|
||||
trainBoosterWithFastHisto(trainMat, Map("training" -> trainMat),
|
||||
round = 10, paramMap, 0.85f)
|
||||
trainBoosterWithQuantileHisto(trainMat, Map("training" -> trainMat),
|
||||
round = 10, paramMap, 0.95f)
|
||||
}
|
||||
|
||||
test("test training from existing model in scala") {
|
||||
|
||||
Reference in New Issue
Block a user