| 179 | } |
| 180 | |
| 181 | void TestTreeBuilder(ui32 binarization, |
| 182 | ui32 permutationCount, |
| 183 | ui32 seed = 0) { |
| 184 | TRandom random(seed); |
| 185 | TBinarizedPool pool; |
| 186 | |
| 187 | const ui32 numCatFeatures = 7; |
| 188 | GenerateTestPool(pool, binarization, numCatFeatures); |
| 189 | |
| 190 | SavePoolToFile(pool, "test-pool.txt"); |
| 191 | SavePoolCDToFile("test-pool.txt.cd", numCatFeatures); |
| 192 | |
| 193 | NCatboostOptions::TBinarizationOptions floatBinarization(EBorderSelectionType::GreedyLogSum, binarization); |
| 194 | NCatboostOptions::TCatFeatureParams catFeatureParams(ETaskType::GPU); |
| 195 | catFeatureParams.MaxTensorComplexity = 3; |
| 196 | catFeatureParams.OneHotMaxSize = 6; |
| 197 | { |
| 198 | TVector<TVector<float>> prior = {{0.5, 1.0}}; |
| 199 | NCatboostOptions::TCtrDescription bucketsCtr(ECtrType::Buckets, prior); |
| 200 | NCatboostOptions::TCtrDescription freqCtr(ECtrType::FeatureFreq, prior); |
| 201 | catFeatureParams.AddSimpleCtrDescription(bucketsCtr); |
| 202 | catFeatureParams.AddSimpleCtrDescription(freqCtr); |
| 203 | |
| 204 | catFeatureParams.AddTreeCtrDescription(bucketsCtr); |
| 205 | catFeatureParams.AddTreeCtrDescription(freqCtr); |
| 206 | } |
| 207 | |
| 208 | NCB::TOnCpuGridBuilderFactory gridBuilderFactory; |
| 209 | |
| 210 | NCB::TTrainingDataProviderPtr dataProvider; |
| 211 | THolder<TBinarizedFeaturesManager> featuresManager; |
| 212 | NCB::TFeatureEstimators estimators; |
| 213 | LoadTrainingData(NCB::TPathWithScheme("dsv://test-pool.txt"), |
| 214 | NCB::TPathWithScheme("dsv://test-pool.txt.cd"), |
| 215 | floatBinarization, |
| 216 | catFeatureParams, |
| 217 | estimators, |
| 218 | &dataProvider, |
| 219 | &featuresManager); |
| 220 | |
| 221 | TFeatureParallelDataSetHoldersBuilder dataSetsHolderBuilder(*featuresManager, |
| 222 | *dataProvider, |
| 223 | estimators |
| 224 | ); |
| 225 | |
| 226 | auto dataSet = dataSetsHolderBuilder.BuildDataSet(permutationCount, &NPar::LocalExecutor()); |
| 227 | |
| 228 | TVector<ui32> oneHotIds; |
| 229 | TVector<ui32> catIds; |
| 230 | TVector<ui32> binaryIds; |
| 231 | TVector<ui32> floatIds; |
| 232 | for (ui32 id : featuresManager->GetCatFeatureIds()) { |
| 233 | if (featuresManager->UseForOneHotEncoding(id)) { |
| 234 | oneHotIds.push_back(id); |
| 235 | } else if (featuresManager->UseForCtr(id)) { |
| 236 | catIds.push_back(id); |
| 237 | } |
| 238 | } |
no test coverage detected