128 if (
n.GetLeft() == 0 ) this->
SetLeft(NULL);
131 if (
n.GetRight() == 0 ) this->
SetRight(NULL);
196 Log() << kINFO <<
"Zero events in purity calculation , return purity=0.5" <<
Endl;
197 std::ostringstream oss;
210 os <<
"< *** " << std::endl;
212 << std::setprecision(6)
229 os <<
"My address is " << (
Longptr_t)
this <<
", ";
234 os <<
" **** > " << std::endl;
243 << std::setprecision(6)
259 <<
" rms: " << this->
GetRMS()
261 if (this->
GetCC() > 10000000000000.) os <<
" CC: " << 100000. << std::endl;
262 else os <<
" CC: " << this->
GetCC() << std::endl;
276 Float_t cutVal, cutType, nsig, nbkg, nEv, nsig_unweighted, nbkg_unweighted, nEv_unweighted;
277 Float_t separationIndex, separationGain, response(-99), cc(0);
278 Int_t depth, ivar, nodeType;
283 if ( depth==-1 ) {
return kFALSE; }
297 >> tmp >> nsig_unweighted
298 >> tmp >> nbkg_unweighted
299 >> tmp >> nEv_unweighted
300 >> tmp >> separationIndex
301 >> tmp >> separationGain
311 >> tmp >> nsig_unweighted
312 >> tmp >> nbkg_unweighted
313 >> tmp >> nEv_unweighted
314 >> tmp >> separationIndex
315 >> tmp >> separationGain
372 GetLeft()->ResetValidationData();
381 os <<
"----------------------" << std::endl
383 <<
"R(t): " <<
GetNodeR() << std::endl
385 <<
"g(t): " <<
GetAlpha() << std::endl
406 else Log() << kFATAL <<
"call to SetCC without trainingInfo" <<
Endl;
416 else Log() << kFATAL <<
"You asked for Min of the event sample in node for variable "
417 << ivar <<
" that is out of range" <<
Endl;
428 else Log() << kFATAL <<
"You asked for Max of the event sample in node for variable "
429 << ivar <<
" that is out of range" <<
Endl;
459 Float_t tempNSigEvents,tempNBkgEvents;
462 if (
gTools().HasAttr(node,
"NCoef")){
479 if(
gTools().HasAttr(node,
"purity") ) {
484 fPurity = tempNSigEvents / (tempNSigEvents + tempNBkgEvents);
543 TTHREAD_TLS_DECL_ARG(
MsgLogger,logger,
"DecisionTreeNode");
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
#define TMVA_VERSION(a, b, c)
void SetNEvents_unweighted(Float_t nev)
set the number of unweighted events that entered the node (during training), if traininfo defined
void SetCC(Double_t cc)
Set CC, if traininfo defined, otherwise Log Fatal.
DTNodeTrainingInfo * fTrainInfo
Bool_t fIsTerminalNode
! flag to set node as terminal (i.e., without deleting its descendants)
virtual ~DecisionTreeNode()
destructor
void SetParent(Node *p) override
Float_t GetNSigEvents_unweighted(void) const
Float_t GetNBkgEvents_unweighted(void) const
return the sum of unweighted backgr weights in the node, or -1 if traininfo undefined
void SetNodeType(Int_t t)
set node type: 1 signal node, -1 bkg leave, 0 intermediate Node
Int_t fNodeType
Type of node: -1 == Bkg-leaf, 1 == Signal-leaf, 0 = internal.
Double_t GetSubTreeR() const
return the resubstitution estimate, R(T_t), of the tree rooted at this node, or -1 if traininfo undef...
Float_t GetSeparationIndex(void) const
return the separation index AT this node, or 0 if traininfo undefined
void SetSeparationGain(Float_t sep)
set the separation, or information gained BY this node's selection, if traininfo defined
void SetNBkgEvents(Float_t b)
set the sum of the backgr weights in the node, if traininfo defined
void SetCutType(Bool_t t)
set true: if event variable > cutValue ==> signal , false otherwise
static void SetIsTraining(bool on)
void PrintPrune(std::ostream &os) const
printout of the node (can be read in with ReadDataRecord)
void PrintRecPrune(std::ostream &os) const
recursive printout of the node and its daughters
void SetFisherCoeff(Int_t ivar, Double_t coeff)
set fisher coefficients
Bool_t GoesLeft(const Event &) const override
test event if it descends the tree at this node to the left
void SetSumTarget2(Float_t t2)
set sum target 2, if traininfo defined
Float_t fRMS
response RMS of the regression node
static UInt_t fgTmva_Version_Code
set only when read from weightfile
Short_t fSelector
index of variable used in node selection (decision tree)
Float_t GetNSigEvents(void) const
return the sum of the signal weights in the node, or -1 if traininfo undefined
Float_t fPurity
the node purity
DecisionTreeNode * GetLeft() const override
Double_t GetAlphaMinSubtree() const
return the minimum alpha in the tree rooted at this node, or -1 if traininfo undefined
void SetLeft(Node *l) override
Float_t GetNEvents_unweighted(void) const
return the number of unweighted events that entered the node (during training), or -1 if traininfo un...
DecisionTreeNode * GetRight() const override
UInt_t GetNFisherCoeff() const
void SetSampleMax(UInt_t ivar, Float_t xmax)
set the maximum of variable ivar from the training sample that pass/end up in this node,...
void ClearNodeAndAllDaughters()
clear the nodes (their S/N, Nevents etc), just keep the structure of the tree
static void SetTmvaVersionCode(UInt_t code)
void SetNBValidation(Double_t b)
set number of background events from the pruning validation sample, if traininfo defined
Float_t GetRMS(void) const
return the RMS of the response of the node (for regression)
void SetPurity(void)
return the S/(S+B) (purity) for the node REM: even if nodes with purity 0.01 are very PURE background...
void ReadAttributes(void *node, UInt_t tmva_Version_Code=262657) override
DecisionTreeNode * GetParent() const override
Double_t GetNodeR() const
return the node resubstitution estimate, R(t), for Cost Complexity pruning, or -1 if traininfo undefi...
Float_t fCutValue
cut value applied on this node to discriminate bkg against sig
void AddContentToNode(std::stringstream &s) const override
adding attributes to tree node (well, was used in BinarySearchTree, and somehow I guess someone progr...
void AddAttributesToNode(void *node) const override
add attribute to xml
DecisionTreeNode()
constructor of an essentially "empty" node floating in space
void SetNFisherCoeff(Int_t nvars)
void Print(std::ostream &os) const override
print the node
Short_t GetSelector() const
return index of variable used for discrimination at this node
static UInt_t GetTmvaVersionCode()
void SetNSigEvents(Float_t s)
set the sum of the signal weights in the node, if traininfo defined
Float_t GetResponse(void) const
return the response of the node (for regression)
void ReadContent(std::stringstream &s) override
reading attributes from tree node (well, was used in BinarySearchTree, and somehow I guess someone pr...
Float_t GetCutValue(void) const
return the cut value applied at this node
Bool_t GoesRight(const Event &) const override
test event if it descends the tree at this node to the right
Int_t GetNodeType(void) const
return node type: 1 signal node, -1 bkg leave, 0 intermediate Node
Double_t GetAlpha() const
return the critical point alpha, or -1 if traininfo undefined
Int_t GetNTerminal() const
return number of terminal nodes in the subtree rooted here, or -1 if traininfo undefined
Bool_t fCutType
true: if event variable > cutValue ==> signal , false otherwise
Bool_t GetCutType(void) const
return kTRUE: Cuts select signal, kFALSE: Cuts select bkg
void ResetValidationData()
temporary stored node values (number of events, etc.) that originate not from the training but from t...
void SetNSigEvents_unweighted(Float_t s)
set the sum of the unweighted signal events in the node, if traininfo defined
Float_t GetNEvents(void) const
return the number of events that entered the node (during training), or -1 if traininfo undefined
void SetRight(Node *r) override
Double_t GetCC() const
return CC, or -1 if traininfo undefined
Bool_t ReadDataRecord(std::istream &is, UInt_t tmva_Version_Code=262657) override
Read the data block.
static bool fgIsTraining
static variable to flag training phase in which we need fTrainInfo
void SetSeparationIndex(Float_t sep)
set the chosen index, measure of "purity" (separation between S and B) AT this node,...
Float_t fResponse
response value in case of regression
void PrintRec(std::ostream &os) const override
recursively print the node and its daughters (--> print the 'tree')
void SetSumTarget(Float_t t)
set sum target, if traininfo defined
Float_t GetPurity(void) const
return S/(S+B) (purity) at this node (from training)
Float_t GetSeparationGain(void) const
return the gain in separation obtained by this node's selection, or -1 if traininfo undefined
Float_t GetSampleMax(UInt_t ivar) const
return the maximum of variable ivar from the training sample that pass/end up in this node,...
void SetCutValue(Float_t c)
set the cut value applied at this node
Float_t GetNBkgEvents(void) const
return the sum of the backgr weights in the node, or -1 if traininfo undefined
Float_t GetSampleMin(UInt_t ivar) const
return the minimum of variable ivar from the training sample that pass/end up in this node,...
void SetSampleMin(UInt_t ivar, Float_t xmin)
set the minimum of variable ivar from the training sample that pass/end up in this node,...
void SetSelector(Short_t i)
set index of variable used for discrimination at this node
std::vector< Double_t > fFisherCoeff
the fisher coeff (offset at the last element)
Double_t GetFisherCoeff(Int_t ivar) const
get fisher coefficients
void SetNBkgEvents_unweighted(Float_t b)
set the sum of the unweighted backgr events in the node, if traininfo defined
void SetNSValidation(Double_t s)
set number of signal events from the pruning validation sample, if traininfo defined
void SetNEvents(Float_t nev)
set the number of events that entered the node (during training), if traininfo defined
ostringstream derivative to redirect and format output
Node for the BinarySearch or Decision Trees.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
create variable transformations
MsgLogger & Endl(MsgLogger &ml)