MCPcopy Create free account
hub / github.com/catboost/catboost / ApplyFeatureNames

Method ApplyFeatureNames

catboost/libs/model/model.h:404–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402 );
403
404 void ApplyFeatureNames(const TVector<TString>& featureNames) {
405 auto setFeatureName = [&] (TFeatureBase& feature) {
406 size_t flatIndex = static_cast<size_t>(feature.Position.FlatIndex);
407 CB_ENSURE(
408 flatIndex < featureNames.size(),
409 "Model has a feature with index " << flatIndex << " but the length of the provided features names array ("
410 << featureNames.size() << ") is too small for it"
411 );
412 feature.FeatureId = featureNames[flatIndex];
413 };
414
415 for (TFloatFeature& feature : FloatFeatures) {
416 setFeatureName(feature);
417 }
418 for (TCatFeature& feature : CatFeatures) {
419 setFeatureName(feature);
420 }
421 for (TTextFeature& feature : TextFeatures) {
422 setFeatureName(feature);
423 }
424 for (TEmbeddingFeature& feature : EmbeddingFeatures) {
425 setFeatureName(feature);
426 }
427 }
428
429 void AddFloatFeature(const TFloatFeature& floatFeature) {
430 FloatFeatures.push_back(floatFeature);

Callers 1

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected