Add XGBoosterGetNumFeature (#5856)
- add GetNumFeature to Learner - add XGBoosterGetNumFeature to C API - update c-api-demo accordingly
This commit is contained in:
@@ -395,6 +395,14 @@ XGB_DLL int XGBoosterSetParam(BoosterHandle handle,
|
||||
API_END();
|
||||
}
|
||||
|
||||
XGB_DLL int XGBoosterGetNumFeature(BoosterHandle handle,
|
||||
xgboost::bst_ulong *out) {
|
||||
API_BEGIN();
|
||||
CHECK_HANDLE();
|
||||
*out = static_cast<Learner*>(handle)->GetNumFeature();
|
||||
API_END();
|
||||
}
|
||||
|
||||
XGB_DLL int XGBoosterLoadJsonConfig(BoosterHandle handle, char const* json_parameters) {
|
||||
API_BEGIN();
|
||||
CHECK_HANDLE();
|
||||
|
||||
@@ -384,6 +384,10 @@ class LearnerConfiguration : public Learner {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t GetNumFeature() override {
|
||||
return learner_model_param_.num_feature;
|
||||
}
|
||||
|
||||
void SetAttr(const std::string& key, const std::string& value) override {
|
||||
attributes_[key] = value;
|
||||
mparam_.contain_extra_attrs = 1;
|
||||
|
||||
Reference in New Issue
Block a user