| 159 | } |
| 160 | |
| 161 | static 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 | |
| 190 | TVector<TFeaturePairInteractionInfo> CalcMostInteractingFeatures(const TVector<TMxTree>& trees, |
| 191 | int topPairsCount) { |
no test coverage detected