MCPcopy Create free account
hub / github.com/dmlc/xgboost / LoadFeatureType

Function LoadFeatureType

src/data/data.cc:285–306  ·  view source on GitHub ↗

* @brief Load feature type info from names, returns whether there's categorical features. */

Source from the content-addressed store, hash-verified

283 * @brief Load feature type info from names, returns whether there's categorical features.
284 */
285[[nodiscard]] bool LoadFeatureType(std::vector<std::string> const& type_names,
286 std::vector<FeatureType>* types) {
287 types->clear();
288 bool has_cat{false};
289 for (auto const& elem : type_names) {
290 if (elem == "int") {
291 types->emplace_back(FeatureType::kNumerical);
292 } else if (elem == "float") {
293 types->emplace_back(FeatureType::kNumerical);
294 } else if (elem == "i") {
295 types->emplace_back(FeatureType::kNumerical);
296 } else if (elem == "q") {
297 types->emplace_back(FeatureType::kNumerical);
298 } else if (elem == "c") {
299 types->emplace_back(FeatureType::kCategorical);
300 has_cat = true;
301 } else {
302 LOG(FATAL) << "All feature_types must be one of {int, float, i, q, c}.";
303 }
304 }
305 return has_cat;
306}
307
308const std::vector<size_t>& MetaInfo::LabelAbsSort(Context const* ctx) const {
309 if (label_order_cache_.size() == labels.Size()) {

Callers 3

LoadBinaryMethod · 0.85
SetFeatureInfoMethod · 0.85
ExtendMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected