TMVA Variable Rank from Weights File

Greetings all,

I’ve been trying to use the weights file to reproduce the variable rankings printed when training a BDT classifier (using TMVA 4.0.4). I’m not convinced that this is possible, but it seems like something like this should work (in pseudo-code):

tmvaFactory->TrainAllMethods();
TMVA::IMethod* method = tmvaFactory->GetMethod( “myBDT” );
const TMVA::Ranking* ranking = method->CreateRanking();
ranking->Print();

However, when I do this, I get “nan” printed for the importance of all my variables. As far as I can tell, there is nothing wrong with the weights file and calls to TestAllMethods() and EvaluateAllMethods() give reasonable output. I’ve included a snippet of the full output below.

Thanks for any help,
Alex

P.S. - It looks like a similar thread was posted [url=https://root-forum.cern.ch/t/variable-ranking-after-models-have-been-generated/12359/1 though it may have gotten lost in the mix.

— Factory : Training finished
— Factory :
— Factory : Begin ranking of input variables…
— BDT : Ranking result (top variable is best ranked)
— BDT : --------------------------------------
— BDT : Rank : Variable : Variable Importance
— BDT : --------------------------------------
— BDT : 1 : var4 : 5.640e-01
— BDT : 2 : var3 : 1.538e-01
— BDT : 3 : var2 : 1.495e-01
— BDT : 4 : var1 : 1.327e-01
— BDT : --------------------------------------
— Factory :
— Factory : === Destroy and recreate all methods via weight files for testing ===
— Factory :
— MethodBase : Reading weight file: ./tutorial01.d/weights/TMVA_node_1000_BDT.weights.xml
— BDT : Read method “BDT” of type “BDT”
— BDT : MVA method was trained with TMVA Version: 4.0.4
— BDT : MVA method was trained with ROOT Version: 5.26/00
— BDT : Ranking result (top variable is best ranked)
— BDT : --------------------------------------
— BDT : Rank : Variable : Variable Importance
— BDT : --------------------------------------
— BDT : 1 : var1 : nan
— BDT : 2 : var2 : nan
— BDT : 3 : var3 : nan
— BDT : 4 : var4 : nan
— BDT : --------------------------------------

Below is a reply from Helge Voss to a post on the TMVA users list. It appears that this inform is indeed lost after training.


Hi Alex,

well this doesn’t work because at the end of the training, after the
weight files
have been written, the actual BDT is deleted and then later re-created from the
weight files. Doing this you lose the information from the training
which was used
to calculate the “ranking”, as for the application later this is not
relevant, and hence
not stored in the weight files.

                      Helge