Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
* Improve false positive rates from periodicity test for time series anomaly detection.
(See {ml-pull}1177[#1177].)
* Break progress reporting of data frame analyses into multiple phases. (See {ml-pull}1179[#1179].)
* Really centre the data before training for classification and regression begins. This
means we can choose more optimal smoothing bias and should reduce the number of trees.
(See {ml-pull}1192[#1192].)

=== Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions include/maths/CBoostedTreeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class MATHS_EXPORT CBoostedTreeImpl final {
const core::CPackedBitVector& trainingRowMask,
const core::CPackedBitVector& testingRowMask,
double eta,
double lambda,
TNodeVec& tree) const;

//! Compute the mean of the loss function on the masked rows of \p frame.
Expand Down
4 changes: 2 additions & 2 deletions lib/api/unittest/CDataFrameAnalyzerFeatureImportanceTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ BOOST_FIXTURE_TEST_CASE(testRegressionFeatureImportanceNoImportance, SFixture) {
double c1{readShapValue(result, "c1")};
double prediction{
result["row_results"]["results"]["ml"]["target_prediction"].GetDouble()};
// c1 explains 94% of the prediction value, i.e. the difference from the prediction is less than 2%.
// c1 explains 94% of the prediction value, i.e. the difference from the prediction is less than 6%.
BOOST_REQUIRE_CLOSE(c1, prediction, 6.0);
for (const auto& feature : {"c2", "c3", "c4"}) {
double c = readShapValue(result, feature);
BOOST_REQUIRE_SMALL(c, 2.0);
BOOST_REQUIRE_SMALL(c, 3.0);
cNoImportanceMean.add(std::fabs(c));
}
}
Expand Down
14 changes: 7 additions & 7 deletions lib/maths/CBoostedTreeImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ CBoostedTreeImpl::TNodeVec CBoostedTreeImpl::initializePredictionsAndLossDerivat

// At the start we will centre the data w.r.t. the given loss function.
TNodeVec tree{CBoostedTreeNode{m_Loss->numberParameters()}};
this->refreshPredictionsAndLossDerivatives(frame, trainingRowMask,
testingRowMask, 1.0, tree);
this->refreshPredictionsAndLossDerivatives(frame, trainingRowMask, testingRowMask,
1.0 /*eta*/, 0.0 /*lambda*/, tree);

return tree;
}
Expand Down Expand Up @@ -585,8 +585,9 @@ CBoostedTreeImpl::trainForest(core::CDataFrame& frame,

if (tree.size() > 1) {
scopeMemoryUsage.add(tree);
this->refreshPredictionsAndLossDerivatives(frame, trainingRowMask,
testingRowMask, eta, tree);
this->refreshPredictionsAndLossDerivatives(
frame, trainingRowMask, testingRowMask, eta,
m_Regularization.leafWeightPenaltyMultiplier(), tree);
forest.push_back(std::move(tree));
eta = std::min(1.0, m_EtaGrowthRatePerTree * eta);
retries = 0;
Expand Down Expand Up @@ -990,13 +991,12 @@ void CBoostedTreeImpl::refreshPredictionsAndLossDerivatives(core::CDataFrame& fr
const core::CPackedBitVector& trainingRowMask,
const core::CPackedBitVector& testingRowMask,
double eta,
double lambda,
TNodeVec& tree) const {

using TArgMinLossVec = std::vector<CArgMinLoss>;

TArgMinLossVec leafValues(
tree.size(),
m_Loss->minimizer(m_Regularization.leafWeightPenaltyMultiplier(), m_Rng));
TArgMinLossVec leafValues(tree.size(), m_Loss->minimizer(lambda, m_Rng));
auto nextPass = [&] {
bool done{true};
for (const auto& value : leafValues) {
Expand Down