MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / SplitCategorical

Method SplitCategorical

src/io/sparse_bin.hpp:211–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209 }
210
211 data_size_t SplitCategorical(
212 uint32_t min_bin, uint32_t max_bin, uint32_t default_bin,
213 const uint32_t* threshold, int num_threahold, data_size_t* data_indices, data_size_t num_data,
214 data_size_t* lte_indices, data_size_t* gt_indices) const override {
215 if (num_data <= 0) { return 0; }
216 data_size_t lte_count = 0;
217 data_size_t gt_count = 0;
218 SparseBinIterator<VAL_T> iterator(this, data_indices[0]);
219 data_size_t* default_indices = gt_indices;
220 data_size_t* default_count = &gt_count;
221 if (Common::FindInBitset(threshold, num_threahold, default_bin)) {
222 default_indices = lte_indices;
223 default_count = &lte_count;
224 }
225 for (data_size_t i = 0; i < num_data; ++i) {
226 const data_size_t idx = data_indices[i];
227 uint32_t bin = iterator.InnerRawGet(idx);
228 if (bin < min_bin || bin > max_bin) {
229 default_indices[(*default_count)++] = idx;
230 } else if (Common::FindInBitset(threshold, num_threahold, bin - min_bin)) {
231 lte_indices[lte_count++] = idx;
232 } else {
233 gt_indices[gt_count++] = idx;
234 }
235 }
236 return lte_count;
237 }
238
239 data_size_t num_data() const override { return num_data_; }
240

Callers

nothing calls this directly

Calls 2

FindInBitsetFunction · 0.50
InnerRawGetMethod · 0.45

Tested by

no test coverage detected