* @brief Load feature type info from names, returns whether there's categorical features. */
| 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 | |
| 308 | const std::vector<size_t>& MetaInfo::LabelAbsSort(Context const* ctx) const { |
| 309 | if (label_order_cache_.size() == labels.Size()) { |
no outgoing calls
no test coverage detected