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

Method UpdateBestSplit

catboost/cuda/methods/tree_ctr_datasets_visitor.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 }
60
61 void TTreeCtrDataSetVisitor::UpdateBestSplit(const TTreeCtrDataSet& dataSet, const TMirrorBuffer<ui32>& inverseIndices,
62 const TBestSplitProperties& bestSplitProperties) {
63 const ui32 dev = dataSet.GetCompressedDataSet().GetSamplesMapping().GetDeviceId();
64
65 { //we don't need complex logic here. this should be pretty fast
66 bool shouldReturn = false;
67 with_lock (Lock) {
68 if (bestSplitProperties.Gain < BestGain) {
69 BestScore = bestSplitProperties.Score;
70 BestGain = bestSplitProperties.Gain;
71 BestBin = bestSplitProperties.BinId;
72 BestDevice = dev;
73 BestCtr = dataSet.GetCtrs()[bestSplitProperties.FeatureId];
74 } else {
75 shouldReturn = true;
76 }
77 }
78 if (shouldReturn) {
79 return;
80 }
81 }
82
83 {
84 const ui32 featureId = bestSplitProperties.FeatureId;
85 const ui32 binId = bestSplitProperties.BinId;
86
87 const auto& ctr = dataSet.GetCtrs()[featureId];
88 const ui32 compressedSize = CompressedSize<ui64>(static_cast<ui32>(inverseIndices.GetObjectsSlice().Size()), 2);
89 BestSplits[dev].Reset(NCudaLib::TSingleMapping(dev, compressedSize));
90 const auto devInverseIndices = inverseIndices.ConstDeviceView(dev);
91 auto& binarizedDataSet = dataSet.GetCompressedDataSet();
92
93 CreateCompressedSplit(binarizedDataSet,
94 binarizedDataSet.GetTCFeature(featureId),
95 binId,
96 BestSplits[dev],
97 &devInverseIndices);
98
99 if (!FeaturesManager.IsKnown(ctr)) {
100 BestBorders[dev] = dataSet.ReadBorders(featureId);
101 }
102 }
103 }
104
105 void TTreeCtrDataSetVisitor::CacheCtrBorders(const TMap<TCtr, TVector<float>>& bordersMap) {
106 for (auto& entry : bordersMap) {

Callers

nothing calls this directly

Calls 9

CreateCompressedSplitFunction · 0.85
ConstDeviceViewMethod · 0.80
IsKnownMethod · 0.80
ReadBordersMethod · 0.80
TSingleMappingClass · 0.50
GetDeviceIdMethod · 0.45
SizeMethod · 0.45
GetObjectsSliceMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected