[TREE] Remove gap constraint, make tree construction more robust

This commit is contained in:
tqchen 2016-01-28 11:26:37 -08:00
parent c36195795a
commit 2f2080a337
2 changed files with 5 additions and 7 deletions

View File

@ -62,9 +62,7 @@ struct bst_gpair {
};
/*! \brief small eps gap for minimum split decision. */
const float rt_eps = 1e-5f;
/*! \brief min gap between feature values to allow a split happen */
const float rt_2eps = rt_eps * 2.0f;
const float rt_eps = 1e-6f;
/*! \brief define unsigned long for openmp loop */
typedef dmlc::omp_ulong omp_ulong;

View File

@ -291,7 +291,7 @@ class ColMaker: public TreeUpdater {
ThreadEntry &e = stemp[tid][nid];
float fsplit;
if (tid != 0) {
if (std::abs(stemp[tid - 1][nid].last_fvalue - e.first_fvalue) > rt_2eps) {
if (stemp[tid - 1][nid].last_fvalue != e.first_fvalue) {
fsplit = (stemp[tid - 1][nid].last_fvalue + e.first_fvalue) * 0.5f;
} else {
continue;
@ -352,7 +352,7 @@ class ColMaker: public TreeUpdater {
e.first_fvalue = fvalue;
} else {
// forward default right
if (std::abs(fvalue - e.first_fvalue) > rt_2eps) {
if (fvalue != e.first_fvalue) {
if (need_forward) {
c.SetSubstract(snode[nid].stats, e.stats);
if (c.sum_hess >= param.min_child_weight &&
@ -393,7 +393,7 @@ class ColMaker: public TreeUpdater {
e.last_fvalue = fvalue;
} else {
// try to find a split
if (std::abs(fvalue - e.last_fvalue) > rt_2eps &&
if (fvalue != e.last_fvalue &&
e.stats.sum_hess >= param.min_child_weight) {
c.SetSubstract(snode[nid].stats, e.stats);
if (c.sum_hess >= param.min_child_weight) {
@ -511,7 +511,7 @@ class ColMaker: public TreeUpdater {
e.last_fvalue = fvalue;
} else {
// try to find a split
if (std::abs(fvalue - e.last_fvalue) > rt_2eps &&
if (fvalue != e.last_fvalue &&
e.stats.sum_hess >= param.min_child_weight) {
c.SetSubstract(snode[nid].stats, e.stats);
if (c.sum_hess >= param.min_child_weight) {