| 23 | Y_UNIT_TEST_SUITE(BinarizationsTests) { |
| 24 | template <class TCompressedDataSet> |
| 25 | void CheckDataSet(const TCompressedDataSet& dataSet, |
| 26 | const TBinarizedFeaturesManager& featuresManager, |
| 27 | const TDataPermutation& ctrsPermutation, |
| 28 | const NCB::TTrainingDataProvider& dataProvider, |
| 29 | const TDataPermutation* onGpuPermutation = nullptr) { |
| 30 | auto binarizedTarget = NCB::BinarizeLine<ui8>(*dataProvider.TargetData->GetOneDimensionalTarget(), |
| 31 | ENanMode::Forbidden, |
| 32 | featuresManager.GetTargetBorders()); |
| 33 | ui32 numClasses = 0; |
| 34 | { |
| 35 | std::array<bool, 255> seen; |
| 36 | for (ui32 i = 0; i < 255; ++i) { |
| 37 | seen[i] = false; |
| 38 | } |
| 39 | for (auto val : binarizedTarget) { |
| 40 | seen[val] = true; |
| 41 | } |
| 42 | for (ui32 i = 0; i < 255; ++i) { |
| 43 | numClasses += seen[i]; |
| 44 | } |
| 45 | } |
| 46 | TVector<ui32> ctrToDirectIndices; |
| 47 | TVector<ui32> ctrsEstimationPermutation; |
| 48 | ctrsPermutation.FillInversePermutation(ctrToDirectIndices); |
| 49 | ctrsPermutation.FillOrder(ctrsEstimationPermutation); |
| 50 | |
| 51 | TVector<ui32> gatherBinIndices; |
| 52 | if (onGpuPermutation != nullptr) { |
| 53 | onGpuPermutation->FillOrder(gatherBinIndices); |
| 54 | } else { |
| 55 | gatherBinIndices.resize(ctrToDirectIndices.size()); |
| 56 | std::iota(gatherBinIndices.begin(), gatherBinIndices.end(), 0); |
| 57 | } |
| 58 | |
| 59 | TMap<ui32, TArray2D<float>> ctrsCache; |
| 60 | |
| 61 | auto features = dataSet.GetFeatures(); |
| 62 | |
| 63 | for (ui32 dev = 0; dev < NCudaLib::GetDeviceCount(); ++dev) { |
| 64 | // TSlice featuresSlice = featuresMapping.DeviceSlice(dev); |
| 65 | |
| 66 | TVector<ui32> compressedIndex; |
| 67 | dataSet.GetCompressedIndex().DeviceView(dev).Read(compressedIndex); |
| 68 | |
| 69 | for (ui32 f = 0; f < dataSet.GetFeatureCount(); ++f) { |
| 70 | auto featureId = features[f]; |
| 71 | auto cudaFeature = dataSet.GetTCFeature(featureId); |
| 72 | if (cudaFeature.IsEmpty(dev)) { |
| 73 | continue; |
| 74 | } |
| 75 | auto feature = cudaFeature.At(dev); |
| 76 | // const ui32 featureId = dataSet.GetFeatureId(f); |
| 77 | TSlice docsSlice = dataSet.GetSamplesMapping().DeviceSlice(dev); |
| 78 | |
| 79 | TVector<ui32> bins; |
| 80 | |
| 81 | ui32 binarization = 0; |
| 82 |
no test coverage detected