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

Function PostProcessSumInteractions

catboost/libs/fstr/feature_str.cpp:161–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161static TVector<TFeaturePairInteractionInfo> PostProcessSumInteractions(
162 THashMap<std::pair<int, int>, double>& sumInteractions,
163 int featureCount,
164 int topPairsCount) {
165
166 TVector<TFeaturePairInteractionInfo> pairsInfo;
167
168 if (topPairsCount == EXISTING_PAIRS_COUNT) {
169 for (const auto& pairInteraction : sumInteractions) {
170 pairsInfo.push_back(TFeaturePairInteractionInfo(sumInteractions[pairInteraction.first],
171 pairInteraction.first.first, pairInteraction.first.second));
172 }
173 } else {
174 for (int firstIdx = 0; firstIdx < featureCount; ++firstIdx) {
175 for (int secondIdx = firstIdx + 1; secondIdx < featureCount; ++secondIdx) {
176 pairsInfo.push_back(TFeaturePairInteractionInfo(sumInteractions[std::make_pair(firstIdx, secondIdx)],
177 firstIdx, secondIdx));
178 }
179 }
180 }
181
182 std::sort(pairsInfo.rbegin(), pairsInfo.rend());
183 if (topPairsCount != EXISTING_PAIRS_COUNT && pairsInfo.ysize() > topPairsCount) {
184 pairsInfo.resize(topPairsCount);
185 }
186
187 return pairsInfo;
188}
189
190TVector<TFeaturePairInteractionInfo> CalcMostInteractingFeatures(const TVector<TMxTree>& trees,
191 int topPairsCount) {

Callers 1

Calls 7

sortFunction · 0.50
push_backMethod · 0.45
rbeginMethod · 0.45
rendMethod · 0.45
ysizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected