105 std::vector<TTreeFormula*>::iterator
formIt = fCatFormulas.
begin();
106 std::vector<TTreeFormula*>::iterator
lastF = fCatFormulas.
end();
154 if(fModelPersistence)
method->SetWeightFileDir(fFileDir);
155 method->SetModelPersistence(fModelPersistence);
156 method->SetAnalysisType( fAnalysisType );
161 method->SetSilentFile(IsSilentFile());
167 if (dir != 0)
method->SetMethodBaseDir( dir );
180 fMethods.push_back(
method);
181 fCategoryCuts.push_back(
theCut);
210 fDataSetManager->AddDataSetInfo(*
dsi);
213 std::vector<VariableInfo>::iterator
itrVarInfo;
225 std::vector<UInt_t>
varMap;
242 varMap.push_back(counter);
254 varMap.push_back(counter);
262 Log() << kFATAL <<
"The variable " <<
itrVariables->Data() <<
" was not found and could not be added " <<
Endl;
270 dsi->AddVariable(
oldDSI.GetVariableInfos()[i]);
276 fVarMaps.push_back(
varMap);
283 className =
oldDSI.GetClassInfo(i)->GetName();
284 dsi->AddClass(className);
287 dsi->SetWeightExpression(
oldDSI.GetWeightExpression(i),className);
291 dsi->SetSplitOptions(
oldDSI.GetSplitOptions());
320 std::vector<VariableInfo>::const_iterator
viIt;
321 const std::vector<VariableInfo>& vars =
dsi.GetVariableInfos();
322 const std::vector<VariableInfo>&
specs =
dsi.GetSpectatorInfos();
326 if(
viIt->GetExternalLink() == 0 ) {
331 if(
viIt->GetExternalLink() == 0 ) {
344 fCatTree =
new TTree(
TString::Format(
"Circ%s",GetMethodName().Data()).Data(),
"Circular Tree for categorization");
345 fCatTree->SetCircular(1);
354 if(
vi.GetVarType()==
'C')
continue;
358 for(
UInt_t cat=0; cat!=fCategoryCuts.size(); ++cat) {
374 Log() << kINFO <<
"Train all sub-classifiers for "
378 if (fMethods.empty()) {
379 Log() << kINFO <<
"...nothing found to train" <<
Endl;
383 std::vector<IMethod*>::iterator
itrMethod;
390 mva->SetAnalysisType( analysisType );
391 if (!
mva->HasAnalysisType( analysisType,
392 mva->DataInfo().GetNClasses(),
393 mva->DataInfo().GetNTargets() ) ) {
394 Log() << kWARNING <<
"Method " <<
mva->GetMethodTypeName() <<
" is not capable of handling " ;
396 Log() <<
"regression with " <<
mva->DataInfo().GetNTargets() <<
" targets." <<
Endl;
398 Log() <<
"classification with " <<
mva->DataInfo().GetNClasses() <<
" classes." <<
Endl;
404 Log() << kINFO <<
"Train method: " <<
mva->GetMethodName() <<
" for "
407 Log() << kINFO <<
"Training finished" <<
Endl;
411 Log() << kWARNING <<
"Method " <<
mva->GetMethodName()
412 <<
" not trained (training tree has less entries ["
413 <<
mva->Data()->GetNTrainingEvents()
416 Log() << kERROR <<
" w/o training/test events for that category, I better stop here and let you fix " <<
Endl;
417 Log() << kFATAL <<
"that one first, otherwise things get too messy later ... " <<
Endl;
425 Log() << kINFO <<
"Begin ranking of input variables..." <<
Endl;
433 Log() << kINFO <<
"No variable ranking supplied by classifier: "
450 for (
UInt_t i=0; i<fMethods.size(); i++) {
476 Log() << kINFO <<
"Recreating sub-classifiers from XML-file " <<
Endl;
499 Log() << kFATAL <<
"Could not create sub-method " <<
method <<
" from XML." <<
Endl;
504 fMethods.push_back(
method);
514 std::vector<VariableInfo>& spectators=
primaryDSI.GetSpectatorInfos();
515 std::vector<VariableInfo>::iterator
itrVarInfo;
529 InitCircularTree(DataInfo());
551 Log() <<
"This method allows to define different categories of events. The" <<
Endl;
552 Log() <<
"categories are defined via cuts on the variables. For each" <<
Endl;
553 Log() <<
"category, a different classifier and set of variables can be" <<
Endl;
554 Log() <<
"specified. The categories which are defined for this method must" <<
Endl;
555 Log() <<
"be disjoint." <<
Endl;
575 Log() << kFATAL <<
"Large method index " <<
methodIdx <<
", number of category formulas = "
576 << fCatFormulas.size() <<
Endl;
585 if (
methodIdx>=fCategorySpecIdx.size()) {
586 Log() << kFATAL <<
"Unknown method index " <<
methodIdx <<
" maximum allowed index="
587 << fCategorySpecIdx.size() <<
Endl;
601 if (fMethods.empty())
return 0;
609 for (
UInt_t i=0; i<fMethods.size(); ++i) {
610 if (PassesCut(
ev, i)) {
617 Log() << kWARNING <<
"Event does not lie within the cut of any sub-classifier." <<
Endl;
622 Log() << kFATAL <<
"The defined categories are not disjoint." <<
Endl;
629 ev->SetVariableArrangement(0);
631 Log() << kDEBUG <<
"Event is for method " <<
methodToUse <<
" spectator is " <<
ev->GetSpectator(0) <<
" "
632 << fVarMaps[0][0] <<
" classID " << DataInfo().IsSignal(
ev) <<
" value " <<
mvaValue
633 <<
" type " << Data()->GetCurrentType() <<
Endl;
645 std::vector<Double_t>
result;
647 Info(
"GetMVaValues",
"Evaluate MethodCategory for %d events type %d on the dataset %s",
int(
lastEvt -
firstEvt),
648 (
int)Data()->GetCurrentType(), DataInfo().GetName());
650 if (fMethods.empty())
656 std::vector<std::vector<Double_t>> mvaValues(fMethods.size());
657 for (
UInt_t i = 0; i < fMethods.size(); ++i) {
662 ev->SetVariableArrangement(&fVarMaps[i]);
680 for (
UInt_t i = 0; i < fMethods.size(); ++i) {
681 if (PassesCut(
ev, i)) {
688 Log() << kWARNING <<
"Event does not lie within the cut of any sub-classifier." <<
Endl;
693 Log() << kFATAL <<
"The defined categories are not disjoint." <<
Endl;
701 ev->SetVariableArrangement(
nullptr);
711 if (fMethods.empty())
720 for (
UInt_t i = 0; i < fMethods.size(); ++i) {
721 if (PassesCut(
ev, i)) {
728 Log() << kWARNING <<
"Event does not lie within the cut of any sub-classifier." <<
Endl;
733 Log() << kFATAL <<
"The defined categories are not disjoint." <<
Endl;
738 Log() << kFATAL <<
"method not found in Category Regression method" <<
Endl;
744 ev->SetVariableArrangement(
nullptr);
761 for (
UInt_t i=0; i<fMethods.size(); ++i) {
762 if (PassesCut(
ev, i)) {
769 Log() << kWARNING <<
"Event does not lie within the cut of any sub-classifier." <<
Endl;
774 Log() << kFATAL <<
"The defined categories are not disjoint." <<
Endl;
779 Log() << kFATAL <<
"method not found in Category Regression method" <<
Endl;
#define MinNoTrainingEvents
#define REGISTER_METHOD(CLASS)
for example
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
float Float_t
Float 4 bytes (float)
long long Long64_t
Portable signed long integer 8 bytes.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
const_iterator begin() const
const_iterator end() const
A specialized string object used for TTree selections.
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
static ClassifierFactory & Instance()
access to the ClassifierFactory singleton creates the instance if needed
Class that contains all the data information.
Interface for all concrete MVA method implementations.
Virtual base Class for all MVA method.
virtual const std::vector< Float_t > & GetRegressionValues()
virtual const std::vector< Float_t > & GetMulticlassValues()
const TString & GetMethodName() const
friend class MethodCategory
Class for categorizing the phase space.
void InitCircularTree(const DataSetInfo &dsi)
initialize the circular tree
void DeclareOptions() override
options for this method
void ReadWeightsFromXML(void *wghtnode) override
read weights of sub-classifiers of MethodCategory from xml weight file
Bool_t PassesCut(const Event *ev, UInt_t methodIdx)
void Train(void) override
train all sub-classifiers
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t) override
check whether method category has analysis type the method type has to be the same for all sub-method...
const Ranking * CreateRanking() override
no ranking
TMVA::DataSetInfo & CreateCategoryDSI(const TCut &, const TString &, const TString &)
create a DataSetInfo object for a sub-classifier
const std::vector< Float_t > & GetRegressionValues() override
returns the mva value of the right sub-classifier
void Init() override
initialize the method
virtual ~MethodCategory(void)
destructor
void AddWeightsXMLTo(void *parent) const override
create XML description of Category classifier
void ProcessOptions() override
process user options
TMVA::IMethod * AddMethod(const TCut &, const TString &theVariables, Types::EMVA theMethod, const TString &theTitle, const TString &theOptions)
adds sub-classifier for a category
void GetHelpMessage() const override
Get help message text.
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr) override
returns the mva value of the right sub-classifier
std::vector< Double_t > GetMvaValues(Long64_t firstEvt=0, Long64_t lastEvt=-1, Bool_t logProgress=false) override
returns the mva values of the right sub-classifier
const std::vector< Float_t > & GetMulticlassValues() override
returns the mva values of the multi-class right sub-classifier
Virtual base class for combining several TMVA method.
Ranking for variables in method (implementation)
Singleton class for Global types used by TMVA.
static Types & Instance()
The single instance of "Types" if existing already, or create it (Singleton)
Class for type info of MVA input variable.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
A TTree represents a columnar dataset.
create variable transformations
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
MsgLogger & Endl(MsgLogger &ml)