| 109 | } |
| 110 | |
| 111 | void Split(const TBinarySplit& split, |
| 112 | ui32 depth, |
| 113 | TVector<ui32>& bins) { |
| 114 | if (FeaturesManager.IsFloat(split.FeatureId)) { |
| 115 | const auto floatFeatureIdx = DataProvider.MetaInfo.FeaturesLayout->GetInternalFeatureIdx<EFeatureType::Float>(split.FeatureId); |
| 116 | auto& valuesHolder = **(DataProvider.ObjectsData->GetFloatFeature(*floatFeatureIdx)); |
| 117 | auto featureBins = valuesHolder.ExtractValues<ui16>(&NPar::LocalExecutor()); |
| 118 | for (ui32 i = 0; i < bins.size(); ++i) { |
| 119 | bins[i] |= (featureBins[i] > split.BinIdx) << depth; |
| 120 | } |
| 121 | } else if (FeaturesManager.IsCat(split.FeatureId)) { |
| 122 | const auto catFeatureIdx = DataProvider.MetaInfo.FeaturesLayout->GetInternalFeatureIdx<EFeatureType::Categorical>(split.FeatureId); |
| 123 | auto& valuesHolder = **(DataProvider.ObjectsData->GetCatFeature(*catFeatureIdx)); |
| 124 | auto featureBins = valuesHolder.ExtractValues<ui32>(&NPar::LocalExecutor()); |
| 125 | for (ui32 i = 0; i < bins.size(); ++i) { |
| 126 | bins[i] |= (featureBins[i] == split.BinIdx) << depth; |
| 127 | } |
| 128 | } else { |
| 129 | const auto& ctr = FeaturesManager.GetCtr(split.FeatureId); |
| 130 | auto treeSplit = BuildTreeCtrSplitCpu(ctr.FeatureTensor); |
| 131 | |
| 132 | const auto& borders = FeaturesManager.GetBorders(split.FeatureId); |
| 133 | |
| 134 | TCpuTargetClassCtrCalcer calcer(treeSplit.UniqueCount, |
| 135 | treeSplit.Bins, |
| 136 | GetWeights(*DataProvider.TargetData), |
| 137 | ctr.Configuration.Prior[0], ctr.Configuration.Prior[1]); |
| 138 | |
| 139 | TVector<ui32> featureBins; |
| 140 | if (ctr.Configuration.Type == ECtrType::FeatureFreq) { |
| 141 | auto freqCtr = calcer.ComputeFreqCtr(); |
| 142 | featureBins = NCB::BinarizeLine<ui32>(freqCtr, ENanMode::Forbidden, borders); |
| 143 | } else if (ctr.Configuration.Type == ECtrType::Buckets) { |
| 144 | auto floatCtr = calcer.Calc(Indices, TConstArrayRef<ui32>(Indices), BinarizedTarget, NumClasses); |
| 145 | TVector<float> values; |
| 146 | for (ui32 i = 0; i < treeSplit.Bins.size(); ++i) { |
| 147 | values.push_back(floatCtr[i][ctr.Configuration.ParamId]); |
| 148 | } |
| 149 | featureBins = NCB::BinarizeLine<ui32>(values, |
| 150 | ENanMode::Forbidden, |
| 151 | borders); |
| 152 | } else { |
| 153 | ythrow yexception() << "Test for ctr type " << ctr.Configuration.Type |
| 154 | << " isn't supported currently " << Endl; |
| 155 | } |
| 156 | |
| 157 | for (ui32 i = 0; i < bins.size(); ++i) { |
| 158 | bins[i] |= (featureBins[i] > split.BinIdx) << depth; |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | }; |
| 163 | |
| 164 | void CheckBins(const TFeatureParallelDataSet& dataSet, |
no test coverage detected