Configuration for init estimation. (#8343)

* Configuration for init estimation.

* Check whether the model needs configuration based on const attribute `ModelFitted`
instead of a mutable state.
* Add parameter `boost_from_average` to tell whether the user has specified base score.
* Add tests.
This commit is contained in:
Jiaming Yuan
2022-10-18 01:52:24 +08:00
committed by GitHub
parent 2176e511fc
commit 031d66ec27
10 changed files with 247 additions and 111 deletions

View File

@@ -95,6 +95,8 @@ class GBLinear : public GradientBooster {
return model_.num_boosted_rounds;
}
bool ModelFitted() const override { return BoostedRounds() != 0; }
void Load(dmlc::Stream* fi) override {
model_.Load(fi);
}

View File

@@ -252,6 +252,10 @@ class GBTree : public GradientBooster {
return model_.trees.size() / this->LayerTrees();
}
bool ModelFitted() const override {
return !model_.trees.empty() || !model_.trees_to_update.empty();
}
void PredictBatch(DMatrix *p_fmat, PredictionCacheEntry *out_preds,
bool training, unsigned layer_begin, unsigned layer_end) override;