133 #pragma warning ( disable : 4355 )
150 fAnalysisType (
Types::kNoAnalysisType ),
151 fRegressionReturnVal ( 0 ),
152 fMulticlassReturnVal ( 0 ),
153 fDisableWriting (
kFALSE ),
154 fDataSetInfo ( dsi ),
155 fSignalReferenceCut ( 0.5 ),
156 fSignalReferenceCutOrientation( 1. ),
157 fVariableTransformType (
Types::kSignal ),
158 fJobName ( jobName ),
159 fMethodName ( methodTitle ),
160 fMethodType ( methodType ),
164 fConstructedFromWeightFile (
kFALSE ),
166 fMethodBaseDir ( theBaseDir ),
177 fSplTrainEffBvsS ( 0 ),
178 fVarTransformString (
"None" ),
179 fTransformationPointer ( 0 ),
180 fTransformation ( dsi, methodTitle ),
182 fVerbosityLevelString (
"Default" ),
185 fIgnoreNegWeightsInTraining(
kFALSE ),
187 fBackgroundClass ( 0 ),
214 fAnalysisType (
Types::kNoAnalysisType ),
215 fRegressionReturnVal ( 0 ),
216 fMulticlassReturnVal ( 0 ),
217 fDataSetInfo ( dsi ),
218 fSignalReferenceCut ( 0.5 ),
219 fVariableTransformType (
Types::kSignal ),
221 fMethodName (
"MethodBase" ),
222 fMethodType ( methodType ),
224 fTMVATrainingVersion ( 0 ),
225 fROOTTrainingVersion ( 0 ),
226 fConstructedFromWeightFile ( kTRUE ),
227 fBaseDir ( theBaseDir ),
228 fMethodBaseDir ( 0 ),
229 fWeightFile ( weightFile ),
239 fSplTrainEffBvsS ( 0 ),
240 fVarTransformString (
"None" ),
241 fTransformationPointer ( 0 ),
242 fTransformation ( dsi,
"" ),
244 fVerbosityLevelString (
"Default" ),
247 fIgnoreNegWeightsInTraining(
kFALSE ),
249 fBackgroundClass ( 0 ),
263 if (!fSetupCompleted)
Log() <<
kFATAL <<
"Calling destructor of method which got never setup" <<
Endl;
266 if (fInputVars != 0) { fInputVars->clear();
delete fInputVars; }
267 if (fRanking != 0)
delete fRanking;
270 if (fDefaultPDF!= 0) {
delete fDefaultPDF; fDefaultPDF = 0; }
271 if (fMVAPdfS != 0) {
delete fMVAPdfS; fMVAPdfS = 0; }
272 if (fMVAPdfB != 0) {
delete fMVAPdfB; fMVAPdfB = 0; }
275 if (fSplS) {
delete fSplS; fSplS = 0; }
276 if (fSplB) {
delete fSplB; fSplB = 0; }
277 if (fSpleffBvsS) {
delete fSpleffBvsS; fSpleffBvsS = 0; }
278 if (fSplRefS) {
delete fSplRefS; fSplRefS = 0; }
279 if (fSplRefB) {
delete fSplRefB; fSplRefB = 0; }
280 if (fSplTrainRefS) {
delete fSplTrainRefS; fSplTrainRefS = 0; }
281 if (fSplTrainRefB) {
delete fSplTrainRefB; fSplTrainRefB = 0; }
282 if (fSplTrainEffBvsS) {
delete fSplTrainEffBvsS; fSplTrainEffBvsS = 0; }
284 for (
Int_t i = 0; i < 2; i++ ) {
285 if (fEventCollections.at(i)) {
286 for (std::vector<Event*>::const_iterator it = fEventCollections.at(i)->begin();
287 it != fEventCollections.at(i)->end(); it++) {
290 delete fEventCollections.at(i);
291 fEventCollections.at(i) = 0;
295 if (fRegressionReturnVal)
delete fRegressionReturnVal;
296 if (fMulticlassReturnVal)
delete fMulticlassReturnVal;
304 if (fSetupCompleted)
Log() <<
kFATAL <<
"Calling SetupMethod for the second time" <<
Endl;
306 DeclareBaseOptions();
309 fSetupCompleted =
kTRUE;
319 ProcessBaseOptions();
329 CheckForUnusedOptions();
337 SetConfigDescription(
"Configuration options for classifier architecture and tuning" );
345 fSplTrainEffBvsS = 0;
352 fTxtWeightsOnly =
kTRUE;
362 fInputVars =
new std::vector<TString>;
363 for (
UInt_t ivar=0; ivar<GetNvar(); ivar++) {
364 fInputVars->push_back(DataInfo().GetVariableInfo(ivar).GetLabel());
366 fRegressionReturnVal = 0;
367 fMulticlassReturnVal = 0;
369 fEventCollections.resize( 2 );
370 fEventCollections.at(0) = 0;
371 fEventCollections.at(1) = 0;
377 if (DataInfo().GetClassInfo(
"Signal") != 0) {
378 fSignalClass = DataInfo().GetClassInfo(
"Signal")->GetNumber();
380 if (DataInfo().GetClassInfo(
"Background") != 0) {
381 fBackgroundClass = DataInfo().GetClassInfo(
"Background")->GetNumber();
384 SetConfigDescription(
"Configuration options for MVA method" );
385 SetConfigName(
TString(
"Method") + GetMethodTypeName() );
405 DeclareOptionRef( fVerbose,
"V",
"Verbose output (short form of \"VerbosityLevel\" below - overrides the latter one)" );
407 DeclareOptionRef( fVerbosityLevelString=
"Default",
"VerbosityLevel",
"Verbosity level" );
408 AddPreDefVal(
TString(
"Default") );
409 AddPreDefVal(
TString(
"Debug") );
410 AddPreDefVal(
TString(
"Verbose") );
411 AddPreDefVal(
TString(
"Info") );
412 AddPreDefVal(
TString(
"Warning") );
413 AddPreDefVal(
TString(
"Error") );
414 AddPreDefVal(
TString(
"Fatal") );
418 fTxtWeightsOnly =
kTRUE;
421 DeclareOptionRef( fVarTransformString,
"VarTransform",
"List of variable transformations performed before training, e.g., \"D_Background,P_Signal,G,N_AllClasses\" for: \"Decorrelation, PCA-transformation, Gaussianisation, Normalisation, each for the given class of events ('AllClasses' denotes all events of all classes, if no class indication is given, 'All' is assumed)\"" );
423 DeclareOptionRef( fHelp,
"H",
"Print method-specific help message" );
425 DeclareOptionRef( fHasMVAPdfs,
"CreateMVAPdfs",
"Create PDFs for classifier outputs (signal and background)" );
427 DeclareOptionRef( fIgnoreNegWeightsInTraining,
"IgnoreNegWeightsInTraining",
428 "Events with negative weights are ignored in the training (but are included for testing and performance evaluation)" );
440 fDefaultPDF =
new PDF(
TString(GetName())+
"_PDF", GetOptions(),
"MVAPdf" );
441 fDefaultPDF->DeclareOptions();
442 fDefaultPDF->ParseOptions();
443 fDefaultPDF->ProcessOptions();
444 fMVAPdfB =
new PDF(
TString(GetName())+
"_PDFBkg", fDefaultPDF->GetOptions(),
"MVAPdfBkg", fDefaultPDF );
446 fMVAPdfB->ParseOptions();
447 fMVAPdfB->ProcessOptions();
448 fMVAPdfS =
new PDF(
TString(GetName())+
"_PDFSig", fMVAPdfB->GetOptions(),
"MVAPdfSig", fDefaultPDF );
450 fMVAPdfS->ParseOptions();
451 fMVAPdfS->ProcessOptions();
454 SetOptions( fMVAPdfS->GetOptions() );
459 GetTransformationHandler(),
463 if (fDefaultPDF!= 0) {
delete fDefaultPDF; fDefaultPDF = 0; }
464 if (fMVAPdfS != 0) {
delete fMVAPdfS; fMVAPdfS = 0; }
465 if (fMVAPdfB != 0) {
delete fMVAPdfB; fMVAPdfB = 0; }
469 fVerbosityLevelString =
TString(
"Verbose");
472 else if (fVerbosityLevelString ==
"Debug" )
Log().SetMinType(
kDEBUG );
473 else if (fVerbosityLevelString ==
"Verbose" )
Log().SetMinType(
kVERBOSE );
474 else if (fVerbosityLevelString ==
"Info" )
Log().SetMinType(
kINFO );
475 else if (fVerbosityLevelString ==
"Warning" )
Log().SetMinType(
kWARNING );
476 else if (fVerbosityLevelString ==
"Error" )
Log().SetMinType(
kERROR );
477 else if (fVerbosityLevelString ==
"Fatal" )
Log().SetMinType(
kFATAL );
478 else if (fVerbosityLevelString !=
"Default" ) {
479 Log() <<
kFATAL <<
"<ProcessOptions> Verbosity level type '"
480 << fVerbosityLevelString <<
"' unknown." <<
Endl;
493 TString trafoDefinition(trafoDefinitionIn);
494 if (trafoDefinition ==
"None")
return;
498 TString trafoDefinitionCheck(trafoDefinitionIn);
499 int npartial = 0, ntrafo=0;
500 for (
Int_t pos = 0, siz = trafoDefinition.
Sizeof(); pos < siz; ++pos) {
501 TString ch = trafoDefinition(pos,1);
502 if ( ch ==
"(" ) npartial++;
503 if ( ch ==
"+" || ch ==
",") ntrafo++;
506 log <<
kWARNING <<
"The use of multiple partial variable transformations during the application phase can be properly invoked via the \"Reader\", but it is not yet implemented in \"MakeClass\", the creation mechanism for standalone C++ application classes. The standalone C++ class produced by this training job is thus INCOMPLETE AND MUST NOT BE USED! The transformation in question is: " << trafoDefinitionIn <<
Endl;
514 Int_t parenthesisCount = 0;
515 for (
Int_t position = 0, size = trafoDefinition.
Sizeof(); position < size; ++position) {
516 TString ch = trafoDefinition(position,1);
517 if (ch ==
"(") ++parenthesisCount;
518 else if (ch ==
")") --parenthesisCount;
519 else if (ch ==
"," && parenthesisCount == 0) trafoDefinition.
Replace(position,1,
'+');
525 TString tdef = os->GetString();
531 Ssiz_t parLen = tdef.
Index(
")", parStart )-parStart+1;
533 variables = tdef(parStart,parLen);
534 tdef.
Remove(parStart,parLen);
535 variables.
Remove(parLen-1,1);
541 if (trClsList->
GetSize() < 1) log <<
kFATAL <<
"Incorrect transformation string provided." <<
Endl;
548 if (trCls !=
"AllClasses") {
551 log <<
kFATAL <<
"Class " << trCls <<
" not known for variable transformation "
552 << trName <<
", please check." <<
Endl;
559 if (trName ==
"I" || trName ==
"Ident" || trName ==
"Identity") {
560 if (variables.
Length() == 0) variables =
"_V_";
563 else if (trName ==
"D" || trName ==
"Deco" || trName ==
"Decorrelate") {
564 if (variables.
Length() == 0) variables =
"_V_";
567 else if (trName ==
"P" || trName ==
"PCA") {
568 if (variables.
Length() == 0) variables =
"_V_";
571 else if (trName ==
"U" || trName ==
"Uniform") {
572 if (variables.
Length() == 0) variables =
"_V_,_T_";
575 else if (trName ==
"G" || trName ==
"Gauss") {
576 if (variables.
Length() == 0) variables =
"_V_";
579 else if (trName ==
"N" || trName ==
"Norm" || trName ==
"Normalise" || trName ==
"Normalize") {
580 if (variables.
Length() == 0) variables =
"_V_,_T_";
583 else log <<
kFATAL <<
"<ProcessOptions> Variable transform '"
584 << trName <<
"' unknown." <<
Endl;
586 if (transformation) {
589 log <<
kINFO <<
"Create Transformation \"" << trName <<
"\" with reference class "
590 << clsInfo->
GetName() <<
"=("<< idxCls <<
")"<<
Endl;
592 log <<
kINFO <<
"Create Transformation \"" << trName <<
"\" with events from all classes." <<
Endl;
608 DeclareOptionRef( fNormalise=
kFALSE,
"Normalise",
"Normalise input variables" );
609 DeclareOptionRef( fUseDecorr=
kFALSE,
"D",
"Use-decorrelated-variables flag" );
610 DeclareOptionRef( fVariableTransformTypeString=
"Signal",
"VarTransformType",
611 "Use signal or background events to derive for variable transformation (the transformation is applied on both types of, course)" );
612 AddPreDefVal(
TString(
"Signal") );
613 AddPreDefVal(
TString(
"Background") );
614 DeclareOptionRef( fTxtWeightsOnly=kTRUE,
"TxtWeightFilesOnly",
"If True: write all training results (weights) as text files (False: some are written in ROOT format)" );
624 DeclareOptionRef( fNbinsMVAPdf = 60,
"NbinsMVAPdf",
"Number of bins used for the PDFs of classifier outputs" );
625 DeclareOptionRef( fNsmoothMVAPdf = 2,
"NsmoothMVAPdf",
"Number of smoothing iterations for classifier PDFs" );
639 Log() <<
kWARNING <<
"Parameter optimization is not yet implemented for method "
640 << GetName() <<
Endl;
641 Log() <<
kWARNING <<
"Currently we need to set hardcoded which parameter is tuned in which ranges"<<
Endl;
643 std::map<TString,Double_t> tunedParameters;
644 tunedParameters.size();
645 return tunedParameters;
666 if (Help()) PrintHelpMessage();
673 GetTransformationHandler().CalcTransformations(
Data()->GetEventCollection());
678 Timer traintimer( nEvents, GetName(), kTRUE );
682 Log() <<
kINFO <<
"Elapsed time for training with " << nEvents <<
" events: "
685 Log() <<
kINFO <<
"Create MVA output for ";
688 if (DoMulticlass()) {
689 Log() <<
"Multiclass classification on training sample" <<
Endl;
692 else if (!DoRegression()) {
694 Log() <<
"classification on training sample" <<
Endl;
703 Log() <<
"regression on training sample" <<
Endl;
707 Log() <<
"Create PDFs" <<
Endl;
714 if (!fDisableWriting ) WriteStateToFile();
717 if ((!DoRegression()) && (!fDisableWriting)) MakeClass();
722 WriteMonitoringHistosToFile();
729 if (!DoRegression())
Log() <<
kFATAL <<
"Trying to use GetRegressionDeviation() with a classification job" <<
Endl;
732 bool truncate =
false;
733 TH1F*
h1 = regRes->QuadraticDeviation( tgtNum , truncate, 1.);
738 TH1F*
h2 = regRes->QuadraticDeviation( tgtNum , truncate, yq[0]);
749 Data()->SetCurrentType(type);
763 regRes->Resize( nEvents );
765 Data()->SetCurrentEvent(ievt);
766 std::vector< Float_t > vals = GetRegressionValues();
767 regRes->SetValue( vals, ievt );
771 Log() <<
kINFO <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
778 TString histNamePrefix(GetTestvarName());
780 regRes->CreateDeviationHistograms( histNamePrefix );
788 Data()->SetCurrentType(type);
793 if (!resMulticlass)
Log() <<
kFATAL<<
"unable to create pointer in AddMulticlassOutput, exiting."<<
Endl;
803 resMulticlass->Resize( nEvents );
805 Data()->SetCurrentEvent(ievt);
806 std::vector< Float_t > vals = GetMulticlassValues();
807 resMulticlass->SetValue( vals, ievt );
811 Log() <<
kINFO <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
818 TString histNamePrefix(GetTestvarName());
820 resMulticlass->CreateMulticlassHistos( histNamePrefix, fNbinsMVAoutput, fNbinsH );
829 if (errUpper) *errUpper=-1;
836 Double_t val = GetMvaValue(err, errUpper);
846 return GetMvaValue()*GetSignalReferenceCutOrientation() > GetSignalReferenceCut()*GetSignalReferenceCutOrientation() ? kTRUE :
kFALSE;
853 return mvaVal*GetSignalReferenceCutOrientation() > GetSignalReferenceCut()*GetSignalReferenceCutOrientation() ? kTRUE :
kFALSE;
861 Data()->SetCurrentType(type);
872 << (type==
Types::kTraining?
"training":
"testing") <<
" sample (" << nEvents <<
" events)" <<
Endl;
876 Data()->SetCurrentEvent(ievt);
877 clRes->
SetValue( GetMvaValue(), ievt );
881 if (modulo <= 0 ) modulo = 1;
885 Log() <<
kINFO <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
899 Data()->SetCurrentType(type);
912 mvaProb->
Resize( nEvents );
915 Data()->SetCurrentEvent(ievt);
917 if (proba < 0)
break;
922 if (modulo <= 0 ) modulo = 1;
926 Log() <<
kINFO <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
946 Data()->SetCurrentType(type);
948 bias = 0; biasT = 0; dev = 0; devT = 0; rms = 0; rmsT = 0;
951 const Int_t nevt = GetNEvents();
956 for (
Long64_t ievt=0; ievt<nevt; ievt++) {
958 const Event* ev =
Data()->GetEvent(ievt);
961 Float_t r = GetRegressionValues()[0];
980 m1 += t*
w;
s1 += t*t*
w;
981 m2 += r*
w;
s2 += r*r*
w;
994 corr = s12/sumw - m1*m2;
998 TH2F* hist =
new TH2F(
"hist",
"hist", 150, xmin, xmax, 100, xmin, xmax );
999 TH2F* histT =
new TH2F(
"histT",
"histT", 150, xmin, xmax, 100, xmin, xmax );
1006 for (
Long64_t ievt=0; ievt<nevt; ievt++) {
1008 hist->
Fill( rV[ievt], tV[ievt], wV[ievt] );
1009 if (d >= devMin && d <= devMax) {
1011 biasT += wV[ievt] *
d;
1013 rmsT += wV[ievt] * d *
d;
1014 histT->
Fill( rV[ievt], tV[ievt], wV[ievt] );
1032 Data()->SetCurrentType(savedType);
1042 if (!resMulticlass)
Log() <<
kFATAL<<
"unable to create pointer in TestMulticlass, exiting."<<
Endl;
1043 Log() <<
kINFO <<
"Determine optimal multiclass cuts for test data..." <<
Endl;
1044 for (
UInt_t icls = 0; icls<DataInfo().GetNClasses(); ++icls) {
1061 if (0==mvaRes && !(GetMethodTypeName().Contains(
"Cuts"))) {
1062 Log() <<
"mvaRes " << mvaRes <<
" GetMethodTypeName " << GetMethodTypeName()
1063 <<
" contains " << !(GetMethodTypeName().Contains(
"Cuts")) <<
Endl;
1064 Log() <<
kFATAL <<
"<TestInit> Test variable " << GetTestvarName()
1065 <<
" not found in tree" <<
Endl;
1070 fMeanS, fMeanB, fRmsS, fRmsB, fXmin, fXmax, fSignalClass );
1078 fCutOrientation = (fMeanS > fMeanB) ? kPositive : kNegative;
1087 TH1* mva_s =
new TH1D( GetTestvarName() +
"_S",GetTestvarName() +
"_S", fNbinsMVAoutput, fXmin, sxmax );
1088 TH1* mva_b =
new TH1D( GetTestvarName() +
"_B",GetTestvarName() +
"_B", fNbinsMVAoutput, fXmin, sxmax );
1089 mvaRes->
Store(mva_s,
"MVA_S");
1090 mvaRes->
Store(mva_b,
"MVA_B");
1100 proba_s =
new TH1D( GetTestvarName() +
"_Proba_S", GetTestvarName() +
"_Proba_S", fNbinsMVAoutput, 0.0, 1.0 );
1101 proba_b =
new TH1D( GetTestvarName() +
"_Proba_B", GetTestvarName() +
"_Proba_B", fNbinsMVAoutput, 0.0, 1.0 );
1102 mvaRes->
Store(proba_s,
"Prob_S");
1103 mvaRes->
Store(proba_b,
"Prob_B");
1108 rarity_s =
new TH1D( GetTestvarName() +
"_Rarity_S", GetTestvarName() +
"_Rarity_S", fNbinsMVAoutput, 0.0, 1.0 );
1109 rarity_b =
new TH1D( GetTestvarName() +
"_Rarity_B", GetTestvarName() +
"_Rarity_B", fNbinsMVAoutput, 0.0, 1.0 );
1110 mvaRes->
Store(rarity_s,
"Rar_S");
1111 mvaRes->
Store(rarity_b,
"Rar_B");
1117 TH1* mva_eff_s =
new TH1D( GetTestvarName() +
"_S_high", GetTestvarName() +
"_S_high", fNbinsH, fXmin, sxmax );
1118 TH1* mva_eff_b =
new TH1D( GetTestvarName() +
"_B_high", GetTestvarName() +
"_B_high", fNbinsH, fXmin, sxmax );
1119 mvaRes->
Store(mva_eff_s,
"MVA_HIGHBIN_S");
1120 mvaRes->
Store(mva_eff_b,
"MVA_HIGHBIN_B");
1128 Log() <<
kINFO <<
"Loop over test events and fill histograms with classifier response..." <<
Endl;
1129 if (mvaProb)
Log() <<
kINFO <<
"Also filling probability and rarity histograms (on request)..." <<
Endl;
1130 for (
Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
1132 const Event* ev = GetEvent(ievt);
1136 if (DataInfo().IsSignal(ev)) {
1137 mva_s ->
Fill( v, w );
1139 proba_s->
Fill( (*mvaProb)[ievt][0], w );
1140 rarity_s->
Fill( GetRarity( v ), w );
1143 mva_eff_s ->
Fill( v, w );
1146 mva_b ->
Fill( v, w );
1148 proba_b->
Fill( (*mvaProb)[ievt][0], w );
1149 rarity_b->
Fill( GetRarity( v ), w );
1151 mva_eff_b ->
Fill( v, w );
1166 if (fSplS) {
delete fSplS; fSplS = 0; }
1167 if (fSplB) {
delete fSplB; fSplB = 0; }
1181 tf << prefix <<
"#GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1182 tf << prefix <<
"Method : " << GetMethodTypeName() <<
"::" <<
GetMethodName() << std::endl;
1183 tf.setf(std::ios::left);
1184 tf << prefix <<
"TMVA Release : " << std::setw(10) << GetTrainingTMVAVersionString() <<
" ["
1185 << GetTrainingTMVAVersionCode() <<
"]" << std::endl;
1186 tf << prefix <<
"ROOT Release : " << std::setw(10) << GetTrainingROOTVersionString() <<
" ["
1187 << GetTrainingROOTVersionCode() <<
"]" << std::endl;
1188 tf << prefix <<
"Creator : " << userInfo->
fUser << std::endl;
1192 tf << prefix <<
"Training events: " <<
Data()->GetNTrainingEvents() << std::endl;
1194 TString analysisType(((const_cast<TMVA::MethodBase*>(
this)->GetAnalysisType()==
Types::kRegression) ?
"Regression" :
"Classification"));
1196 tf << prefix <<
"Analysis type : " <<
"[" << ((GetAnalysisType()==
Types::kRegression) ?
"Regression" :
"Classification") <<
"]" << std::endl;
1197 tf << prefix << std::endl;
1202 tf << prefix << std::endl << prefix <<
"#OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1203 WriteOptionsToStream( tf, prefix );
1204 tf << prefix << std::endl;
1207 tf << prefix << std::endl << prefix <<
"#VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1208 WriteVarsToStream( tf, prefix );
1209 tf << prefix << std::endl;
1226 AddRegressionOutput( type );
1228 AddMulticlassOutput( type );
1230 AddClassifierOutput( type );
1232 AddClassifierOutputProb( type );
1242 if (!parent)
return;
1247 AddInfoItem( gi,
"TMVA Release", GetTrainingTMVAVersionString() +
" [" +
gTools().StringFromInt(GetTrainingTMVAVersionCode()) +
"]" );
1248 AddInfoItem( gi,
"ROOT Release", GetTrainingROOTVersionString() +
" [" +
gTools().StringFromInt(GetTrainingROOTVersionCode()) +
"]");
1249 AddInfoItem( gi,
"Creator", userInfo->
fUser);
1253 AddInfoItem( gi,
"Training events",
gTools().StringFromInt(
Data()->GetNTrainingEvents()));
1254 AddInfoItem( gi,
"TrainingTime",
gTools().StringFromDouble(const_cast<TMVA::MethodBase*>(
this)->GetTrainTime()));
1259 AddInfoItem( gi,
"AnalysisType", analysisType );
1263 AddOptionsXMLTo( parent );
1266 AddVarsXMLTo( parent );
1269 if (!fDisableWriting)
1270 AddSpectatorsXMLTo( parent );
1273 AddClassesXMLTo(parent);
1276 if (DoRegression()) AddTargetsXMLTo(parent);
1279 GetTransformationHandler(
false).AddXMLTo( parent );
1283 if (fMVAPdfS) fMVAPdfS->AddXMLTo(pdfs);
1284 if (fMVAPdfB) fMVAPdfB->AddXMLTo(pdfs);
1287 AddWeightsXMLTo( parent );
1303 ReadWeightsFromStream( rf );
1316 TString tfname( GetWeightFileName() );
1320 Log() <<
kINFO <<
"Creating weight file in xml format: "
1326 WriteStateToXML(rootnode);
1338 TString tfname(GetWeightFileName());
1340 Log() <<
kINFO <<
"Reading weight file: "
1344 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,29,0)
1350 ReadStateFromXML(rootnode);
1355 fb.open(tfname.
Data(),std::ios::in);
1356 if (!fb.is_open()) {
1357 Log() <<
kFATAL <<
"<ReadStateFromFile> "
1358 <<
"Unable to open input weight file: " << tfname <<
Endl;
1360 std::istream fin(&fb);
1361 ReadStateFromStream(fin);
1364 if (!fTxtWeightsOnly) {
1367 Log() <<
kINFO <<
"Reading root weight file: "
1370 ReadStateFromStream( *rfile );
1378 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,00)
1381 ReadStateFromXML(rootnode);
1384 Log() <<
kFATAL <<
"Method MethodBase::ReadStateFromXMLString( const char* xmlstr = "
1385 << xmlstr <<
" ) is not available for ROOT versions prior to 5.26/00." <<
Endl;
1397 fMethodName = fullMethodName(fullMethodName.
Index(
"::")+2,fullMethodName.
Length());
1400 Log().SetSource( GetName() );
1411 if (nodeName==
"GeneralInfo") {
1416 while (antypeNode) {
1419 if (
name ==
"TrainingTime")
1422 if (
name ==
"AnalysisType") {
1428 else Log() <<
kFATAL <<
"Analysis type " << val <<
" is not known." <<
Endl;
1431 if (
name ==
"TMVA Release" ||
name ==
"TMVA") {
1435 Log() <<
kINFO <<
"MVA method was trained with TMVA Version: " << GetTrainingTMVAVersionString() <<
Endl;
1438 if (
name ==
"ROOT Release" ||
name ==
"ROOT") {
1442 Log() <<
kINFO <<
"MVA method was trained with ROOT Version: " << GetTrainingROOTVersionString() <<
Endl;
1447 else if (nodeName==
"Options") {
1448 ReadOptionsFromXML(ch);
1452 else if (nodeName==
"Variables") {
1453 ReadVariablesFromXML(ch);
1455 else if (nodeName==
"Spectators") {
1456 ReadSpectatorsFromXML(ch);
1458 else if (nodeName==
"Classes") {
1459 if (DataInfo().GetNClasses()==0) ReadClassesFromXML(ch);
1461 else if (nodeName==
"Targets") {
1462 if (DataInfo().GetNTargets()==0 && DoRegression()) ReadTargetsFromXML(ch);
1464 else if (nodeName==
"Transformations") {
1465 GetTransformationHandler().ReadFromXML(ch);
1467 else if (nodeName==
"MVAPdfs") {
1469 if (fMVAPdfS) {
delete fMVAPdfS; fMVAPdfS=0; }
1470 if (fMVAPdfB) {
delete fMVAPdfB; fMVAPdfB=0; }
1474 fMVAPdfS =
new PDF(pdfname);
1475 fMVAPdfS->ReadXML(pdfnode);
1478 fMVAPdfB =
new PDF(pdfname);
1479 fMVAPdfB->ReadXML(pdfnode);
1482 else if (nodeName==
"Weights") {
1483 ReadWeightsFromXML(ch);
1486 Log() <<
kWARNING <<
"Unparsed XML node: '" << nodeName <<
"'" <<
Endl;
1493 if (GetTransformationHandler().GetCallerName() ==
"") GetTransformationHandler().SetCallerName( GetName() );
1513 methodType = methodType(methodType.Last(
' '),methodType.Length());
1518 if (methodName ==
"") methodName = methodType;
1519 fMethodName = methodName;
1524 Log().SetSource( GetName() );
1539 ReadOptionsFromStream(fin);
1543 fin.getline(buf,512);
1545 ReadVarsFromStream(fin);
1550 if (IsNormalised()) {
1556 if ( fVarTransformString ==
"None") {
1559 }
else if ( fVarTransformString ==
"Decorrelate" ) {
1561 }
else if ( fVarTransformString ==
"PCA" ) {
1562 varTrafo = GetTransformationHandler().AddTransformation(
new VariablePCATransform(DataInfo()), -1 );
1563 }
else if ( fVarTransformString ==
"Uniform" ) {
1564 varTrafo = GetTransformationHandler().AddTransformation(
new VariableGaussTransform(DataInfo(),
"Uniform"), -1 );
1565 }
else if ( fVarTransformString ==
"Gauss" ) {
1567 }
else if ( fVarTransformString ==
"GaussDecorr" ) {
1571 Log() <<
kFATAL <<
"<ProcessOptions> Variable transform '"
1572 << fVarTransformString <<
"' unknown." <<
Endl;
1575 if (GetTransformationHandler().GetTransformationList().GetSize() > 0) {
1576 fin.getline(buf,512);
1580 varTrafo->ReadTransformationFromStream(fin, trafo );
1591 fin.getline(buf,512);
1593 if (fMVAPdfS != 0) {
delete fMVAPdfS; fMVAPdfS = 0; }
1594 if (fMVAPdfB != 0) {
delete fMVAPdfB; fMVAPdfB = 0; }
1595 fMVAPdfS =
new PDF(
TString(GetName()) +
" MVA PDF Sig");
1596 fMVAPdfB =
new PDF(
TString(GetName()) +
" MVA PDF Bkg");
1597 fMVAPdfS->SetReadingVersion( GetTrainingTMVAVersionCode() );
1598 fMVAPdfB->SetReadingVersion( GetTrainingTMVAVersionCode() );
1605 fin.getline(buf,512);
1607 fin.getline(buf,512);
1608 ReadWeightsFromStream( fin );;
1611 if (GetTransformationHandler().GetCallerName() ==
"") GetTransformationHandler().SetCallerName( GetName() );
1621 o << prefix <<
"NVar " << DataInfo().GetNVariables() << std::endl;
1622 std::vector<VariableInfo>::const_iterator varIt = DataInfo().GetVariableInfos().begin();
1623 for (; varIt!=DataInfo().GetVariableInfos().end(); varIt++) { o << prefix; varIt->WriteToStream(o); }
1624 o << prefix <<
"NSpec " << DataInfo().GetNSpectators() << std::endl;
1625 varIt = DataInfo().GetSpectatorInfos().begin();
1626 for (; varIt!=DataInfo().GetSpectatorInfos().end(); varIt++) { o << prefix; varIt->WriteToStream(o); }
1638 istr >> dummy >> readNVar;
1640 if (readNVar!=DataInfo().GetNVariables()) {
1641 Log() <<
kFATAL <<
"You declared "<< DataInfo().GetNVariables() <<
" variables in the Reader"
1642 <<
" while there are " << readNVar <<
" variables declared in the file"
1648 std::vector<VariableInfo>::iterator varIt = DataInfo().GetVariableInfos().begin();
1650 for (; varIt!=DataInfo().GetVariableInfos().end(); varIt++, varIdx++) {
1657 Log() <<
kINFO <<
"ERROR in <ReadVarsFromStream>" <<
Endl;
1658 Log() <<
kINFO <<
"The definition (or the order) of the variables found in the input file is" <<
Endl;
1659 Log() <<
kINFO <<
"is not the same as the one declared in the Reader (which is necessary for" <<
Endl;
1660 Log() <<
kINFO <<
"the correct working of the method):" <<
Endl;
1661 Log() <<
kINFO <<
" var #" << varIdx <<
" declared in Reader: " << varIt->GetExpression() <<
Endl;
1663 Log() <<
kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1676 for (
UInt_t idx=0; idx<DataInfo().GetVariableInfos().size(); idx++) {
1692 for (
UInt_t idx=0; idx<DataInfo().GetSpectatorInfos().size(); idx++) {
1694 VariableInfo& vi = DataInfo().GetSpectatorInfos()[idx];
1712 UInt_t nClasses=DataInfo().GetNClasses();
1717 for (
UInt_t iCls=0; iCls<nClasses; ++iCls) {
1718 ClassInfo *classInfo=DataInfo().GetClassInfo (iCls);
1735 for (
UInt_t idx=0; idx<DataInfo().GetTargetInfos().size(); idx++) {
1751 if (readNVar!=DataInfo().GetNVariables()) {
1752 Log() <<
kFATAL <<
"You declared "<< DataInfo().GetNVariables() <<
" variables in the Reader"
1753 <<
" while there are " << readNVar <<
" variables declared in the file"
1763 existingVarInfo = DataInfo().GetVariableInfos()[varIdx];
1768 existingVarInfo = readVarInfo;
1771 Log() <<
kINFO <<
"ERROR in <ReadVariablesFromXML>" <<
Endl;
1772 Log() <<
kINFO <<
"The definition (or the order) of the variables found in the input file is" <<
Endl;
1773 Log() <<
kINFO <<
"not the same as the one declared in the Reader (which is necessary for the" <<
Endl;
1774 Log() <<
kINFO <<
"correct working of the method):" <<
Endl;
1777 Log() <<
kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1791 if (readNSpec!=DataInfo().GetNSpectators(
kFALSE)) {
1792 Log() <<
kFATAL <<
"You declared "<< DataInfo().GetNSpectators(
kFALSE) <<
" spectators in the Reader"
1793 <<
" while there are " << readNSpec <<
" spectators declared in the file"
1803 existingSpecInfo = DataInfo().GetSpectatorInfos()[specIdx];
1808 existingSpecInfo = readSpecInfo;
1811 Log() <<
kINFO <<
"ERROR in <ReadSpectatorsFromXML>" <<
Endl;
1812 Log() <<
kINFO <<
"The definition (or the order) of the spectators found in the input file is" <<
Endl;
1813 Log() <<
kINFO <<
"not the same as the one declared in the Reader (which is necessary for the" <<
Endl;
1814 Log() <<
kINFO <<
"correct working of the method):" <<
Endl;
1817 Log() <<
kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1836 for (
UInt_t icls = 0; icls<readNCls;++icls) {
1838 DataInfo().AddClass(classname);
1846 DataInfo().AddClass(className);
1853 if (DataInfo().GetClassInfo(
"Signal") != 0) {
1854 fSignalClass = DataInfo().GetClassInfo(
"Signal")->GetNumber();
1858 if (DataInfo().GetClassInfo(
"Background") != 0) {
1859 fBackgroundClass = DataInfo().GetClassInfo(
"Background")->GetNumber();
1879 DataInfo().AddTarget(expression,
"",
"",0,0);
1891 if (fBaseDir != 0)
return fBaseDir;
1892 Log()<<
kDEBUG<<
" Base Directory for " << GetMethodTypeName() <<
" not set yet --> check if already there.." <<
Endl;
1896 Log() <<
kFATAL <<
"MethodBase::BaseDir() - MethodBaseDir() return a NULL pointer!" <<
Endl;
1917 wfilePath.Write(
"TrainingPath" );
1918 wfileName.Write(
"WeightFileName" );
1929 if (fMethodBaseDir != 0)
return fMethodBaseDir;
1931 Log()<<
kDEBUG<<
" Base Directory for " << GetMethodTypeName() <<
" not set yet --> check if already there.." <<
Endl;
1937 Log()<<
kDEBUG<<
" Base Directory for " << GetMethodTypeName() <<
" existed, return it.." <<
Endl;
1941 Log()<<
kDEBUG<<
" Base Directory for " << GetMethodTypeName() <<
" does not exist yet--> created it" <<
Endl;
1944 Log()<<
kDEBUG<<
"Return from MethodBaseDir() after creating base directory "<<
Endl;
1945 return fMethodBaseDir;
1962 fWeightFile = theWeightFile;
1970 if (fWeightFile!=
"")
return fWeightFile;
1975 TString wFileDir(GetWeightFileDir());
1976 return ( wFileDir + (wFileDir[wFileDir.
Length()-1]==
'/' ?
"" :
"/")
1989 if (0 != fMVAPdfS) {
1990 fMVAPdfS->GetOriginalHist()->Write();
1991 fMVAPdfS->GetSmoothedHist()->Write();
1992 fMVAPdfS->GetPDFHist()->Write();
1994 if (0 != fMVAPdfB) {
1995 fMVAPdfB->GetOriginalHist()->Write();
1996 fMVAPdfB->GetSmoothedHist()->Write();
1997 fMVAPdfB->GetPDFHist()->Write();
2003 Log() <<
kFATAL <<
"<WriteEvaluationHistosToFile> Unknown result: "
2005 <<
"/kMaxAnalysisType" <<
Endl;
2008 GetTransformationHandler().PlotVariables (GetEventCollection(
Types::kTesting ), BaseDir() );
2027 fin.getline(buf,512);
2033 std::stringstream s(code.
Data());
2034 s >> fTMVATrainingVersion;
2035 Log() <<
kINFO <<
"MVA method was trained with TMVA Version: " << GetTrainingTMVAVersionString() <<
Endl;
2041 std::stringstream s(code.
Data());
2042 s >> fROOTTrainingVersion;
2043 Log() <<
kINFO <<
"MVA method was trained with ROOT Version: " << GetTrainingROOTVersionString() <<
Endl;
2049 std::stringstream s(code.
Data());
2050 std::string analysisType;
2052 if (analysisType ==
"regression" || analysisType ==
"Regression") SetAnalysisType(
Types::kRegression );
2053 else if (analysisType ==
"classification" || analysisType ==
"Classification") SetAnalysisType(
Types::kClassification );
2054 else if (analysisType ==
"multiclass" || analysisType ==
"Multiclass") SetAnalysisType(
Types::kMulticlass );
2055 else Log() <<
kFATAL <<
"Analysis type " << analysisType <<
" from weight-file not known!" << std::endl;
2057 Log() <<
kINFO <<
"Method was trained for "
2077 if (mvaRes==0 || mvaRes->
GetSize()==0) {
2078 Log() <<
kERROR<<
"<CreateMVAPdfs> No result of classifier testing available" <<
Endl;
2085 TH1* histMVAPdfS =
new TH1D( GetMethodTypeName() +
"_tr_S", GetMethodTypeName() +
"_tr_S",
2086 fMVAPdfS->GetHistNBins( mvaRes->
GetSize() ), minVal, maxVal );
2087 TH1* histMVAPdfB =
new TH1D( GetMethodTypeName() +
"_tr_B", GetMethodTypeName() +
"_tr_B",
2088 fMVAPdfB->GetHistNBins( mvaRes->
GetSize() ), minVal, maxVal );
2092 histMVAPdfS->Sumw2();
2093 histMVAPdfB->
Sumw2();
2098 Double_t theWeight =
Data()->GetEvent(ievt)->GetWeight();
2100 if (DataInfo().IsSignal(
Data()->GetEvent(ievt))) histMVAPdfS->Fill( theVal, theWeight );
2101 else histMVAPdfB->
Fill( theVal, theWeight );
2108 histMVAPdfS->Write();
2109 histMVAPdfB->
Write();
2112 fMVAPdfS->BuildPDF ( histMVAPdfS );
2113 fMVAPdfB->BuildPDF ( histMVAPdfB );
2114 fMVAPdfS->ValidatePDF( histMVAPdfS );
2115 fMVAPdfB->ValidatePDF( histMVAPdfB );
2117 if (DataInfo().GetNClasses() == 2) {
2119 <<
Form(
"<CreateMVAPdfs> Separation from histogram (PDF): %1.3f (%1.3f)",
2120 GetSeparation( histMVAPdfS, histMVAPdfB ), GetSeparation( fMVAPdfS, fMVAPdfB ) )
2132 if (!fMVAPdfS || !fMVAPdfB) {
2133 Log() <<
kINFO <<
"<GetProba> MVA PDFs for Signal and Background don't exist yet, we'll create them on demand" <<
Endl;
2136 Double_t sigFraction = DataInfo().GetTrainingSumSignalWeights() / (DataInfo().GetTrainingSumSignalWeights() + DataInfo().GetTrainingSumBackgrWeights() );
2139 return GetProba(mvaVal,sigFraction);
2147 if (!fMVAPdfS || !fMVAPdfB) {
2148 Log() <<
kWARNING <<
"<GetProba> MVA PDFs for Signal and Background don't exist" <<
Endl;
2151 Double_t p_s = fMVAPdfS->GetVal( mvaVal );
2152 Double_t p_b = fMVAPdfB->GetVal( mvaVal );
2154 Double_t denom = p_s*ap_sig + p_b*(1 - ap_sig);
2156 return (denom > 0) ? (p_s*ap_sig) / denom : -1;
2167 Log() <<
kWARNING <<
"<GetRarity> Required MVA PDF for Signal or Backgroud does not exist: "
2168 <<
"select option \"CreateMVAPdfs\"" <<
Endl;
2183 Data()->SetCurrentType(type);
2192 if (!list || list->
GetSize() < 2) computeArea = kTRUE;
2193 else if (list->
GetSize() > 2) {
2194 Log() <<
kFATAL <<
"<GetEfficiency> Wrong number of arguments"
2195 <<
" in string: " << theString
2196 <<
" | required format, e.g., Efficiency:0.05, or empty string" <<
Endl;
2204 Log() <<
kFATAL <<
"<GetEfficiency> Binning mismatch between signal and background histos" <<
Endl;
2212 TH1 * effhist = results->
GetHist(
"MVA_HIGHBIN_S");
2219 if (results->
DoesExist(
"MVA_EFF_S")==0) {
2222 TH1* eff_s =
new TH1D( GetTestvarName() +
"_effS", GetTestvarName() +
" (signal)", fNbinsH, xmin, xmax );
2223 TH1* eff_b =
new TH1D( GetTestvarName() +
"_effB", GetTestvarName() +
" (background)", fNbinsH, xmin, xmax );
2224 results->
Store(eff_s,
"MVA_EFF_S");
2225 results->
Store(eff_b,
"MVA_EFF_B");
2228 Int_t sign = (fCutOrientation == kPositive) ? +1 : -1;
2232 for (
UInt_t ievt=0; ievt<
Data()->GetNEvents(); ievt++) {
2235 Bool_t isSignal = DataInfo().IsSignal(GetEvent(ievt));
2236 Float_t theWeight = GetEvent(ievt)->GetWeight();
2237 Float_t theVal = (*mvaRes)[ievt];
2240 TH1* theHist = isSignal ? eff_s : eff_b;
2243 if (isSignal) nevtS+=theWeight;
2247 if (sign > 0 && maxbin > fNbinsH)
continue;
2248 if (sign < 0 && maxbin < 1 )
continue;
2249 if (sign > 0 && maxbin < 1 ) maxbin = 1;
2250 if (sign < 0 && maxbin > fNbinsH) maxbin = fNbinsH;
2255 for (
Int_t ibin=maxbin+1; ibin<=fNbinsH; ibin++) theHist->
AddBinContent( ibin , theWeight );
2257 Log() <<
kFATAL <<
"<GetEfficiency> Mismatch in sign" <<
Endl;
2268 TH1* eff_BvsS =
new TH1D( GetTestvarName() +
"_effBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2269 results->
Store(eff_BvsS,
"MVA_EFF_BvsS");
2274 TH1* rej_BvsS =
new TH1D( GetTestvarName() +
"_rejBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2275 results->
Store(rej_BvsS);
2277 rej_BvsS->
SetYTitle(
"Backgr rejection (1-eff)" );
2280 TH1* inveff_BvsS =
new TH1D( GetTestvarName() +
"_invBeffvsSeff",
2281 GetTestvarName(), fNbins, 0, 1 );
2282 results->
Store(inveff_BvsS);
2284 inveff_BvsS->
SetYTitle(
"Inverse backgr. eff (1/eff)" );
2290 fSplRefS =
new TSpline1(
"spline2_signal",
new TGraph( eff_s ) );
2291 fSplRefB =
new TSpline1(
"spline2_background",
new TGraph( eff_b ) );
2303 RootFinder rootFinder( &IGetEffForRoot, fXmin, fXmax );
2307 for (
Int_t bini=1; bini<=fNbins; bini++) {
2329 Double_t effS = 0., rejB, effS_ = 0., rejB_ = 0.;
2330 Int_t nbins_ = 5000;
2331 for (
Int_t bini=1; bini<=nbins_; bini++) {
2334 effS = (bini - 0.5)/
Float_t(nbins_);
2335 rejB = 1.0 - fSpleffBvsS->Eval( effS );
2338 if ((effS - rejB)*(effS_ - rejB_) < 0)
break;
2345 SetSignalReferenceCut( cut );
2350 if (0 == fSpleffBvsS) {
2356 Double_t effS = 0, effB = 0, effS_ = 0, effB_ = 0;
2357 Int_t nbins_ = 1000;
2363 for (
Int_t bini=1; bini<=nbins_; bini++) {
2366 effS = (bini - 0.5)/
Float_t(nbins_);
2367 effB = fSpleffBvsS->Eval( effS );
2368 integral += (1.0 - effB);
2382 for (
Int_t bini=1; bini<=nbins_; bini++) {
2385 effS = (bini - 0.5)/
Float_t(nbins_);
2386 effB = fSpleffBvsS->Eval( effS );
2389 if ((effB - effBref)*(effB_ - effBref) <= 0)
break;
2395 effS = 0.5*(effS + effS_);
2398 if (nevtS > 0) effSerr =
TMath::Sqrt( effS*(1.0 - effS)/nevtS );
2423 Log() <<
kFATAL <<
"<GetTrainingEfficiency> Wrong number of arguments"
2424 <<
" in string: " << theString
2425 <<
" | required format, e.g., Efficiency:0.05" <<
Endl;
2438 Log() <<
kFATAL <<
"<GetTrainingEfficiency> Binning mismatch between signal and background histos"
2446 TH1 * effhist = results->
GetHist(
"MVA_HIGHBIN_S");
2451 if (results->
DoesExist(
"MVA_TRAIN_S")==0) {
2457 TH1* mva_s_tr =
new TH1D( GetTestvarName() +
"_Train_S",GetTestvarName() +
"_Train_S", fNbinsMVAoutput, fXmin, sxmax );
2458 TH1* mva_b_tr =
new TH1D( GetTestvarName() +
"_Train_B",GetTestvarName() +
"_Train_B", fNbinsMVAoutput, fXmin, sxmax );
2459 results->
Store(mva_s_tr,
"MVA_TRAIN_S");
2460 results->
Store(mva_b_tr,
"MVA_TRAIN_B");
2465 TH1* mva_eff_tr_s =
new TH1D( GetTestvarName() +
"_trainingEffS", GetTestvarName() +
" (signal)",
2466 fNbinsH, xmin, xmax );
2467 TH1* mva_eff_tr_b =
new TH1D( GetTestvarName() +
"_trainingEffB", GetTestvarName() +
" (background)",
2468 fNbinsH, xmin, xmax );
2469 results->
Store(mva_eff_tr_s,
"MVA_TRAINEFF_S");
2470 results->
Store(mva_eff_tr_b,
"MVA_TRAINEFF_B");
2473 Int_t sign = (fCutOrientation == kPositive) ? +1 : -1;
2476 for (
Int_t ievt=0; ievt<
Data()->GetNEvents(); ievt++) {
2478 Data()->SetCurrentEvent(ievt);
2479 const Event* ev = GetEvent();
2484 TH1* theEffHist = DataInfo().IsSignal(ev) ? mva_eff_tr_s : mva_eff_tr_b;
2485 TH1* theClsHist = DataInfo().IsSignal(ev) ? mva_s_tr : mva_b_tr;
2487 theClsHist->
Fill( theVal, theWeight );
2491 if (sign > 0 && maxbin > fNbinsH)
continue;
2492 if (sign < 0 && maxbin < 1 )
continue;
2493 if (sign > 0 && maxbin < 1 ) maxbin = 1;
2494 if (sign < 0 && maxbin > fNbinsH) maxbin = fNbinsH;
2496 if (sign > 0)
for (
Int_t ibin=1; ibin<=maxbin; ibin++) theEffHist->
AddBinContent( ibin , theWeight );
2497 else for (
Int_t ibin=maxbin+1; ibin<=fNbinsH; ibin++) theEffHist->
AddBinContent( ibin , theWeight );
2510 TH1* eff_bvss =
new TH1D( GetTestvarName() +
"_trainingEffBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2512 TH1* rej_bvss =
new TH1D( GetTestvarName() +
"_trainingRejBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2513 results->
Store(eff_bvss,
"EFF_BVSS_TR");
2514 results->
Store(rej_bvss,
"REJ_BVSS_TR");
2520 if (fSplTrainRefS)
delete fSplTrainRefS;
2521 if (fSplTrainRefB)
delete fSplTrainRefB;
2522 fSplTrainRefS =
new TSpline1(
"spline2_signal",
new TGraph( mva_eff_tr_s ) );
2523 fSplTrainRefB =
new TSpline1(
"spline2_background",
new TGraph( mva_eff_tr_b ) );
2535 RootFinder rootFinder(&IGetEffForRoot, fXmin, fXmax );
2538 fEffS = results->
GetHist(
"MVA_TRAINEFF_S");
2539 for (
Int_t bini=1; bini<=fNbins; bini++) {
2557 fSplTrainEffBvsS =
new TSpline1(
"effBvsS",
new TGraph( eff_bvss ) );
2561 if (0 == fSplTrainEffBvsS)
return 0.0;
2564 Double_t effS = 0., effB, effS_ = 0., effB_ = 0.;
2565 Int_t nbins_ = 1000;
2566 for (
Int_t bini=1; bini<=nbins_; bini++) {
2569 effS = (bini - 0.5)/
Float_t(nbins_);
2570 effB = fSplTrainEffBvsS->Eval( effS );
2573 if ((effB - effBref)*(effB_ - effBref) <= 0)
break;
2578 return 0.5*(effS + effS_);
2588 if (!resMulticlass)
Log() <<
kFATAL<<
"unable to create pointer in GetMulticlassEfficiency, exiting."<<
Endl;
2600 if (!resMulticlass)
Log() <<
kFATAL<<
"unable to create pointer in GetMulticlassTrainingEfficiency, exiting."<<
Endl;
2602 Log() <<
kINFO <<
"Determine optimal multiclass cuts for training data..." <<
Endl;
2603 for (
UInt_t icls = 0; icls<DataInfo().GetNClasses(); ++icls) {
2620 return (rms > 0) ?
TMath::Abs(fMeanS - fMeanB)/rms : 0;
2640 if ((!pdfS && pdfB) || (pdfS && !pdfB))
2641 Log() <<
kFATAL <<
"<GetSeparation> Mismatch in pdfs" <<
Endl;
2642 if (!pdfS) pdfS = fSplS;
2643 if (!pdfB) pdfB = fSplB;
2645 if (!fSplS || !fSplB) {
2646 Log()<<
kWARNING<<
"could not calculate the separation, distributions"
2647 <<
" fSplS or fSplB are not yet filled" <<
Endl;
2662 if ((!histS && histB) || (histS && !histB))
2663 Log() <<
kFATAL <<
"<GetROCIntegral(TH1D*, TH1D*)> Mismatch in hists" <<
Endl;
2665 if (histS==0 || histB==0)
return 0.;
2678 for (
UInt_t i=0; i<nsteps; i++) {
2682 return integral*step;
2694 if ((!pdfS && pdfB) || (pdfS && !pdfB))
2695 Log() <<
kFATAL <<
"<GetSeparation> Mismatch in pdfs" <<
Endl;
2696 if (!pdfS) pdfS = fSplS;
2697 if (!pdfB) pdfB = fSplB;
2699 if (pdfS==0 || pdfB==0)
return 0.;
2708 for (
UInt_t i=0; i<nsteps; i++) {
2712 return integral*step;
2722 Double_t& max_significance_value )
const
2727 Double_t effS(0),effB(0),significance(0);
2728 TH1D *temp_histogram =
new TH1D(
"temp",
"temp", fNbinsH, fXmin, fXmax );
2730 if (SignalEvents <= 0 || BackgroundEvents <= 0) {
2731 Log() <<
kFATAL <<
"<GetMaximumSignificance> "
2732 <<
"Number of signal or background events is <= 0 ==> abort"
2736 Log() <<
kINFO <<
"Using ratio SignalEvents/BackgroundEvents = "
2737 << SignalEvents/BackgroundEvents <<
Endl;
2742 if ( (eff_s==0) || (eff_b==0) ) {
2748 for (
Int_t bin=1; bin<=fNbinsH; bin++) {
2753 significance =
sqrt(SignalEvents)*( effS )/
sqrt( effS + ( BackgroundEvents / SignalEvents) * effB );
2763 delete temp_histogram;
2765 Log() <<
kINFO <<
"Optimal cut at : " << max_significance <<
Endl;
2766 Log() <<
kINFO <<
"Maximum significance: " << max_significance_value <<
Endl;
2768 return max_significance;
2782 Data()->SetCurrentType(treeType);
2788 Log() <<
kFATAL <<
"<CalculateEstimator> Wrong tree type: " << treeType <<
Endl;
2791 UInt_t varIndex = DataInfo().FindVarIndex( theVarName );
2807 for (
Int_t ievt = 0; ievt < entries; ievt++) {
2809 const Event* ev = GetEvent(ievt);
2814 if (DataInfo().IsSignal(ev)) {
2816 meanS += weight*theVar;
2817 rmsS += weight*theVar*theVar;
2821 meanB += weight*theVar;
2822 rmsB += weight*theVar*theVar;
2830 meanS = meanS/sumwS;
2831 meanB = meanB/sumwB;
2835 Data()->SetCurrentType(previousTreeType);
2845 if (theClassFileName ==
"")
2846 classFileName = GetWeightFileDir() +
"/" + GetJobName() +
"_" +
GetMethodName() +
".class.C";
2848 classFileName = theClassFileName;
2852 TString tfname( classFileName );
2853 Log() <<
kINFO <<
"Creating standalone response class: "
2856 std::ofstream fout( classFileName );
2858 Log() <<
kFATAL <<
"<MakeClass> Unable to open file: " << classFileName <<
Endl;
2863 fout <<
"// Class: " << className << std::endl;
2864 fout <<
"// Automatically generated by MethodBase::MakeClass" << std::endl <<
"//" << std::endl;
2868 fout <<
"/* configuration options =====================================================" << std::endl << std::endl;
2869 WriteStateToStream( fout );
2871 fout <<
"============================================================================ */" << std::endl;
2874 fout <<
"" << std::endl;
2875 fout <<
"#include <vector>" << std::endl;
2876 fout <<
"#include <cmath>" << std::endl;
2877 fout <<
"#include <string>" << std::endl;
2878 fout <<
"#include <iostream>" << std::endl;
2879 fout <<
"" << std::endl;
2882 this->MakeClassSpecificHeader( fout, className );
2884 fout <<
"#ifndef IClassifierReader__def" << std::endl;
2885 fout <<
"#define IClassifierReader__def" << std::endl;
2887 fout <<
"class IClassifierReader {" << std::endl;
2889 fout <<
" public:" << std::endl;
2891 fout <<
" // constructor" << std::endl;
2892 fout <<
" IClassifierReader() : fStatusIsClean( true ) {}" << std::endl;
2893 fout <<
" virtual ~IClassifierReader() {}" << std::endl;
2895 fout <<
" // return classifier response" << std::endl;
2896 fout <<
" virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;" << std::endl;
2898 fout <<
" // returns classifier status" << std::endl;
2899 fout <<
" bool IsStatusClean() const { return fStatusIsClean; }" << std::endl;
2901 fout <<
" protected:" << std::endl;
2903 fout <<
" bool fStatusIsClean;" << std::endl;
2904 fout <<
"};" << std::endl;
2906 fout <<
"#endif" << std::endl;
2908 fout <<
"class " << className <<
" : public IClassifierReader {" << std::endl;
2910 fout <<
" public:" << std::endl;
2912 fout <<
" // constructor" << std::endl;
2913 fout <<
" " << className <<
"( std::vector<std::string>& theInputVars ) " << std::endl;
2914 fout <<
" : IClassifierReader()," << std::endl;
2915 fout <<
" fClassName( \"" << className <<
"\" )," << std::endl;
2916 fout <<
" fNvars( " << GetNvar() <<
" )," << std::endl;
2917 fout <<
" fIsNormalised( " << (IsNormalised() ?
"true" :
"false") <<
" )" << std::endl;
2918 fout <<
" { " << std::endl;
2919 fout <<
" // the training input variables" << std::endl;
2920 fout <<
" const char* inputVars[] = { ";
2921 for (
UInt_t ivar=0; ivar<GetNvar(); ivar++) {
2922 fout <<
"\"" << GetOriginalVarName(ivar) <<
"\"";
2923 if (ivar<GetNvar()-1) fout <<
", ";
2925 fout <<
" };" << std::endl;
2927 fout <<
" // sanity checks" << std::endl;
2928 fout <<
" if (theInputVars.size() <= 0) {" << std::endl;
2929 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": empty input vector\" << std::endl;" << std::endl;
2930 fout <<
" fStatusIsClean = false;" << std::endl;
2931 fout <<
" }" << std::endl;
2933 fout <<
" if (theInputVars.size() != fNvars) {" << std::endl;
2934 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": mismatch in number of input values: \"" << std::endl;
2935 fout <<
" << theInputVars.size() << \" != \" << fNvars << std::endl;" << std::endl;
2936 fout <<
" fStatusIsClean = false;" << std::endl;
2937 fout <<
" }" << std::endl;
2939 fout <<
" // validate input variables" << std::endl;
2940 fout <<
" for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {" << std::endl;
2941 fout <<
" if (theInputVars[ivar] != inputVars[ivar]) {" << std::endl;
2942 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": mismatch in input variable names\" << std::endl" << std::endl;
2943 fout <<
" << \" for variable [\" << ivar << \"]: \" << theInputVars[ivar].c_str() << \" != \" << inputVars[ivar] << std::endl;" << std::endl;
2944 fout <<
" fStatusIsClean = false;" << std::endl;
2945 fout <<
" }" << std::endl;
2946 fout <<
" }" << std::endl;
2948 fout <<
" // initialize min and max vectors (for normalisation)" << std::endl;
2949 for (
UInt_t ivar = 0; ivar < GetNvar(); ivar++) {
2950 fout <<
" fVmin[" << ivar <<
"] = " << std::setprecision(15) << GetXmin( ivar ) <<
";" << std::endl;
2951 fout <<
" fVmax[" << ivar <<
"] = " << std::setprecision(15) << GetXmax( ivar ) <<
";" << std::endl;
2954 fout <<
" // initialize input variable types" << std::endl;
2955 for (
UInt_t ivar=0; ivar<GetNvar(); ivar++) {
2956 fout <<
" fType[" << ivar <<
"] = \'" << DataInfo().GetVariableInfo(ivar).GetVarType() <<
"\';" << std::endl;
2959 fout <<
" // initialize constants" << std::endl;
2960 fout <<
" Initialize();" << std::endl;
2962 if (GetTransformationHandler().GetTransformationList().GetSize() != 0) {
2963 fout <<
" // initialize transformation" << std::endl;
2964 fout <<
" InitTransform();" << std::endl;
2966 fout <<
" }" << std::endl;
2968 fout <<
" // destructor" << std::endl;
2969 fout <<
" virtual ~" << className <<
"() {" << std::endl;
2970 fout <<
" Clear(); // method-specific" << std::endl;
2971 fout <<
" }" << std::endl;
2973 fout <<
" // the classifier response" << std::endl;
2974 fout <<
" // \"inputValues\" is a vector of input values in the same order as the " << std::endl;
2975 fout <<
" // variables given to the constructor" << std::endl;
2976 fout <<
" double GetMvaValue( const std::vector<double>& inputValues ) const;" << std::endl;
2978 fout <<
" private:" << std::endl;
2980 fout <<
" // method-specific destructor" << std::endl;
2981 fout <<
" void Clear();" << std::endl;
2983 if (GetTransformationHandler().GetTransformationList().GetSize()!=0) {
2984 fout <<
" // input variable transformation" << std::endl;
2985 GetTransformationHandler().MakeFunction(fout, className,1);
2986 fout <<
" void InitTransform();" << std::endl;
2987 fout <<
" void Transform( std::vector<double> & iv, int sigOrBgd ) const;" << std::endl;
2990 fout <<
" // common member variables" << std::endl;
2991 fout <<
" const char* fClassName;" << std::endl;
2993 fout <<
" const size_t fNvars;" << std::endl;
2994 fout <<
" size_t GetNvar() const { return fNvars; }" << std::endl;
2995 fout <<
" char GetType( int ivar ) const { return fType[ivar]; }" << std::endl;
2997 fout <<
" // normalisation of input variables" << std::endl;
2998 fout <<
" const bool fIsNormalised;" << std::endl;
2999 fout <<
" bool IsNormalised() const { return fIsNormalised; }" << std::endl;
3000 fout <<
" double fVmin[" << GetNvar() <<
"];" << std::endl;
3001 fout <<
" double fVmax[" << GetNvar() <<
"];" << std::endl;
3002 fout <<
" double NormVariable( double x, double xmin, double xmax ) const {" << std::endl;
3003 fout <<
" // normalise to output range: [-1, 1]" << std::endl;
3004 fout <<
" return 2*(x - xmin)/(xmax - xmin) - 1.0;" << std::endl;
3005 fout <<
" }" << std::endl;
3007 fout <<
" // type of input variable: 'F' or 'I'" << std::endl;
3008 fout <<
" char fType[" << GetNvar() <<
"];" << std::endl;
3010 fout <<
" // initialize internal variables" << std::endl;
3011 fout <<
" void Initialize();" << std::endl;
3012 fout <<
" double GetMvaValue__( const std::vector<double>& inputValues ) const;" << std::endl;
3013 fout <<
"" << std::endl;
3014 fout <<
" // private members (method specific)" << std::endl;
3017 MakeClassSpecific( fout, className );
3019 fout <<
" inline double " << className <<
"::GetMvaValue( const std::vector<double>& inputValues ) const" << std::endl;
3020 fout <<
" {" << std::endl;
3021 fout <<
" // classifier response value" << std::endl;
3022 fout <<
" double retval = 0;" << std::endl;
3024 fout <<
" // classifier response, sanity check first" << std::endl;
3025 fout <<
" if (!IsStatusClean()) {" << std::endl;
3026 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": cannot return classifier response\"" << std::endl;
3027 fout <<
" << \" because status is dirty\" << std::endl;" << std::endl;
3028 fout <<
" retval = 0;" << std::endl;
3029 fout <<
" }" << std::endl;
3030 fout <<
" else {" << std::endl;
3031 fout <<
" if (IsNormalised()) {" << std::endl;
3032 fout <<
" // normalise variables" << std::endl;
3033 fout <<
" std::vector<double> iV;" << std::endl;
3034 fout <<
" iV.reserve(inputValues.size());" << std::endl;
3035 fout <<
" int ivar = 0;" << std::endl;
3036 fout <<
" for (std::vector<double>::const_iterator varIt = inputValues.begin();" << std::endl;
3037 fout <<
" varIt != inputValues.end(); varIt++, ivar++) {" << std::endl;
3038 fout <<
" iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));" << std::endl;
3039 fout <<
" }" << std::endl;
3040 if (GetTransformationHandler().GetTransformationList().GetSize()!=0 &&
3043 fout <<
" Transform( iV, -1 );" << std::endl;
3045 fout <<
" retval = GetMvaValue__( iV );" << std::endl;
3046 fout <<
" }" << std::endl;
3047 fout <<
" else {" << std::endl;
3048 if (GetTransformationHandler().GetTransformationList().GetSize()!=0 &&
3051 fout <<
" std::vector<double> iV;" << std::endl;
3052 fout <<
" int ivar = 0;" << std::endl;
3053 fout <<
" for (std::vector<double>::const_iterator varIt = inputValues.begin();" << std::endl;
3054 fout <<
" varIt != inputValues.end(); varIt++, ivar++) {" << std::endl;
3055 fout <<
" iV.push_back(*varIt);" << std::endl;
3056 fout <<
" }" << std::endl;
3057 fout <<
" Transform( iV, -1 );" << std::endl;
3058 fout <<
" retval = GetMvaValue__( iV );" << std::endl;
3061 fout <<
" retval = GetMvaValue__( inputValues );" << std::endl;
3063 fout <<
" }" << std::endl;
3064 fout <<
" }" << std::endl;
3066 fout <<
" return retval;" << std::endl;
3067 fout <<
" }" << std::endl;
3070 if (GetTransformationHandler().GetTransformationList().GetSize()!=0)
3071 GetTransformationHandler().MakeFunction(fout, className,2);
3083 std::streambuf* cout_sbuf = std::cout.rdbuf();
3084 std::ofstream* o = 0;
3085 if (
gConfig().WriteOptionsReference()) {
3086 Log() <<
kINFO <<
"Print Help message for class " << GetName() <<
" into file: " << GetReferenceFile() <<
Endl;
3087 o =
new std::ofstream( GetReferenceFile(), std::ios::app );
3089 Log() <<
kFATAL <<
"<PrintHelpMessage> Unable to append to output file: " << GetReferenceFile() <<
Endl;
3091 std::cout.rdbuf( o->rdbuf() );
3098 <<
"================================================================"
3102 <<
"H e l p f o r M V A m e t h o d [ " << GetName() <<
" ] :"
3107 Log() <<
"Help for MVA method [ " << GetName() <<
" ] :" <<
Endl;
3115 Log() <<
"<Suppress this message by specifying \"!H\" in the booking option>" <<
Endl;
3117 <<
"================================================================"
3124 Log() <<
"# End of Message___" <<
Endl;
3127 std::cout.rdbuf( cout_sbuf );
3150 retval = fSplRefS->Eval( theCut );
3152 else retval = fEffS->GetBinContent( fEffS->FindBin( theCut ) );
3161 if (theCut-fXmin < eps) retval = (GetCutOrientation() == kPositive) ? 1.0 : 0.0;
3162 else if (fXmax-theCut < eps) retval = (GetCutOrientation() == kPositive) ? 0.0 : 1.0;
3175 if (GetTransformationHandler().GetTransformationList().GetEntries() <= 0) {
3176 return (
Data()->GetEventCollection(type));
3183 if (fEventCollections.at(idx) == 0) {
3184 fEventCollections.at(idx) = &(
Data()->GetEventCollection(type));
3185 fEventCollections.at(idx) = GetTransformationHandler().CalcTransformations(*(fEventCollections.at(idx)),kTRUE);
3187 return *(fEventCollections.at(idx));
3195 UInt_t a = GetTrainingTMVAVersionCode() & 0xff0000; a>>=16;
3196 UInt_t b = GetTrainingTMVAVersionCode() & 0x00ff00; b>>=8;
3197 UInt_t c = GetTrainingTMVAVersionCode() & 0x0000ff;
3207 UInt_t a = GetTrainingROOTVersionCode() & 0xff0000; a>>=16;
3208 UInt_t b = GetTrainingROOTVersionCode() & 0x00ff00; b>>=8;
3209 UInt_t c = GetTrainingROOTVersionCode() & 0x0000ff;
3219 return GetThisBaseThreadLocal();
3227 GetThisBaseThreadLocal() =
this;
3235 if (mvaRes !=
NULL) {
3238 TH1D *mva_s_tr =
dynamic_cast<TH1D*
> (mvaRes->
GetHist(
"MVA_TRAIN_S"));
3239 TH1D *mva_b_tr =
dynamic_cast<TH1D*
> (mvaRes->
GetHist(
"MVA_TRAIN_B"));
3241 if ( !mva_s || !mva_b || !mva_s_tr || !mva_b_tr)
return -1;
3243 if (SorB ==
's' || SorB ==
'S')
static void SetIgnoreNegWeightsInTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
virtual Int_t GetEntries() const
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual void AddClassifierOutputProb(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Return Global bin number corresponding to x,y,z.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetTuneParameters(std::map< TString, Double_t > tuneParameters)
set the tuning parameters accoding to the argument This is just a dummy .
const TString & GetWeightFileDir() const
static TDirectory * RootBaseDir()
void AddInfoItem(void *gi, const TString &name, const TString &value) const
xml writing
#define TMVA_VERSION_CODE
MsgLogger & Endl(MsgLogger &ml)
TH1 * GetHist(const TString &alias) const
Bool_t GetLine(std::istream &fin, char *buf)
reads one line from the input stream checks for certain keywords and interprets the line if keywords ...
static void SetIsTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
TString GetTrainingROOTVersionString() const
calculates the ROOT version string from the training version code on the fly
void AddOutput(Types::ETreeType type, Types::EAnalysisType analysisType)
static void CreateVariableTransforms(const TString &trafoDefinition, TMVA::DataSetInfo &dataInfo, TMVA::TransformationHandler &transformationHandler, TMVA::MsgLogger &log)
create variable transformations
virtual const char * WorkingDirectory()
Return working directory.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
void ReadStateFromXML(void *parent)
virtual Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)=0
void variables(TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
Collectable string class.
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
const TString & GetExpression() const
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void WriteEvaluationHistosToFile(Types::ETreeType treetype)
writes all MVA evaluation histograms to file
TString GetTrainingTMVAVersionString() const
calculates the TMVA version string from the training version code on the fly
virtual std::map< TString, Double_t > OptimizeTuningParameters(TString fomType="ROCIntegral", TString fitType="FitGA")
call the Optimzier with the set of paremeters and ranges that are meant to be tuned.
XMLDocPointer_t NewDoc(const char *version="1.0")
creates new xml document with provided version
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual Int_t GetQuantiles(Int_t nprobSum, Double_t *q, const Double_t *probSum=0)
Compute Quantiles for this histogram Quantile x_q of a probability distribution Function F is defined...
virtual int MakeDirectory(const char *name)
Make a directory.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual Double_t GetMaximumSignificance(Double_t SignalEvents, Double_t BackgroundEvents, Double_t &optimal_significance_value) const
plot significance, S/Sqrt(S^2 + B^2), curve for given number of signal and background events; returns...
static Bool_t AddDirectoryStatus()
static function: cannot be inlined on Windows/NT
1-D histogram with a float per channel (see TH1 documentation)}
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
virtual Double_t GetKSTrainingVsTest(Char_t SorB, TString opt="X")
virtual void SetYTitle(const char *title)
virtual TDirectory * mkdir(const char *name, const char *title="")
Create a sub-directory and return a pointer to the created directory.
MethodBase(const TString &jobName, Types::EMVA methodType, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="", TDirectory *theBaseDir=0)
standard constructur
virtual void TestMulticlass()
test multiclass classification
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not...
virtual Int_t GetNbinsX() const
#define ROOT_VERSION_CODE
void ReadTargetsFromXML(void *tarnode)
read target info from XML
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual Bool_t IsSignalLike()
uses a pre-set cut on the MVA output (SetSignalReferenceCut and SetSignalReferenceCutOrientation) for...
void CreateMVAPdfs()
Create PDFs of the MVA output variables.
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
TString GetWeightFileName() const
retrieve weight file name
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
void ReadVariablesFromXML(void *varnode)
read variable info from XML
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
const char * Data() const
void WriteStateToStream(std::ostream &tf) const
general method used in writing the header of the weight files where the used variables, variable transformation type etc.
virtual ~MethodBase()
destructor
void DocSetRootElement(XMLDocPointer_t xmldoc, XMLNodePointer_t xmlnode)
set main (root) node for document
void WriteVarsToStream(std::ostream &tf, const TString &prefix="") const
write the list of variables (name, min, max) for a given data transformation method to the stream ...
void Init(TClassEdit::TInterpreterLookupHelper *helper)
void ReadStateFromFile()
Function to write options and weights to file.
virtual void MakeClass(const TString &classFileName=TString("")) const
create reader class for method (classification only at present)
std::vector< Float_t > * GetValueVector()
virtual void AddClassifierOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
void ReadClassesFromXML(void *clsnode)
read number of classes from XML
void ResetThisBase()
reset required for RootFinder
std::vector< std::vector< double > > Data
void SetupMethod()
setup of methods
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
XMLDocPointer_t ParseString(const char *xmlstring)
parses content of string and tries to produce xml structures
Int_t Atoi() const
Return integer value of string.
virtual Double_t GetProba(const Event *ev)
virtual void AddBinContent(Int_t bin)
Increment bin content by 1.
virtual Double_t GetEfficiency(const TString &, Types::ETreeType, Double_t &err)
fill background efficiency (resp.
virtual std::vector< Float_t > GetMulticlassEfficiency(std::vector< std::vector< Float_t > > &purity)
Double_t GetEffForRoot(Double_t)
returns efficiency as function of cut
Double_t Root(Double_t refValue)
Root finding using Brents algorithm; taken from CERNLIB function RZERO.
TString GetElapsedTime(Bool_t Scientific=kTRUE)
void ReadStateFromXMLString(const char *xmlstr)
for reading from memory
void AddClassesXMLTo(void *parent) const
write class info to XML
void SaveDoc(XMLDocPointer_t xmldoc, const char *filename, Int_t layout=1)
store document content to file if layout<=0, no any spaces or newlines will be placed between xmlnode...
TString fWeightFileExtension
virtual Double_t GetBinCenter(Int_t bin) const
return bin center for 1D historam Better to use h1.GetXaxis().GetBinCenter(bin)
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
std::string GetMethodName(TCppMethod_t)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Double_t length(const TVector2 &v)
Class to manage histogram axis.
R__EXTERN TSystem * gSystem
virtual const char * GetBuildNode() const
Return the build node name.
Bool_t DoesExist(const TString &alias) const
void ReadVarsFromStream(std::istream &istr)
Read the variables (name, min, max) for a given data transformation method from the stream...
virtual void WriteMonitoringHistosToFile() const
write special monitoring histograms to file dummy implementation here --------------— ...
const Int_t NBIN_HIST_HIGH
2-D histogram with a float per channel (see TH1 documentation)}
class TMVA::Config::VariablePlotting fVariablePlotting
ClassInfo * GetClassInfo(Int_t clNum) const
void Statistics(Types::ETreeType treeType, const TString &theVarName, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &)
calculates rms,mean, xmin, xmax of the event variable this can be either done for the variables as th...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Float_t GetAchievablePur(UInt_t cls)
void SetValue(Float_t value, Int_t ievt)
set MVA response
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using Kolmogorov test...
Double_t ElapsedSeconds(void)
computes elapsed tim in seconds
char * Form(const char *fmt,...)
void ReadFromXML(void *varnode)
read VariableInfo from stream
const TString & GetName() const
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
virtual Double_t GetSignificance() const
compute significance of mean difference significance = |<S> - |/Sqrt(RMS_S2 + RMS_B2) ...
void DeclareBaseOptions()
define the options (their key words) that can be set in the option string here the options valid for ...
1-D histogram with a double per channel (see TH1 documentation)}
void ProcessBaseOptions()
the option string is decoded, for availabel options see "DeclareOptions"
void WriteStateToFile() const
write options and weights to file note that each one text file for the main configuration information...
void AddTargetsXMLTo(void *parent) const
write target info to XML
virtual TObject * FindObject(const char *name) const
Find object by name in the list of memory objects.
void DeclareOptions()
define the options (their key words) that can be set in the option string know options: PDFInterpol[i...
TString & Remove(Ssiz_t pos)
void AddVarsXMLTo(void *parent) const
write variable info to XML
TList * GetStorage() const
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
const std::vector< TMVA::Event * > & GetEventCollection(Types::ETreeType type)
returns the event collection (i.e.
virtual Int_t GetSize() const
virtual void CheckSetup()
check may be overridden by derived class (sometimes, eg, fitters are used which can only be implement...
virtual void AddRegressionOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
Double_t GetVal(Double_t x) const
returns value PDF(x)
std::vector< Double_t > GetBestMultiClassCuts(UInt_t targetClass)
void SetWeightFileName(TString)
set the weight file name (depreciated)
Describe directory structure in memory.
virtual Double_t GetROCIntegral(TH1D *histS, TH1D *histB) const
calculate the area (integral) under the ROC curve as a overall quality measure of the classification ...
TDirectory * BaseDir() const
returns the ROOT directory where info/histograms etc of the corresponding MVA method instance are sto...
static RooMathCoreReg dummy
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
const Bool_t Use_Splines_for_Eff_
virtual void GetRegressionDeviation(UInt_t tgtNum, Types::ETreeType type, Double_t &stddev, Double_t &stddev90Percent) const
void ProcessSetup()
process all options the "CheckForUnusedOptions" is done in an independent call, since it may be overr...
virtual void AddMulticlassOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
Mother of all ROOT objects.
Float_t GetTarget(UInt_t itgt) const
void * GetExternalLink() const
Float_t GetAchievableEff(UInt_t cls)
virtual Double_t GetSeparation(TH1 *, TH1 *) const
compute "separation" defined as <s2> = (1/2) Int_-oo..+oo { (S(x) - B(x))^2/(S(x) + B(x)) dx } ...
virtual std::vector< Float_t > GetMulticlassTrainingEfficiency(std::vector< std::vector< Float_t > > &purity)
virtual void SetXTitle(const char *title)
virtual void TestRegression(Double_t &bias, Double_t &biasT, Double_t &dev, Double_t &devT, Double_t &rms, Double_t &rmsT, Double_t &mInf, Double_t &mInfT, Double_t &corr, Types::ETreeType type)
calculate <sum-of-deviation-squared> of regression output versus "true" value from test sample ...
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
void ReadFromStream(std::istream &istr)
void PrintHelpMessage() const
prints out method-specific help method
static MethodBase * GetThisBase()
return a pointer the base class of this method
virtual void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
Short_t Max(Short_t a, Short_t b)
void AddToXML(void *varnode)
write class to XML
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TDirectory * MethodBaseDir() const
returns the ROOT directory where all instances of the corresponding MVA method are stored ...
void SetWeightFileDir(TString fileDir)
set directory of weight file
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
void AddSpectatorsXMLTo(void *parent) const
write spectator info to XML
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
A Graph is a graphics object made of two arrays X and Y with npoints each.
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
virtual Double_t GetTrainingEfficiency(const TString &)
Double_t GetIntegral(Double_t xmin, Double_t xmax)
computes PDF integral within given ranges
void ReadSpectatorsFromXML(void *specnode)
read spectator info from XML
void DrawProgressBar(Int_t, const TString &comment="")
draws progress bar in color or B&W caution:
void InitBase()
default initialization called by all constructors
void Store(TObject *obj, const char *alias=0)
virtual Double_t GetRarity(Double_t mvaVal, Types::ESBType reftype=Types::kBackground) const
compute rarity: R(x) = Integrate_[-oo..x] { PDF(x') dx' } where PDF(x) is the PDF of the classifier's...
static Double_t IGetEffForRoot(Double_t)
interface for RootFinder
Double_t Sqrt(Double_t x)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
const char * AsString() const
Return the date & time as a string (ctime() format).
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
Int_t Fill(Double_t)
Invalid Fill method.
void SetTestvarName(const TString &v="")
double norm(double *x, double *p)
void WriteStateToXML(void *parent) const
general method used in writing the header of the weight files where the used variables, variable transformation type etc.
virtual void TestClassification()
initialization
void ReadStateFromStream(std::istream &tf)
read the header from the weight files of the different MVA methods
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write all objects in this collection.
void SetExternalLink(void *p)
void Resize(Int_t entries)
Ssiz_t First(char c) const
Find first occurrence of a character c.
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
virtual void Close(Option_t *option="")
Close a file.