104 #define READXML kTRUE
121 fTransformations (
"I" ),
126 fJobName ( jobName ),
127 fAnalysisType (
Types::kClassification ),
128 fModelPersistence (
kTRUE)
154 DeclareOptionRef( color,
"Color",
"Flag for coloured screen output (default: True, if in batch mode: False)" );
155 DeclareOptionRef(
fTransformations,
"Transformations",
"List of transformations to test; formatting example: \"Transformations=I;D;P;U;G,D\", for identity, decorrelation, PCA, Uniform and Gaussianisation followed by decorrelation transformations" );
158 DeclareOptionRef( silent,
"Silent",
"Batch mode: boolean silent flag inhibiting any output from TMVA after the creation of the factory class object (default: False)" );
160 "DrawProgressBar",
"Draw progress bar to display training, testing and evaluation schedule (default: True)" );
163 "Option to save the trained model in xml file or using serialization");
167 "AnalysisType",
"Set the analysis type (Classification, Regression, Multiclass, Auto) (default: Auto)" );
197 fTransformations (
"I" ),
201 fSilentFile (
kTRUE ),
202 fJobName ( jobName ),
203 fAnalysisType (
Types::kClassification ),
204 fModelPersistence (
kTRUE)
231 DeclareOptionRef( color,
"Color",
"Flag for coloured screen output (default: True, if in batch mode: False)" );
232 DeclareOptionRef(
fTransformations,
"Transformations",
"List of transformations to test; formatting example: \"Transformations=I;D;P;U;G,D\", for identity, decorrelation, PCA, Uniform and Gaussianisation followed by decorrelation transformations" );
235 DeclareOptionRef( silent,
"Silent",
"Batch mode: boolean silent flag inhibiting any output from TMVA after the creation of the factory class object (default: False)" );
237 "DrawProgressBar",
"Draw progress bar to display training, testing and evaluation schedule (default: True)" );
240 "Option to save the trained model in xml file or using serialization");
244 "AnalysisType",
"Set the analysis type (Classification, Regression, Multiclass, Auto) (default: Auto)" );
291 return fModelPersistence;
299 std::vector<TMVA::VariableTransformBase*>::iterator trfIt = fDefaultTrfs.begin();
300 for (;trfIt != fDefaultTrfs.end(); trfIt++)
delete (*trfIt);
302 this->DeleteAllMethods();
317 std::map<TString,MVector*>::iterator itrMap;
319 for(itrMap = fMethodsMap.begin();itrMap != fMethodsMap.end();itrMap++)
321 MVector *methods=itrMap->second;
323 MVector::iterator itrMethod = methods->begin();
324 for (; itrMethod != methods->end(); itrMethod++) {
325 Log() << kDEBUG <<
"Delete method: " << (*itrMethod)->GetName() <<
Endl;
365 if(fMethodsMap.find(datasetname)!=fMethodsMap.end())
367 if (
GetMethod( datasetname,methodTitle ) != 0) {
368 Log() << kFATAL <<
"Booking failed since method with title <"
369 << methodTitle <<
"> already exists "<<
"in with DataSet Name <"<< loader->
GetName()<<
"> "
375 Log() << kHEADER <<
"Booking method: " <<
gTools().
Color(
"bold") << methodTitle
383 "Number of times the classifier will be boosted" );
387 if(fModelPersistence)
400 Log() << kDEBUG <<
"Boost Number is " << boostNum <<
" > 0: train boosted classifier" <<
Endl;
404 Log() << kFATAL <<
"Method with type kBoost cannot be casted to MethodCategory. /Factory" <<
Endl;
406 if (fModelPersistence)
411 methBoost->
SetFile(fgTargetFile);
416 if (method==0)
return 0;
422 Log() << kFATAL <<
"Method with type kCategory cannot be casted to MethodCategory. /Factory" <<
Endl;
427 methCat->
SetFile(fgTargetFile);
435 Log() << kWARNING <<
"Method " << method->
GetMethodTypeName() <<
" is not capable of handling " ;
460 if(fMethodsMap.find(datasetname)==fMethodsMap.end())
463 fMethodsMap[datasetname]=mvector;
465 fMethodsMap[datasetname]->push_back( method );
485 if(fMethodsMap.find(datasetname)==fMethodsMap.end())
return 0;
487 MVector *methods=fMethodsMap.find(datasetname)->second;
489 MVector::const_iterator itrMethod;
491 for (itrMethod = methods->begin(); itrMethod != methods->end(); itrMethod++) {
503 if(fMethodsMap.find(datasetname)==fMethodsMap.end())
return 0;
505 std::string methodName = methodTitle.
Data();
507 return ( 0 == methodName.compare(
m->GetName() ) );
511 Bool_t isMethodNameExisting = std::any_of( methods->begin(), methods->end(), isEqualToMethodName);
513 return isMethodNameExisting;
522 if(!RootBaseDir()->GetDirectory(fDataSetInfo.
GetName())) RootBaseDir()->mkdir(fDataSetInfo.
GetName());
525 RootBaseDir()->cd(fDataSetInfo.
GetName());
572 processTrfs = fTransformations;
575 std::vector<TMVA::TransformationHandler*> trfs;
579 std::vector<TString>::iterator trfsDefIt = trfsDef.begin();
580 for (; trfsDefIt!=trfsDef.end(); trfsDefIt++) {
585 Log() << kDEBUG <<
"current transformation string: '" << trfS.
Data() <<
"'" <<
Endl;
591 if (trfS.
BeginsWith(
'I')) identityTrHandler = trfs.back();
597 std::vector<TMVA::TransformationHandler*>::iterator trfIt = trfs.begin();
599 for (;trfIt != trfs.end(); trfIt++) {
601 (*trfIt)->SetRootDir(RootBaseDir()->GetDirectory(fDataSetInfo.
GetName()));
602 (*trfIt)->CalcTransformations(inputEvents);
607 for (trfIt = trfs.begin(); trfIt != trfs.end(); trfIt++)
delete *trfIt;
619 std::map<TString,MVector*>::iterator itrMap;
620 std::map<TString,Double_t> TunedParameters;
621 for(itrMap = fMethodsMap.begin();itrMap != fMethodsMap.end();itrMap++)
623 MVector *methods=itrMap->second;
625 MVector::iterator itrMethod;
628 for( itrMethod = methods->begin(); itrMethod != methods->end(); itrMethod++ ) {
632 Log() << kFATAL <<
"Dynamic cast to MethodBase failed" <<
Endl;
633 return TunedParameters;
638 <<
" not trained (training tree has less entries ["
649 Log() << kINFO <<
"Optimization of tuning parameters finished for Method:"<<mva->
GetName() <<
Endl;
653 return TunedParameters;
668 return GetROC((
TString)loader->
GetName(), theMethodName, iClass, type);
681 if (fMethodsMap.find(datasetname) == fMethodsMap.end()) {
682 Log() << kERROR <<
Form(
"DataSet = %s not found in methods map.", datasetname.
Data()) <<
Endl;
686 if (!this->HasMethod(datasetname, theMethodName)) {
687 Log() << kERROR <<
Form(
"Method = %s not found with Dataset = %s ", theMethodName.
Data(), datasetname.
Data())
693 if (allowedAnalysisTypes.count(this->fAnalysisType) == 0) {
694 Log() << kERROR <<
Form(
"Can only generate ROC curves for analysis type kClassification and kMulticlass.")
706 Log() << kERROR <<
Form(
"Given class number (iClass = %i) does not exist. There are %i classes in dataset.",
716 std::vector<Bool_t> *mvaResTypes =
dynamic_cast<ResultsClassification *
>(results)->GetValueVectorTypes();
717 std::vector<Float_t> mvaResWeights;
720 mvaResWeights.reserve(eventCollection.size());
721 for (
auto ev : eventCollection) {
722 mvaResWeights.push_back(ev->GetWeight());
725 rocCurve =
new TMVA::ROCCurve(*mvaRes, *mvaResTypes, mvaResWeights);
728 std::vector<Float_t> mvaRes;
729 std::vector<Bool_t> mvaResTypes;
730 std::vector<Float_t> mvaResWeights;
732 std::vector<std::vector<Float_t>> *rawMvaRes =
dynamic_cast<ResultsMulticlass *
>(results)->GetValueVector();
737 mvaRes.reserve(rawMvaRes->size());
738 for (
auto item : *rawMvaRes) {
739 mvaRes.push_back(item[iClass]);
743 mvaResTypes.reserve(eventCollection.size());
744 mvaResWeights.reserve(eventCollection.size());
745 for (
auto ev : eventCollection) {
746 mvaResTypes.push_back(ev->GetClass() == iClass);
747 mvaResWeights.push_back(ev->GetWeight());
750 rocCurve =
new TMVA::ROCCurve(mvaRes, mvaResTypes, mvaResWeights);
766 return GetROCIntegral((
TString)loader->
GetName(), theMethodName, iClass);
779 if (fMethodsMap.find(datasetname) == fMethodsMap.end()) {
780 Log() << kERROR <<
Form(
"DataSet = %s not found in methods map.", datasetname.
Data()) <<
Endl;
784 if ( ! this->HasMethod(datasetname, theMethodName) ) {
785 Log() << kERROR <<
Form(
"Method = %s not found with Dataset = %s ", theMethodName.
Data(), datasetname.
Data()) <<
Endl;
790 if ( allowedAnalysisTypes.count(this->fAnalysisType) == 0 ) {
791 Log() << kERROR <<
Form(
"Can only generate ROC integral for analysis type kClassification. and kMulticlass.")
796 TMVA::ROCCurve *rocCurve = GetROC(datasetname, theMethodName, iClass);
798 Log() << kFATAL <<
Form(
"ROCCurve object was not created in Method = %s not found with Dataset = %s ",
799 theMethodName.
Data(), datasetname.
Data())
827 return GetROCCurve( (
TString)loader->
GetName(), theMethodName, setTitles, iClass );
846 if (fMethodsMap.find(datasetname) == fMethodsMap.end()) {
847 Log() << kERROR <<
Form(
"DataSet = %s not found in methods map.", datasetname.
Data()) <<
Endl;
851 if ( ! this->HasMethod(datasetname, theMethodName) ) {
852 Log() << kERROR <<
Form(
"Method = %s not found with Dataset = %s ", theMethodName.
Data(), datasetname.
Data()) <<
Endl;
857 if ( allowedAnalysisTypes.count(this->fAnalysisType) == 0 ) {
858 Log() << kERROR <<
Form(
"Can only generate ROC curves for analysis type kClassification and kMulticlass.") <<
Endl;
862 TMVA::ROCCurve *rocCurve = GetROC(datasetname, theMethodName, iClass);
866 Log() << kFATAL <<
Form(
"ROCCurve object was not created in Method = %s not found with Dataset = %s ", theMethodName.
Data(), datasetname.
Data()) <<
Endl;
876 graph->
SetTitle(
Form(
"Signal efficiency vs. Background rejection (%s)", theMethodName.
Data()));
896 return GetROCCurveAsMultiGraph((
TString)loader->
GetName(), iClass);
917 MVector *methods = fMethodsMap[datasetname.
Data()];
918 for (
auto * method_raw : *methods) {
920 if (method ==
nullptr) {
continue; }
926 Log() << kERROR <<
Form(
"Given class number (iClass = %i) does not exist. There are %i classes in dataset.", iClass, nClasses) <<
Endl;
932 TGraph *graph = this->GetROCCurve(datasetname, methodName,
false, iClass);
939 multigraph->
Add(graph);
943 Log() << kERROR <<
Form(
"No metohds have class %i defined.", iClass) <<
Endl;
980 if (fMethodsMap.find(datasetname) == fMethodsMap.end()) {
981 Log() << kERROR <<
Form(
"DataSet = %s not found in methods map.", datasetname.
Data()) <<
Endl;
986 TCanvas *canvas =
new TCanvas(name,
"ROC Curve", 200, 10, 700, 500);
989 TMultiGraph *multigraph = this->GetROCCurveAsMultiGraph(datasetname, iClass);
992 multigraph->
Draw(
"AL");
997 TString titleString =
Form(
"Signal efficiency vs. Background rejection");
999 titleString =
Form(
"%s (Class=%i)", titleString.
Data(), iClass);
1004 multigraph->
SetTitle( titleString );
1006 canvas->BuildLegend(0.15, 0.15, 0.35, 0.3,
"MVA Method");
1022 if (fMethodsMap.empty()) {
1023 Log() << kINFO <<
"...nothing found to train" <<
Endl;
1029 Log() << kDEBUG <<
"Train all methods for "
1033 std::map<TString,MVector*>::iterator itrMap;
1035 for(itrMap = fMethodsMap.begin();itrMap != fMethodsMap.end();itrMap++)
1037 MVector *methods=itrMap->second;
1038 MVector::iterator itrMethod;
1041 for( itrMethod = methods->begin(); itrMethod != methods->end(); itrMethod++ ) {
1045 if(mva==0)
continue;
1048 Log() << kFATAL <<
"No input data for the training provided!" <<
Endl;
1052 Log() << kFATAL <<
"You want to do regression training without specifying a target." <<
Endl;
1055 Log() << kFATAL <<
"You want to do classification training, but specified less than two classes." <<
Endl;
1058 if(!IsSilentFile()) WriteDataInformation(mva->
fDataSetInfo);
1063 <<
" not trained (training tree has less entries ["
1073 Log() << kHEADER <<
"Training finished" << Endl <<
Endl;
1080 Log() << kINFO <<
"Ranking input variables (method specific)..." <<
Endl;
1081 for (itrMethod = methods->begin(); itrMethod != methods->end(); itrMethod++) {
1086 const Ranking* ranking = (*itrMethod)->CreateRanking();
1087 if (ranking != 0) ranking->
Print();
1088 else Log() << kINFO <<
"No variable ranking supplied by classifier: "
1098 if (fModelPersistence) {
1100 Log() << kHEADER <<
"=== Destroy and recreate all methods via weight files for testing ===" <<
Endl <<
Endl;
1102 if(!IsSilentFile())RootBaseDir()->cd();
1105 for (
UInt_t i=0; i<methods->size(); i++) {
1125 if( !methCat )
Log() << kFATAL <<
"Method with type kCategory cannot be casted to MethodCategory. /Factory" <<
Endl;
1155 if (fMethodsMap.empty()) {
1156 Log() << kINFO <<
"...nothing found to test" <<
Endl;
1159 std::map<TString,MVector*>::iterator itrMap;
1161 for(itrMap = fMethodsMap.begin();itrMap != fMethodsMap.end();itrMap++)
1163 MVector *methods=itrMap->second;
1164 MVector::iterator itrMethod;
1167 for( itrMethod = methods->begin(); itrMethod != methods->end(); itrMethod++ ) {
1170 if(mva==0)
continue;
1184 if (methodTitle !=
"") {
1188 Log() << kWARNING <<
"<MakeClass> Could not find classifier \"" << methodTitle
1189 <<
"\" in list" <<
Endl;
1195 MVector *methods=fMethodsMap.find(datasetname)->second;
1196 MVector::const_iterator itrMethod;
1197 for (itrMethod = methods->begin(); itrMethod != methods->end(); itrMethod++) {
1199 if(method==0)
continue;
1212 if (methodTitle !=
"") {
1216 Log() << kWARNING <<
"<PrintHelpMessage> Could not find classifier \"" << methodTitle
1217 <<
"\" in list" <<
Endl;
1223 MVector *methods=fMethodsMap.find(datasetname)->second;
1224 MVector::const_iterator itrMethod ;
1225 for (itrMethod = methods->begin(); itrMethod != methods->end(); itrMethod++) {
1227 if(method==0)
continue;
1239 Log() << kINFO <<
"Evaluating all variables..." <<
Endl;
1244 if (options.
Contains(
"V")) s +=
":V";
1245 this->BookMethod(loader,
"Variable", s );
1257 if (fMethodsMap.empty()) {
1258 Log() << kINFO <<
"...nothing found to evaluate" <<
Endl;
1261 std::map<TString,MVector*>::iterator itrMap;
1263 for(itrMap = fMethodsMap.begin();itrMap != fMethodsMap.end();itrMap++)
1265 MVector *methods=itrMap->second;
1275 Int_t nmeth_used[2] = {0,0};
1277 std::vector<std::vector<TString> > mname(2);
1278 std::vector<std::vector<Double_t> > sig(2),
sep(2), roc(2);
1279 std::vector<std::vector<Double_t> > eff01(2), eff10(2), eff30(2), effArea(2);
1280 std::vector<std::vector<Double_t> > eff01err(2), eff10err(2), eff30err(2);
1281 std::vector<std::vector<Double_t> > trainEff01(2), trainEff10(2), trainEff30(2);
1283 std::vector<std::vector<Float_t> > multiclass_testEff;
1284 std::vector<std::vector<Float_t> > multiclass_trainEff;
1285 std::vector<std::vector<Float_t> > multiclass_testPur;
1286 std::vector<std::vector<Float_t> > multiclass_trainPur;
1289 std::vector<TMatrixD> multiclass_trainConfusionEffB01;
1290 std::vector<TMatrixD> multiclass_trainConfusionEffB10;
1291 std::vector<TMatrixD> multiclass_trainConfusionEffB30;
1292 std::vector<TMatrixD> multiclass_testConfusionEffB01;
1293 std::vector<TMatrixD> multiclass_testConfusionEffB10;
1294 std::vector<TMatrixD> multiclass_testConfusionEffB30;
1296 std::vector<std::vector<Double_t> > biastrain(1);
1297 std::vector<std::vector<Double_t> > biastest(1);
1298 std::vector<std::vector<Double_t> > devtrain(1);
1299 std::vector<std::vector<Double_t> > devtest(1);
1300 std::vector<std::vector<Double_t> > rmstrain(1);
1301 std::vector<std::vector<Double_t> > rmstest(1);
1302 std::vector<std::vector<Double_t> > minftrain(1);
1303 std::vector<std::vector<Double_t> > minftest(1);
1304 std::vector<std::vector<Double_t> > rhotrain(1);
1305 std::vector<std::vector<Double_t> > rhotest(1);
1308 std::vector<std::vector<Double_t> > biastrainT(1);
1309 std::vector<std::vector<Double_t> > biastestT(1);
1310 std::vector<std::vector<Double_t> > devtrainT(1);
1311 std::vector<std::vector<Double_t> > devtestT(1);
1312 std::vector<std::vector<Double_t> > rmstrainT(1);
1313 std::vector<std::vector<Double_t> > rmstestT(1);
1314 std::vector<std::vector<Double_t> > minftrainT(1);
1315 std::vector<std::vector<Double_t> > minftestT(1);
1324 for (MVector::iterator itrMethod =methods->begin(); itrMethod != methods->end(); itrMethod++) {
1327 if(theMethod==0)
continue;
1328 theMethod->
SetFile(fgTargetFile);
1333 doRegression =
kTRUE;
1341 biastest[0] .push_back( bias );
1342 devtest[0] .push_back( dev );
1343 rmstest[0] .push_back( rms );
1344 minftest[0] .push_back( mInf );
1345 rhotest[0] .push_back( rho );
1346 biastestT[0] .push_back( biasT );
1347 devtestT[0] .push_back( devT );
1348 rmstestT[0] .push_back( rmsT );
1349 minftestT[0] .push_back( mInfT );
1352 biastrain[0] .push_back( bias );
1353 devtrain[0] .push_back( dev );
1354 rmstrain[0] .push_back( rms );
1355 minftrain[0] .push_back( mInf );
1356 rhotrain[0] .push_back( rho );
1357 biastrainT[0].push_back( biasT );
1358 devtrainT[0] .push_back( devT );
1359 rmstrainT[0] .push_back( rmsT );
1360 minftrainT[0].push_back( mInfT );
1366 Log() << kDEBUG <<
"\tWrite evaluation histograms to file" <<
Endl;
1374 doMulticlass =
kTRUE;
1375 Log() << kINFO <<
"Evaluate multiclass classification method: " << theMethod->
GetMethodName() <<
Endl;
1392 if (not IsSilentFile()) {
1393 Log() << kDEBUG <<
"\tWrite evaluation histograms to file" <<
Endl;
1416 eff01err[isel].push_back(err);
1418 eff10err[isel].push_back(err);
1420 eff30err[isel].push_back(err);
1429 if (!IsSilentFile()) {
1430 Log() << kDEBUG <<
"\tWrite evaluation histograms to file" <<
Endl;
1438 std::vector<TString> vtemps = mname[0];
1439 std::vector< std::vector<Double_t> > vtmp;
1440 vtmp.push_back( devtest[0] );
1441 vtmp.push_back( devtrain[0] );
1442 vtmp.push_back( biastest[0] );
1443 vtmp.push_back( biastrain[0] );
1444 vtmp.push_back( rmstest[0] );
1445 vtmp.push_back( rmstrain[0] );
1446 vtmp.push_back( minftest[0] );
1447 vtmp.push_back( minftrain[0] );
1448 vtmp.push_back( rhotest[0] );
1449 vtmp.push_back( rhotrain[0] );
1450 vtmp.push_back( devtestT[0] );
1451 vtmp.push_back( devtrainT[0] );
1452 vtmp.push_back( biastestT[0] );
1453 vtmp.push_back( biastrainT[0]);
1454 vtmp.push_back( rmstestT[0] );
1455 vtmp.push_back( rmstrainT[0] );
1456 vtmp.push_back( minftestT[0] );
1457 vtmp.push_back( minftrainT[0]);
1460 devtest[0] = vtmp[0];
1461 devtrain[0] = vtmp[1];
1462 biastest[0] = vtmp[2];
1463 biastrain[0] = vtmp[3];
1464 rmstest[0] = vtmp[4];
1465 rmstrain[0] = vtmp[5];
1466 minftest[0] = vtmp[6];
1467 minftrain[0] = vtmp[7];
1468 rhotest[0] = vtmp[8];
1469 rhotrain[0] = vtmp[9];
1470 devtestT[0] = vtmp[10];
1471 devtrainT[0] = vtmp[11];
1472 biastestT[0] = vtmp[12];
1473 biastrainT[0] = vtmp[13];
1474 rmstestT[0] = vtmp[14];
1475 rmstrainT[0] = vtmp[15];
1476 minftestT[0] = vtmp[16];
1477 minftrainT[0] = vtmp[17];
1478 }
else if (doMulticlass) {
1486 for (
Int_t k=0; k<2; k++) {
1487 std::vector< std::vector<Double_t> > vtemp;
1488 vtemp.push_back( effArea[k] );
1489 vtemp.push_back( eff10[k] );
1490 vtemp.push_back( eff01[k] );
1491 vtemp.push_back( eff30[k] );
1492 vtemp.push_back( eff10err[k] );
1493 vtemp.push_back( eff01err[k] );
1494 vtemp.push_back( eff30err[k] );
1495 vtemp.push_back( trainEff10[k] );
1496 vtemp.push_back( trainEff01[k] );
1497 vtemp.push_back( trainEff30[k] );
1498 vtemp.push_back( sig[k] );
1499 vtemp.push_back(
sep[k] );
1500 vtemp.push_back( roc[k] );
1501 std::vector<TString> vtemps = mname[k];
1503 effArea[k] = vtemp[0];
1504 eff10[k] = vtemp[1];
1505 eff01[k] = vtemp[2];
1506 eff30[k] = vtemp[3];
1507 eff10err[k] = vtemp[4];
1508 eff01err[k] = vtemp[5];
1509 eff30err[k] = vtemp[6];
1510 trainEff10[k] = vtemp[7];
1511 trainEff01[k] = vtemp[8];
1512 trainEff30[k] = vtemp[9];
1528 const Int_t nmeth = methodsNoCuts.size();
1531 if (!doRegression && !doMulticlass ) {
1537 std::vector<Double_t> rvec;
1545 std::vector<TString>* theVars =
new std::vector<TString>;
1546 std::vector<ResultsClassification*> mvaRes;
1547 for (MVector::iterator itrMethod = methodsNoCuts.begin(); itrMethod != methodsNoCuts.end(); itrMethod++, ivar++) {
1552 theVars->back().ReplaceAll(
"MVA_",
"" );
1572 for (
Int_t im=0; im<nmeth; im++) {
1576 Log() << kWARNING <<
"Found NaN return value in event: " << ievt
1577 <<
" for method \"" << methodsNoCuts[im]->GetName() <<
"\"" <<
Endl;
1580 else dvec[im] = retval;
1584 else { tpBkg->
AddRow( dvec ); theMat = overlapB; }
1587 for (
Int_t im=0; im<nmeth; im++) {
1588 for (
Int_t jm=im; jm<nmeth; jm++) {
1589 if ((dvec[im] - rvec[im])*(dvec[jm] - rvec[jm]) > 0) {
1591 if (im != jm) (*theMat)(jm,im)++;
1611 if (corrMatS != 0 && corrMatB != 0) {
1616 for (
Int_t im=0; im<nmeth; im++) {
1617 for (
Int_t jm=0; jm<nmeth; jm++) {
1618 mvaMatS(im,jm) = (*corrMatS)(im,jm);
1619 mvaMatB(im,jm) = (*corrMatB)(im,jm);
1624 std::vector<TString> theInputVars;
1627 for (
Int_t iv=0; iv<nvar; iv++) {
1629 for (
Int_t jm=0; jm<nmeth; jm++) {
1630 varmvaMatS(iv,jm) = (*corrMatS)(nmeth+iv,jm);
1631 varmvaMatB(iv,jm) = (*corrMatB)(nmeth+iv,jm);
1641 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"Inter-MVA correlation matrix (background):" << Endl;
1646 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"Correlations between input variables and MVA response (signal):" <<
Endl;
1650 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"Correlations between input variables and MVA response (background):" << Endl;
1657 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"The following \"overlap\" matrices contain the fraction of events for which " <<
Endl;
1658 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"the MVAs 'i' and 'j' have returned conform answers about \"signal-likeness\"" <<
Endl;
1659 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"An event is signal-like, if its MVA output exceeds the following value:" <<
Endl;
1661 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"which correspond to the working point: eff(signal) = 1 - eff(background)" <<
Endl;
1664 if (nmeth != (
Int_t)methods->size())
1665 Log() << kINFO <<
Form(
"Dataset[%s] : ",method->
fDataSetInfo.
GetName())<<
"Note: no correlations and overlap with cut method are provided at present" <<
Endl;
1697 TString hLine =
"--------------------------------------------------------------------------------------------------";
1698 Log() << kINFO <<
"Evaluation results ranked by smallest RMS on test sample:" <<
Endl;
1699 Log() << kINFO <<
"(\"Bias\" quotes the mean deviation of the regression from true target." <<
Endl;
1700 Log() << kINFO <<
" \"MutInf\" is the \"Mutual Information\" between regression and target." <<
Endl;
1701 Log() << kINFO <<
" Indicated by \"_T\" are the corresponding \"truncated\" quantities ob-" <<
Endl;
1702 Log() << kINFO <<
" tained when removing events deviating more than 2sigma from average.)" <<
Endl;
1703 Log() << kINFO << hLine <<
Endl;
1705 Log() << kINFO << hLine <<
Endl;
1707 for (
Int_t i=0; i<nmeth_used[0]; i++) {
1709 if(theMethod==0)
continue;
1711 Log() << kINFO <<
Form(
"%-20s %-15s:%#9.3g%#9.3g%#9.3g%#9.3g | %#5.3f %#5.3f",
1713 (
const char*)mname[0][i],
1714 biastest[0][i], biastestT[0][i],
1715 rmstest[0][i], rmstestT[0][i],
1716 minftest[0][i], minftestT[0][i] )
1719 Log() << kINFO << hLine <<
Endl;
1721 Log() << kINFO <<
"Evaluation results ranked by smallest RMS on training sample:" <<
Endl;
1722 Log() << kINFO <<
"(overtraining check)" <<
Endl;
1723 Log() << kINFO << hLine <<
Endl;
1724 Log() << kINFO <<
"DataSet Name: MVA Method: <Bias> <Bias_T> RMS RMS_T | MutInf MutInf_T" <<
Endl;
1725 Log() << kINFO << hLine <<
Endl;
1727 for (
Int_t i=0; i<nmeth_used[0]; i++) {
1729 if(theMethod==0)
continue;
1730 Log() << kINFO <<
Form(
"%-20s %-15s:%#9.3g%#9.3g%#9.3g%#9.3g | %#5.3f %#5.3f",
1732 (
const char*)mname[0][i],
1733 biastrain[0][i], biastrainT[0][i],
1734 rmstrain[0][i], rmstrainT[0][i],
1735 minftrain[0][i], minftrainT[0][i] )
1738 Log() << kINFO << hLine <<
Endl;
1740 }
else if (doMulticlass) {
1746 "-------------------------------------------------------------------------------------------------------";
1785 TString header1 =
Form(
"%-15s%-15s%-15s%-15s%-15s%-15s",
"Dataset",
"MVA Method",
"ROC AUC",
"Sig eff@B=0.01",
1786 "Sig eff@B=0.10",
"Sig eff@B=0.30");
1787 TString header2 =
Form(
"%-15s%-15s%-15s%-15s%-15s%-15s",
"Name:",
"/ Class:",
"test (train)",
"test (train)",
1788 "test (train)",
"test (train)");
1790 Log() << kINFO <<
"1-vs-rest performance metrics per class" <<
Endl;
1791 Log() << kINFO << hLine <<
Endl;
1793 Log() << kINFO <<
"Considers the listed class as signal and the other classes" <<
Endl;
1794 Log() << kINFO <<
"as background, reporting the resulting binary performance." <<
Endl;
1795 Log() << kINFO <<
"A score of 0.820 (0.850) means 0.820 was acheived on the" <<
Endl;
1796 Log() << kINFO <<
"test set and 0.850 on the training set." <<
Endl;
1799 Log() << kINFO << header1 <<
Endl;
1800 Log() << kINFO << header2 <<
Endl;
1801 for (
Int_t k = 0; k < 2; k++) {
1802 for (
Int_t i = 0; i < nmeth_used[k]; i++) {
1804 mname[k][i].ReplaceAll(
"Variable_",
"");
1807 const TString datasetName = itrMap->first;
1808 const TString mvaName = mname[k][i];
1811 if (theMethod == 0) {
1817 Log() << kINFO << row <<
Endl;
1818 Log() << kINFO <<
"------------------------------" <<
Endl;
1821 for (
UInt_t iClass = 0; iClass < numClasses; ++iClass) {
1835 const TString rocaucCmp =
Form(
"%5.3f (%5.3f)", rocaucTest, rocaucTrain);
1836 const TString effB01Cmp =
Form(
"%5.3f (%5.3f)", effB01Test, effB01Train);
1837 const TString effB10Cmp =
Form(
"%5.3f (%5.3f)", effB10Test, effB10Train);
1838 const TString effB30Cmp =
Form(
"%5.3f (%5.3f)", effB30Test, effB30Train);
1839 row =
Form(
"%-15s%-15s%-15s%-15s%-15s%-15s",
"", className.
Data(), rocaucCmp.
Data(), effB01Cmp.
Data(),
1840 effB10Cmp.
Data(), effB30Cmp.
Data());
1841 Log() << kINFO << row <<
Endl;
1843 delete rocCurveTrain;
1844 delete rocCurveTest;
1849 Log() << kINFO << hLine <<
Endl;
1854 auto printMatrix = [](
TMatrixD const &matTraining,
TMatrixD const &matTesting, std::vector<TString> classnames,
1864 for (
UInt_t iCol = 0; iCol < numClasses; ++iCol) {
1865 header +=
Form(
" %-14s", classnames[iCol].Data());
1866 headerInfo +=
Form(
" %-14s",
" test (train)");
1868 stream << kINFO << header <<
Endl;
1869 stream << kINFO << headerInfo <<
Endl;
1871 for (
UInt_t iRow = 0; iRow < numClasses; ++iRow) {
1872 stream << kINFO <<
Form(
" %-14s", classnames[iRow].Data());
1874 for (
UInt_t iCol = 0; iCol < numClasses; ++iCol) {
1876 stream << kINFO <<
Form(
" %-14s",
"-");
1878 Double_t trainValue = matTraining[iRow][iCol];
1879 Double_t testValue = matTesting[iRow][iCol];
1880 TString entry =
Form(
"%-5.3f (%-5.3f)", testValue, trainValue);
1881 stream << kINFO <<
Form(
" %-14s", entry.
Data());
1884 stream << kINFO <<
Endl;
1889 Log() << kINFO <<
"Confusion matrices for all methods" <<
Endl;
1890 Log() << kINFO << hLine <<
Endl;
1892 Log() << kINFO <<
"Does a binary comparison between the two classes given by a " <<
Endl;
1893 Log() << kINFO <<
"particular row-column combination. In each case, the class " <<
Endl;
1894 Log() << kINFO <<
"given by the row is considered signal while the class given " <<
Endl;
1895 Log() << kINFO <<
"by the column index is considered background." <<
Endl;
1897 for (
UInt_t iMethod = 0; iMethod < methods->size(); ++iMethod) {
1899 if (theMethod ==
nullptr) {
1904 std::vector<TString> classnames;
1905 for (
UInt_t iCls = 0; iCls < numClasses; ++iCls) {
1909 <<
"=== Showing confusion matrix for method : " <<
Form(
"%-15s", (
const char *)mname[0][iMethod])
1911 Log() << kINFO <<
"(Signal Efficiency for Background Efficiency 0.01%)" <<
Endl;
1912 Log() << kINFO <<
"---------------------------------------------------" <<
Endl;
1913 printMatrix(multiclass_testConfusionEffB01[iMethod], multiclass_trainConfusionEffB01[iMethod], classnames,
1917 Log() << kINFO <<
"(Signal Efficiency for Background Efficiency 0.10%)" <<
Endl;
1918 Log() << kINFO <<
"---------------------------------------------------" <<
Endl;
1919 printMatrix(multiclass_testConfusionEffB10[iMethod], multiclass_trainConfusionEffB10[iMethod], classnames,
1923 Log() << kINFO <<
"(Signal Efficiency for Background Efficiency 0.30%)" <<
Endl;
1924 Log() << kINFO <<
"---------------------------------------------------" <<
Endl;
1925 printMatrix(multiclass_testConfusionEffB30[iMethod], multiclass_trainConfusionEffB30[iMethod], classnames,
1929 Log() << kINFO << hLine <<
Endl;
1935 Log().EnableOutput();
1938 TString hLine =
"------------------------------------------------------------------------------------------"
1939 "-------------------------";
1940 Log() << kINFO <<
"Evaluation results ranked by best signal efficiency and purity (area)" <<
Endl;
1941 Log() << kINFO << hLine <<
Endl;
1942 Log() << kINFO <<
"DataSet MVA " <<
Endl;
1943 Log() << kINFO <<
"Name: Method: ROC-integ" <<
Endl;
1948 Log() << kDEBUG << hLine <<
Endl;
1949 for (
Int_t k = 0; k < 2; k++) {
1950 if (k == 1 && nmeth_used[k] > 0) {
1951 Log() << kINFO << hLine <<
Endl;
1952 Log() << kINFO <<
"Input Variables: " << Endl << hLine <<
Endl;
1954 for (
Int_t i = 0; i < nmeth_used[k]; i++) {
1955 TString datasetName = itrMap->first;
1956 TString methodName = mname[k][i];
1963 if (theMethod == 0) {
1969 std::vector<Bool_t> *mvaResType =
1973 if (mvaResType->size() != 0) {
1974 rocIntegral = GetROCIntegral(datasetName, methodName);
1977 if (
sep[k][i] < 0 || sig[k][i] < 0) {
1979 Log() << kINFO <<
Form(
"%-13s %-15s: %#1.3f", datasetName.
Data(), methodName.
Data(), effArea[k][i])
1991 Log() << kINFO <<
Form(
"%-13s %-15s: %#1.3f", datasetName.
Data(), methodName.
Data(), rocIntegral)
2005 Log() << kINFO << hLine <<
Endl;
2007 Log() << kINFO <<
"Testing efficiency compared to training efficiency (overtraining check)" <<
Endl;
2008 Log() << kINFO << hLine <<
Endl;
2010 <<
"DataSet MVA Signal efficiency: from test sample (from training sample) "
2012 Log() << kINFO <<
"Name: Method: @B=0.01 @B=0.10 @B=0.30 "
2014 Log() << kINFO << hLine <<
Endl;
2015 for (
Int_t k = 0; k < 2; k++) {
2016 if (k == 1 && nmeth_used[k] > 0) {
2017 Log() << kINFO << hLine <<
Endl;
2018 Log() << kINFO <<
"Input Variables: " << Endl << hLine <<
Endl;
2020 for (
Int_t i = 0; i < nmeth_used[k]; i++) {
2021 if (k == 1) mname[k][i].ReplaceAll(
"Variable_",
"");
2023 if (theMethod == 0)
continue;
2025 Log() << kINFO <<
Form(
"%-20s %-15s: %#1.3f (%#1.3f) %#1.3f (%#1.3f) %#1.3f (%#1.3f)",
2027 trainEff01[k][i], eff10[k][i], trainEff10[k][i], eff30[k][i], trainEff30[k][i])
2031 Log() << kINFO << hLine <<
Endl;
2034 if (
gTools().CheckForSilentOption(GetOptions()))
Log().InhibitOutput();
2039 std::list<TString> datasets;
2040 for (
Int_t k=0; k<2; k++) {
2041 for (
Int_t i=0; i<nmeth_used[k]; i++) {
2043 if(theMethod==0)
continue;
2046 if(std::find(datasets.begin(), datasets.end(), theMethod->
fDataSetInfo.
GetName()) == datasets.end())
2065 fModelPersistence=
kFALSE;
2070 if(vitype==VIType::kShort)
2071 return EvaluateImportanceShort(loader,theMethod,methodTitle,theOption);
2072 else if(vitype==VIType::kAll)
2073 return EvaluateImportanceAll(loader,theMethod,methodTitle,theOption);
2074 else if(vitype==VIType::kRandom&&nbits>10)
2076 return EvaluateImportanceRandom(loader,
pow(2,nbits),theMethod,methodTitle,theOption);
2079 std::cerr<<
"Error in Variable Importance: Random mode require more that 10 variables in the dataset."<<std::endl;
2096 uint64_t range =
pow(2, nbits);
2099 std::vector<Double_t> importances(nbits);
2101 std::vector<Double_t> ROC(range);
2103 for (
int i = 0; i < nbits; i++)importances[i] = 0;
2106 for ( x = 1; x <range ; x++) {
2108 std::bitset<VIBITS> xbitset(x);
2109 if (x == 0)
continue;
2115 for (
int index = 0; index < nbits; index++) {
2116 if (xbitset[index]) seedloader->
AddVariable(varNames[index],
'F');
2123 BookMethod(seedloader, theMethod, methodTitle, theOption);
2128 EvaluateAllMethods();
2131 ROC[
x] = GetROCIntegral(xbitset.to_string(), methodTitle);
2138 this->DeleteAllMethods();
2140 fMethodsMap.clear();
2145 for ( x = 0; x <range ; x++)
2148 for (uint32_t i = 0; i <
VIBITS; ++i) {
2151 std::bitset<VIBITS> ybitset(y);
2157 importances[ny] = SROC - 0.5;
2163 importances[ny] += SROC - SSROC;
2169 std::cout<<
"--- Variable Importance Results (All)"<<std::endl;
2170 return GetImportance(nbits,importances,varNames);
2173 static long int sum(
long int i)
2176 for(
long int n=0;
n<i;
n++) _sum+=
pow(2,
n);
2191 long int range =
sum(nbits);
2194 std::vector<Double_t> importances(nbits);
2195 for (
int i = 0; i < nbits; i++)importances[i] = 0;
2201 std::bitset<VIBITS> xbitset(x);
2202 if (x == 0)
Log()<<kFATAL<<
"Error: need at least one variable.";
2209 for (
int index = 0; index < nbits; index++) {
2210 if (xbitset[index]) seedloader->
AddVariable(varNames[index],
'F');
2217 BookMethod(seedloader, theMethod, methodTitle, theOption);
2222 EvaluateAllMethods();
2225 SROC = GetROCIntegral(xbitset.to_string(), methodTitle);
2232 this->DeleteAllMethods();
2233 fMethodsMap.clear();
2237 for (uint32_t i = 0; i <
VIBITS; ++i) {
2240 std::bitset<VIBITS> ybitset(y);
2246 importances[ny] = SROC - 0.5;
2253 for (
int index = 0; index < nbits; index++) {
2254 if (ybitset[index]) subseedloader->
AddVariable(varNames[index],
'F');
2261 BookMethod(subseedloader, theMethod, methodTitle, theOption);
2266 EvaluateAllMethods();
2269 SSROC = GetROCIntegral(ybitset.to_string(), methodTitle);
2270 importances[ny] += SROC - SSROC;
2276 delete subseedloader;
2277 this->DeleteAllMethods();
2278 fMethodsMap.clear();
2281 std::cout<<
"--- Variable Importance Results (Short)"<<std::endl;
2282 return GetImportance(nbits,importances,varNames);
2298 long int range =
pow(2, nbits);
2301 std::vector<Double_t> importances(nbits);
2303 for (
int i = 0; i < nbits; i++)importances[i] = 0;
2307 x = rangen -> Integer(range);
2309 std::bitset<32> xbitset(x);
2310 if (x == 0)
continue;
2317 for (
int index = 0; index < nbits; index++) {
2318 if (xbitset[index]) seedloader->
AddVariable(varNames[index],
'F');
2325 BookMethod(seedloader, theMethod, methodTitle, theOption);
2330 EvaluateAllMethods();
2333 SROC = GetROCIntegral(xbitset.to_string(), methodTitle);
2341 this->DeleteAllMethods();
2342 fMethodsMap.clear();
2346 for (uint32_t i = 0; i < 32; ++i) {
2349 std::bitset<32> ybitset(y);
2355 importances[ny] = SROC - 0.5;
2356 importances_norm += importances[ny];
2364 for (
int index = 0; index < nbits; index++) {
2365 if (ybitset[index]) subseedloader->
AddVariable(varNames[index],
'F');
2372 BookMethod(subseedloader, theMethod, methodTitle, theOption);
2377 EvaluateAllMethods();
2380 SSROC = GetROCIntegral(ybitset.to_string(), methodTitle);
2381 importances[ny] += SROC - SSROC;
2387 delete subseedloader;
2388 this->DeleteAllMethods();
2389 fMethodsMap.clear();
2393 std::cout<<
"--- Variable Importance Results (Random)"<<std::endl;
2394 return GetImportance(nbits,importances,varNames);
2401 TH1F *vih1 =
new TH1F(
"vih1",
"", nbits, 0, nbits);
2406 for (
int i = 0; i < nbits; i++) {
2407 normalization = normalization + importances[i];
2417 for (
Int_t i = 1; i < nbits + 1; i++) {
2418 x_ie[i - 1] = (i - 1) * 1.;
2419 roc = 100.0 * importances[i - 1] / normalization;
2421 std::cout<<
"--- "<<varNames[i-1]<<
" = "<<roc<<
" %"<<std::endl;
IMethod * Create(const std::string &name, const TString &job, const TString &title, DataSetInfo &dsi, const TString &option)
creates the method if needed based on the method name using the creator function the factory has stor...
static ClassifierFactory & Instance()
access to the ClassifierFactory singleton creates the instance if needed
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
void SetModelPersistence(Bool_t status)
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 SetLineWidth(Width_t lwidth)
Set the line width.
TH1F * GetImportance(const int nbits, std::vector< Double_t > importances, std::vector< TString > varNames)
DataSetManager * fDataSetManager
static long int sum(long int i)
Principal Components Analysis (PCA)
MethodBase * BookMethod(DataLoader *loader, TString theMethodName, TString methodTitle, TString theOption="")
Book a classifier or regression method.
Double_t GetEffSForEffB(Double_t effB, const UInt_t num_points=41)
Calculate the signal efficiency (sensitivity) for a given background efficiency (sensitivity).
Random number generator class based on M.
MsgLogger & Endl(MsgLogger &ml)
Singleton class for Global types used by TMVA.
void AddOutput(Types::ETreeType type, Types::EAnalysisType analysisType)
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
void EvaluateAllVariables(DataLoader *loader, TString options="")
Iterates over all MVA input variables and evaluates them.
Bool_t fROC
enable to calculate corelations
TList * GetListOfGraphs() const
Double_t GetROCIntegral(const UInt_t points=41)
Calculates the ROC integral (AUC)
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
TString & ReplaceAll(const TString &s1, const TString &s2)
const char * GetName() const
R__EXTERN TStyle * gStyle
static Types & Instance()
the the single instance of "Types" if existing already, or create it (Singleton)
void CheckForUnusedOptions() const
checks for unused options in option string
virtual void WriteEvaluationHistosToFile(Types::ETreeType treetype)
writes all MVA evaluation histograms to file
UInt_t GetNClasses() const
TH1F * EvaluateImportanceShort(DataLoader *loader, Types::EMVA theMethod, TString methodTitle, const char *theOption="")
virtual std::map< TString, Double_t > OptimizeTuningParameters(TString fomType="ROCIntegral", TString fitType="FitGA")
call the Optimizer with the set of parameters and ranges that are meant to be tuned.
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual int MakeDirectory(const char *name)
Make a directory.
DataSetInfo & DefaultDataSetInfo()
default creation
virtual void MakeClass(const TString &classFileName=TString("")) const =0
UInt_t GetNTargets() const
Virtual base Class for all MVA method.
overwrite existing object with same name
TString fTransformations
option string given by construction (presently only "V")
1-D histogram with a float per channel (see TH1 documentation)}
Ranking for variables in method (implementation)
void ToLower()
Change string to lower-case.
void TrainAllMethods()
Iterates through all booked methods and calls training.
virtual void SetTitle(const char *title="")
Set graph title.
void DataLoaderCopy(TMVA::DataLoader *des, TMVA::DataLoader *src)
TMultiGraph * GetROCCurveAsMultiGraph(DataLoader *loader, UInt_t iClass)
Generate a collection of graphs, for all methods for a given class.
void WriteDataInformation(DataSetInfo &fDataSetInfo)
void SetSilentFile(Bool_t status)
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)=0
void CenterTitle(Bool_t center=kTRUE)
Center axis title.
UInt_t GetNVariables() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
IMethod * GetMethod(const TString &datasetname, const TString &title) const
Returns pointer to MVA that corresponds to given method title.
DataSet * GetDataSet() const
returns data set
void AddVariable(const TString &expression, const TString &title, const TString &unit, char type='F', Double_t min=0, Double_t max=0)
user inserts discriminating variable in data set info
TH1F * EvaluateImportanceRandom(DataLoader *loader, UInt_t nseeds, Types::EMVA theMethod, TString methodTitle, const char *theOption="")
const TString & GetMethodName() const
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
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
virtual void SetBarWidth(Float_t width=0.5)
TGraph * GetROCCurve(DataLoader *loader, TString theMethodName, Bool_t setTitles=kTRUE, UInt_t iClass=0)
Argument iClass specifies the class to generate the ROC curve in a multiclass setting.
virtual const char * GetName() const
Returns name of object.
const char * Data() const
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates).
Types::EAnalysisType GetAnalysisType() const
static void InhibitOutput()
static void SetIsTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
DataSetInfo & fDataSetInfo
TAxis * GetXaxis()
Get x axis of the graph.
TH1F * EvaluateImportance(DataLoader *loader, VIType vitype, Types::EMVA theMethod, TString methodTitle, const char *theOption="")
Evaluate Variable Importance.
Bool_t IsSignal(const Event *ev) const
Bool_t fModelPersistence
the training type
TTree * GetTree(Types::ETreeType type)
create the test/trainings tree with all the variables, the weights, the classes, the targets...
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)
double pow(double, double)
Bool_t DoMulticlass() const
virtual void ParseOptions()
options parser
void SetupMethod()
setup of methods
void SetMinType(EMsgType minType)
void SetDrawProgressBar(Bool_t d)
TH1F * EvaluateImportanceAll(DataLoader *loader, Types::EMVA theMethod, TString methodTitle, const char *theOption="")
Types::EMVA GetMethodType() const
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Bool_t IsModelPersistence()
Class that contains all the data information.
TH1F * GetHistogram()
Returns a pointer to the histogram used to draw the axis.
virtual void Draw(Option_t *chopt="")
Draw this multigraph with its current attributes.
virtual Double_t GetEfficiency(const TString &, Types::ETreeType, Double_t &err)
fill background efficiency (resp.
void CreateVariableTransforms(const TString &trafoDefinition, TMVA::DataSetInfo &dataInfo, TMVA::TransformationHandler &transformationHandler, TMVA::MsgLogger &log)
void PrintHelpMessage(const TString &datasetname, const TString &methodTitle="") const
Print predefined help message of classifier.
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Class for boosting a TMVA method.
const TMatrixD * GetCovarianceMatrix() const
TMatrixT< Double_t > TMatrixD
const Int_t MinNoTrainingEvents
Class that contains all the data information.
virtual ~Factory()
Destructor.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
std::map< TString, Double_t > OptimizeAllMethods(TString fomType="ROCIntegral", TString fitType="FitGA")
Iterates through all booked methods and sees if they use parameter tuning and if so.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Results * GetResults(const TString &, Types::ETreeType type, Types::EAnalysisType analysistype)
std::string GetMethodName(TCppMethod_t)
TAxis * GetXaxis() const
Get x axis of the graph.
Double_t GetROCIntegral(DataLoader *loader, TString theMethodName, UInt_t iClass=0)
Calculate the integral of the ROC curve, also known as the area under curve (AUC), for a given method.
DataSetManager * GetDataSetManager()
Service class for 2-Dim histogram classes.
R__EXTERN TSystem * gSystem
virtual void AddRow(const Double_t *x)
Add a data point and update the covariance matrix.
Long64_t GetNEvtSigTest()
return number of signal test events in dataset
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Bool_t fCorrelations
verbose mode
void EvaluateAllMethods(void)
Iterates over all MVAs that have been booked, and calls their evaluation methods. ...
class TMVA::Config::VariablePlotting fVariablePlotting
ClassInfo * GetClassInfo(Int_t clNum) const
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...
const TMatrixD * CorrelationMatrix(const TString &className) const
char * Form(const char *fmt,...)
DataSetManager * fDataSetManager
TAxis * GetYaxis()
Get y axis of the graph.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
virtual const char * GetName() const
Returns name of object.
virtual Double_t GetSignificance() const
compute significance of mean difference
void Greetings()
Print welcome message.
This is the main MVA steering class.
const TCut & GetCut(Int_t i) const
virtual void MakePrincipals()
Perform the principal components analysis.
void SetBoostedMethodName(TString methodName)
void SetVerbose(Bool_t v=kTRUE)
Long64_t GetNEvtBkgdTest()
return number of background test events in dataset
virtual void SetTitleSize(Float_t size=0.04)
Set size of axis title The size is expressed in per cent of the pad width.
TH2 * CreateCorrelationMatrixHist(const TMatrixD *m, const TString &hName, const TString &hTitle) const
Class for categorizing the phase space.
const TString & GetSplitOptions() const
const Event * GetEvent() const
void SetCurrentType(Types::ETreeType type) const
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background
virtual const char * GetName() const
Returns name of object.
virtual void CheckSetup()
check may be overridden by derived class (sometimes, eg, fitters are used which can only be implement...
ROCCurve * GetROC(DataLoader *loader, TString theMethodName, UInt_t iClass=0, Types::ETreeType type=Types::kTesting)
Private method to generate a ROCCurve instance for a given method.
virtual void PrintHelpMessage() const =0
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 ...
Class which takes the results of a multiclass classification.
void SetFile(TFile *file)
Long64_t GetNEvents(Types::ETreeType type=Types::kMaxTreeType) const
Bool_t HasMethod(const TString &datasetname, const TString &title) const
Checks whether a given method name is defined for a given dataset.
static constexpr double s
DataSetInfo & DataInfo() const
VariableInfo & GetVariableInfo(Int_t i)
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
void AddPreDefVal(const T &)
void ProcessSetup()
process all options the "CheckForUnusedOptions" is done in an independent call, since it may be overr...
ostringstream derivative to redirect and format output
TAxis * GetYaxis() const
Get y axis of the graph.
void SetUseColor(Bool_t uc)
void SetConfigName(const char *n)
Interface for all concrete MVA method implementations.
void SetSource(const std::string &source)
Bool_t DoRegression() const
void SetTitleXOffset(Float_t offset=1)
virtual void MakeClass(const TString &datasetname, const TString &methodTitle="") const
virtual Double_t GetSeparation(TH1 *, TH1 *) const
compute "separation" defined as
TGraph * GetROCCurve(const UInt_t points=100)
Returns a new TGraph containing the ROC curve.
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 ...
DataSetManager * fDataSetManager
Bool_t Verbose(void) const
Factory(TString theJobName, TFile *theTargetFile, TString theOption="")
Standard constructor.
DataInputHandler & DataInput()
void PrintHelpMessage() const
prints out method-specific help method
Class that is the base-class for a vector of result.
const TString & GetOptions() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void SetWeightFileDir(TString fileDir)
set directory of weight file
A Graph is a graphics object made of two arrays X and Y with npoints each.
void DeleteAllMethods(void)
Delete methods.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
virtual Double_t GetTrainingEfficiency(const TString &)
const std::vector< Event * > & GetEventCollection(Types::ETreeType type=Types::kMaxTreeType) const
std::vector< TString > GetListOfVariables() const
returns list of variables
Long64_t GetNTrainingEvents() const
Types::EAnalysisType fAnalysisType
jobname, used as extension in weight file names
virtual void SetTitle(const char *title)
Change (i.e.
std::vector< IMethod * > MVector
Double_t GetSignalReferenceCut() const
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
virtual void Print() const
get maximum length of variable names
TString GetMethodTypeName() const
const TString & GetLabel() const
virtual TMatrixD GetMulticlassConfusionMatrix(Double_t effB, Types::ETreeType type)
Construct a confusion matrix for a multiclass classifier.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
void SetTestvarName(const TString &v="")
virtual void TestClassification()
initialization
virtual void SetAnalysisType(Types::EAnalysisType type)
Class that is the base-class for a vector of result.
void SetConfigDescription(const char *d)
Bool_t fVerbose
List of transformations to test.
const TString & GetTestvarName() const