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

@@ -75,6 +75,11 @@ class GradientBooster : public Model, public Configurable {
/*! \brief Return number of boosted rounds.
*/
virtual int32_t BoostedRounds() const = 0;
/**
* \brief Whether the model has already been trained. When tree booster is chosen, then
* returns true when there are existing trees.
*/
virtual bool ModelFitted() const = 0;
/*!
* \brief perform update to the model(boosting)
* \param p_fmat feature matrix that provide access to features

View File

@@ -328,7 +328,7 @@ struct LearnerModelParam {
void Copy(LearnerModelParam const& that);
/* \brief Whether this parameter is initialized with LearnerModelParamLegacy. */
bool Initialized() const { return num_feature != 0; }
bool Initialized() const { return num_feature != 0 && num_output_group != 0; }
};
} // namespace xgboost