67 const std::vector< const Node * >& nodes )
147 found = (
fCut->GetSelector(i) == iv);
149 doneLoop = (found || (i==nvars));
175 if (mindist<0) useCutValue=
kFALSE;
178 if (useCutValue) rval = ( (!(
d<0)) && (
d<mindist) );
179 else rval = (!(
d<0));
215 while ((equal) && (in<nvars)) {
223 sel =
fCut->GetSelector(in);
224 vminA =
fCut->GetCutMin(in);
225 vmaxA =
fCut->GetCutMax(in);
229 rms =
fRuleEnsemble->GetRuleFit()->GetMethodBase()->GetRMS(sel);
232 if (
fCut->GetCutDoMin(in))
233 smin = ( rms>0 ? (vminA-vminB)/rms : 0 );
234 if (
fCut->GetCutDoMax(in))
235 smax = ( rms>0 ? (vmaxA-vmaxB)/rms : 0 );
236 sumdc2 += smin*smin + smax*smax;
242 if (!useCutValue) sumdc2 = (equal ? 0.0:-1.0);
243 else sumdc2 = (equal ? sqrt(sumdc2) : -1.0);
306 if (nvars<1) os <<
" *** WARNING - <EMPTY RULE> ***" << std::endl;
313 os <<
" Support = " <<
Form(
"%1.4f",
fSupport) << std::endl;
314 os <<
" S/(S+B) = " <<
Form(
"%1.4f",
fSSB) << std::endl;
316 for (
UInt_t i=0; i<nvars; i++) {
318 sel =
fCut->GetSelector(i);
319 valmin =
fCut->GetCutMin(i);
320 valmax =
fCut->GetCutMax(i);
322 os <<
Form(
"* Cut %2d",i+1) <<
" : " << std::flush;
323 if (
fCut->GetCutDoMin(i)) os <<
Form(
"%10.3g",valmin) <<
" < " << std::flush;
324 else os <<
" " << std::flush;
326 if (
fCut->GetCutDoMax(i)) os <<
" < " <<
Form(
"%10.3g",valmax) << std::flush;
327 else os <<
" " << std::flush;
338 if (nvars<1)
Log() << kWARNING <<
"BUG TRAP: EMPTY RULE!!!" <<
Endl;
343 if (title)
Log() << kINFO << title;
347 for (
UInt_t i=0; i<nvars; i++) {
349 Log() << kINFO <<
" ";
350 sel =
fCut->GetSelector(i);
351 valmin =
fCut->GetCutMin(i);
352 valmax =
fCut->GetCutMax(i);
354 Log() << kINFO <<
Form(
"Cut %2d",i+1) <<
" : ";
355 if (
fCut->GetCutDoMin(i))
Log() << kINFO <<
Form(
"%10.3g",valmin) <<
" < ";
356 else Log() << kINFO <<
" ";
358 if (
fCut->GetCutDoMax(i))
Log() << kINFO <<
" < " <<
Form(
"%10.3g",valmax);
359 else Log() << kINFO <<
" ";
369 Int_t dp = os.precision();
372 << std::setprecision(10)
382 os <<
"N(cuts): " << nvars << std::endl;
383 for (
UInt_t i=0; i<nvars; i++) {
384 os <<
"Cut " << i <<
" : " << std::flush;
385 os <<
fCut->GetSelector(i)
386 << std::setprecision(10)
387 <<
" " <<
fCut->GetCutMin(i)
388 <<
" " <<
fCut->GetCutMax(i)
389 <<
" " << (
fCut->GetCutDoMin(i) ?
"T":
"F")
390 <<
" " << (
fCut->GetCutDoMax(i) ?
"T":
"F")
393 os << std::setprecision(dp);
413 for (
UInt_t i=0; i<nvars; i++) {
431 if (nodeName !=
"Rule")
Log() << kFATAL <<
"<ReadFromXML> Unexpected node name: " << nodeName <<
Endl;
446 fCut->SetNvars( nvars );
456 fCut->SetSelector( i, ui );
458 fCut->SetCutMin ( i,
d );
460 fCut->SetCutMax ( i,
d );
471 if (i != nvars)
Log() << kFATAL <<
"<ReadFromXML> Mismatch in number of cuts: " << i <<
" != " << nvars <<
Endl;
491 istr >> dummy >> nvars;
498 fCut->SetNvars( nvars );
499 for (
UInt_t i=0; i<nvars; i++) {
500 istr >> dummy >> idum;
502 istr >> sel >> cutmin >> cutmax >> bA >> bB;
503 fCut->SetSelector(i,sel);
504 fCut->SetCutMin(i,cutmin);
505 fCut->SetCutMax(i,cutmax);
int Int_t
Signed integer 4 bytes (int).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
ostringstream derivative to redirect and format output
A class describing a 'rule cut'.
Double_t GetCutMin(Int_t is) const
UInt_t GetSelector(Int_t is) const
Char_t GetCutDoMin(Int_t is) const
Char_t GetCutDoMax(Int_t is) const
Double_t GetCutMax(Int_t is) const
Implementation of a rule.
Double_t fImportance
importance of rule
void SetImportanceRef(Double_t v)
void SetMsgType(EMsgType t)
void Copy(const Rule &other)
copy function
Double_t GetImportanceRef() const
Double_t GetSSBNeve() const
void PrintLogger(const char *title=nullptr) const
print function
Double_t GetSupport() const
Double_t fSigma
t(k) = sqrt(s*(1-s))
MsgLogger * fLogger
! message logger
void SetSigma(Double_t v)
Bool_t Equal(const Rule &other, Bool_t useCutValue, Double_t maxdist) const
Compare two rules.
void ReadRaw(std::istream &os)
read function (format is the same as written by PrintRaw)
void * AddXMLTo(void *parent) const
Bool_t operator==(const Rule &other) const
comparison operator ==
const RuleCut * GetRuleCut() const
Double_t GetCoefficient() const
void SetCoefficient(Double_t v)
void Print(std::ostream &os) const
print function
void SetNorm(Double_t norm)
const RuleEnsemble * GetRuleEnsemble() const
virtual ~Rule()
destructor
Double_t fNorm
normalization - usually 1.0/t(k)
void ReadFromXML(void *wghtnode)
read rule from XML
Double_t GetImportance() const
void PrintRaw(std::ostream &os) const
extensive print function used to print info for the weight file
Double_t GetSigma() const
void SetRuleEnsemble(const RuleEnsemble *re)
const TString & GetVarName(Int_t i) const
returns the name of a rule
Bool_t operator<(const Rule &other) const
comparison operator <
Double_t RuleDist(const Rule &other, Bool_t useCutValue) const
Returns:
Double_t fSSB
S/(S+B) for rule.
Rule(RuleEnsemble *re, const std::vector< const TMVA::Node * > &nodes)
the main constructor for a Rule
RuleCut * fCut
all cuts associated with the rule
Bool_t ContainsVariable(UInt_t iv) const
check if variable in node
Double_t fCoefficient
rule coeff. a(k)
void SetSupport(Double_t v)
const RuleEnsemble * fRuleEnsemble
pointer to parent RuleEnsemble
Rule()
the simple constructor
Double_t fSSBNeve
N(events) reaching the last node in reevaluation.
Double_t fImportanceRef
importance ref
std::ostream & operator<<(std::ostream &os, const BinaryTree &tree)
MsgLogger & Endl(MsgLogger &ml)