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

Function CalcShapValuesForDocumentBlockMulti

catboost/libs/fstr/shap_values.cpp:1081–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1079}
1080
1081static void CalcShapValuesForDocumentBlockMulti(
1082 const TFullModel& model,
1083 const IFeaturesBlockIterator& featuresBlockIterator,
1084 int flatFeatureCount,
1085 const TShapPreparedTrees& preparedTrees,
1086 const TMaybe<TFixedFeatureParams>& fixedFeatureParams,
1087 size_t start,
1088 size_t end,
1089 NPar::ILocalExecutor* localExecutor,
1090 TVector<TVector<TVector<double>>>* shapValuesForAllDocuments,
1091 ECalcTypeShapValues calcType
1092) {
1093 const size_t documentCount = end - start;
1094
1095 auto binarizedFeaturesForBlock = MakeQuantizedFeaturesForEvaluator(model, featuresBlockIterator, start, end);
1096
1097 TVector<NModelEvaluation::TCalcerIndexType> indices(binarizedFeaturesForBlock->GetObjectsCount() * model.GetTreeCount());
1098 model.GetCurrentEvaluator()->CalcLeafIndexes(binarizedFeaturesForBlock.Get(), 0, model.GetTreeCount(), indices);
1099
1100 const int oldShapValuesSize = shapValuesForAllDocuments->size();
1101 shapValuesForAllDocuments->resize(oldShapValuesSize + end - start);
1102
1103 NPar::ILocalExecutor::TExecRangeParams blockParams(0, documentCount);
1104 localExecutor->ExecRange([&] (size_t documentIdxInBlock) {
1105 TVector<TVector<double>>& shapValues = (*shapValuesForAllDocuments)[oldShapValuesSize + documentIdxInBlock];
1106
1107 CalcShapValuesForDocumentMulti(
1108 model,
1109 preparedTrees,
1110 binarizedFeaturesForBlock.Get(),
1111 fixedFeatureParams,
1112 flatFeatureCount,
1113 MakeArrayRef(indices.data() + documentIdxInBlock * model.GetTreeCount(), model.GetTreeCount()),
1114 documentIdxInBlock,
1115 &shapValues,
1116 calcType,
1117 /*documentIdx*/ documentIdxInBlock + start
1118 );
1119
1120 }, blockParams, NPar::TLocalExecutor::WAIT_COMPLETE);
1121}
1122
1123static void CalcShapValuesByLeafForTreeBlock(
1124 const TModelTrees& forest,

Callers 2

CalcAndOutputShapValuesFunction · 0.85

Calls 12

MakeArrayRefFunction · 0.85
GetObjectsCountMethod · 0.80
GetCurrentEvaluatorMethod · 0.80
GetTreeCountMethod · 0.45
CalcLeafIndexesMethod · 0.45
GetMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
ExecRangeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected