Small cleanup to evaluator. (#6400)
This commit is contained in:
parent
9c9070aea2
commit
44a9d69efb
@ -71,15 +71,15 @@ class TreeEvaluator {
|
|||||||
|
|
||||||
XGBOOST_DEVICE double CalcSplitGain(const ParamT ¶m, bst_node_t nidx,
|
XGBOOST_DEVICE double CalcSplitGain(const ParamT ¶m, bst_node_t nidx,
|
||||||
bst_feature_t fidx,
|
bst_feature_t fidx,
|
||||||
tree::GradStats left,
|
tree::GradStats const& left,
|
||||||
tree::GradStats right) const {
|
tree::GradStats const& right) const {
|
||||||
int constraint = constraints[fidx];
|
int constraint = constraints[fidx];
|
||||||
const double negative_infinity = -std::numeric_limits<double>::infinity();
|
const double negative_infinity = -std::numeric_limits<double>::infinity();
|
||||||
double wleft = this->CalcWeight(nidx, param, left);
|
double wleft = this->CalcWeight(nidx, param, left);
|
||||||
double wright = this->CalcWeight(nidx, param, right);
|
double wright = this->CalcWeight(nidx, param, right);
|
||||||
|
|
||||||
double gain = this->CalcGainGivenWeight(nidx, param, left, wleft) +
|
double gain = this->CalcGainGivenWeight(param, left, wleft) +
|
||||||
this->CalcGainGivenWeight(nidx, param, right, wright);
|
this->CalcGainGivenWeight(param, right, wright);
|
||||||
|
|
||||||
if (constraint == 0) {
|
if (constraint == 0) {
|
||||||
return gain;
|
return gain;
|
||||||
@ -91,7 +91,7 @@ class TreeEvaluator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XGBOOST_DEVICE float CalcWeight(bst_node_t nodeid, const ParamT ¶m,
|
XGBOOST_DEVICE float CalcWeight(bst_node_t nodeid, const ParamT ¶m,
|
||||||
tree::GradStats stats) const {
|
tree::GradStats const& stats) const {
|
||||||
float w = xgboost::tree::CalcWeight(param, stats);
|
float w = xgboost::tree::CalcWeight(param, stats);
|
||||||
if (!has_constraint) {
|
if (!has_constraint) {
|
||||||
return w;
|
return w;
|
||||||
@ -107,8 +107,8 @@ class TreeEvaluator {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XGBOOST_DEVICE float CalcGainGivenWeight(bst_node_t, ParamT const &p,
|
XGBOOST_DEVICE float
|
||||||
tree::GradStats stats, float w) const {
|
CalcGainGivenWeight(ParamT const &p, tree::GradStats const& stats, float w) const {
|
||||||
if (stats.GetHess() <= 0) {
|
if (stats.GetHess() <= 0) {
|
||||||
return .0f;
|
return .0f;
|
||||||
}
|
}
|
||||||
@ -121,8 +121,8 @@ class TreeEvaluator {
|
|||||||
stats.sum_hess, w);
|
stats.sum_hess, w);
|
||||||
}
|
}
|
||||||
XGBOOST_DEVICE float CalcGain(bst_node_t nid, ParamT const &p,
|
XGBOOST_DEVICE float CalcGain(bst_node_t nid, ParamT const &p,
|
||||||
tree::GradStats stats) const {
|
tree::GradStats const& stats) const {
|
||||||
return this->CalcGainGivenWeight(nid, p, stats, this->CalcWeight(nid, p, stats));
|
return this->CalcGainGivenWeight(p, stats, this->CalcWeight(nid, p, stats));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user