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

Method GetLearnFeatureIds

catboost/cuda/gpu_data/dataset_helpers.cpp:73–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73TVector<ui32> NCatboostCuda::GetLearnFeatureIds(NCatboostCuda::TBinarizedFeaturesManager& featuresManager) {
74 TSet<ui32> featureIdsSet;
75 auto ctrTypes = featuresManager.GetKnownSimpleCtrTypes();
76
77 for (auto floatFeature : featuresManager.GetFloatFeatureIds()) {
78 if (featuresManager.GetBinCount(floatFeature) > 1) {
79 featureIdsSet.insert(floatFeature);
80 }
81 }
82 for (auto catFeature : featuresManager.GetCatFeatureIds()) {
83 if (featuresManager.UseForOneHotEncoding(catFeature)) {
84 if (featuresManager.GetBinCount(catFeature) > 1) {
85 featureIdsSet.insert(catFeature);
86 }
87 }
88
89 if (featuresManager.UseForCtr(catFeature)) {
90 for (auto& ctr : ctrTypes) {
91 const auto simpleCtrsForType = featuresManager.CreateSimpleCtrsForType(catFeature,
92 ctr);
93 for (auto ctrFeatureId : simpleCtrsForType) {
94 featureIdsSet.insert(ctrFeatureId);
95 }
96 }
97 }
98 }
99 TSet<ui32> combinationCtrIds;
100
101 for (auto& ctr : ctrTypes) {
102 auto combinationCtrs = featuresManager.CreateCombinationCtrForType(ctr);
103 for (auto ctrFeatureId : combinationCtrs) {
104 TFeatureTensor tensor = featuresManager.GetCtr(ctrFeatureId).FeatureTensor;
105 bool hasUnknownFeatures = false;
106 CB_ENSURE(tensor.GetSplits().size() == 0);
107
108 for (auto featureId : tensor.GetCatFeatures()) {
109 if (!featureIdsSet.contains(featureId)) {
110 hasUnknownFeatures = true;
111 break;
112 }
113 }
114 for (auto binarySplit : tensor.GetSplits()) {
115 if (!featureIdsSet.contains(binarySplit.FeatureId)) {
116 hasUnknownFeatures = true;
117 break;
118 }
119 }
120 if (!hasUnknownFeatures) {
121 combinationCtrIds.insert(ctrFeatureId);
122 }
123 }
124 }
125 featureIdsSet.insert(combinationCtrIds.begin(), combinationCtrIds.end());
126
127 auto estimatedFeatures = featuresManager.GetEstimatedFeatureIds();
128 featureIdsSet.insert(estimatedFeatures.begin(), estimatedFeatures.end());
129
130 auto featureBundleIds = featuresManager.GetExclusiveFeatureBundleIds();

Callers

nothing calls this directly

Calls 15

GetFloatFeatureIdsMethod · 0.80
GetCatFeatureIdsMethod · 0.80
UseForOneHotEncodingMethod · 0.80
UseForCtrMethod · 0.80
GetSplitsMethod · 0.80
GetCatFeaturesMethod · 0.80
GetBinCountMethod · 0.45

Tested by

no test coverage detected