From 8386431e77fa527db26d2c0e63c3e1267abdc76d Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sun, 31 May 2026 21:09:18 +0200 Subject: [PATCH] fix: explicit NegWeightTreatment=Pray for BoostType=Grad in TMVA angular training BoostType=Grad does not support InverseBoostNegWeights (TMVA's global default for BDT), which caused TMVA to silently replace it with Pray, making the effective training configuration differ from the nominal one. Explicitly setting NegWeightTreatment=Pray in the default options string eliminates the silent substitution and ensures the logged configuration matches actual training behaviour. Fixes: VERITAS-Observatory/EventDisplay_v4#352 (item from mvaAngRes log) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/changes/353.bugfix.md | 7 +++++++ src/trainTMVAforAngularReconstruction.cpp | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 docs/changes/353.bugfix.md diff --git a/docs/changes/353.bugfix.md b/docs/changes/353.bugfix.md new file mode 100644 index 000000000..14b2bfb55 --- /dev/null +++ b/docs/changes/353.bugfix.md @@ -0,0 +1,7 @@ +# Bug fix: explicit NegWeightTreatment for TMVA Gradient BDT angular reconstruction + +Added `NegWeightTreatment=Pray` to the default TMVA options in +`trainTMVAforAngularReconstruction` to match actual TMVA behaviour: +`BoostType=Grad` does not support `InverseBoostNegWeights` (TMVA's global +default) and silently replaces it with `Pray`; the options string now +declares this explicitly so the training configuration matches what is used. diff --git a/src/trainTMVAforAngularReconstruction.cpp b/src/trainTMVAforAngularReconstruction.cpp index f7d37f1f8..015a95a80 100644 --- a/src/trainTMVAforAngularReconstruction.cpp +++ b/src/trainTMVAforAngularReconstruction.cpp @@ -878,8 +878,10 @@ int main( int argc, char* argv[] ) iQualityCut = argv[7]; } // TMVA options (default options derived from hyperparameter optimisation on CTAO prod3 simulations) + // NegWeightTreatment=Pray is explicit here: BoostType=Grad does not support + // InverseBoostNegWeights (TMVA's global default) and silently replaces it with Pray. string iTMVAOptions = "NTrees=100:BoostType=Grad:Shrinkage=0.1:UseBaggedBoost:GradBaggingFraction=0.5:nCuts=20:MaxDepth=10:"; - iTMVAOptions += "PruneMethod=ExpectedError:RegressionLossFunctionBDTG=Huber:MinNodeSize=0.02:VarTransform=N"; + iTMVAOptions += "PruneMethod=ExpectedError:RegressionLossFunctionBDTG=Huber:MinNodeSize=0.02:NegWeightTreatment=Pray:VarTransform=N"; if( argc >= 9 ) { iTMVAOptions = argv[8];