Add XGBoosterGetNumFeature (#5856)

- add GetNumFeature to Learner
- add XGBoosterGetNumFeature to C API
- update c-api-demo accordingly
This commit is contained in:
Alexander Gugel
2020-07-14 07:25:17 +01:00
committed by GitHub
parent e0c179c7cc
commit 970b4b3fa2
6 changed files with 36 additions and 1 deletions

View File

@@ -563,6 +563,14 @@ XGB_DLL int XGBoosterSetParam(BoosterHandle handle,
const char *name,
const char *value);
/*!
* \brief get number of features
* \param out number of features
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGBoosterGetNumFeature(BoosterHandle handle,
bst_ulong *out);
/*!
* \brief update the model in one round using dtrain
* \param handle handle

View File

@@ -158,6 +158,12 @@ class Learner : public Model, public Configurable, public rabit::Serializable {
*/
virtual void SetParam(const std::string& key, const std::string& value) = 0;
/*!
* \brief Get the number of features of the booster.
* \return number of features
*/
virtual uint32_t GetNumFeature() = 0;
/*!
* \brief Set additional attribute to the Booster.
*