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

Function CalcInternalFeatureInteraction

catboost/libs/fstr/calc_fstr.cpp:314–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314TVector<TInternalFeatureInteraction> CalcInternalFeatureInteraction(const TFullModel& model) {
315 if (model.GetTreeCount() == 0) {
316 return TVector<TInternalFeatureInteraction>();
317 }
318 CB_ENSURE_SCALE_IDENTITY(model.GetScaleAndBias(), "feature interaction");
319
320 TVector<TFeature> features;
321 THashMap<TFeature, int, TFeatureHash> featureToIdx = GetFeatureToIdxMap(model, &features);
322
323 TVector<TFeaturePairInteractionInfo> pairwiseEffect;
324
325 if (model.IsOblivious()) {
326 TVector<TMxTree> trees = BuildTrees(featureToIdx, model);
327 pairwiseEffect = CalcMostInteractingFeatures(trees);
328 } else {
329 pairwiseEffect = CalcMostInteractingFeatures(
330 model,
331 featureToIdx
332 );
333 }
334
335 TVector<TInternalFeatureInteraction> result;
336 result.reserve(pairwiseEffect.size());
337 for (const auto& efffect : pairwiseEffect) {
338 result.emplace_back(efffect.Score, features[efffect.Feature1], features[efffect.Feature2]);
339 }
340 return result;
341}
342
343TVector<TFeatureInteraction> CalcFeatureInteraction(
344 const TVector<TInternalFeatureInteraction>& internalFeatureInteraction,

Callers 3

CalcInteractionFunction · 0.85
CalcInteractionFunction · 0.85
CalcAndOutputInteractionFunction · 0.85

Calls 8

GetFeatureToIdxMapFunction · 0.85
BuildTreesFunction · 0.85
GetTreeCountMethod · 0.45
IsObliviousMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected