29 #ifndef ROOT_TMVA_RuleEnsemble 30 #define ROOT_TMVA_RuleEnsemble 42 #ifndef ROOT_TMVA_DecisionTree 45 #ifndef ROOT_TMVA_Event 48 #ifndef ROOT_TMVA_Rule 51 #ifndef ROOT_TMVA_Types 65 std::ostream&
operator<<( std::ostream& os,
const RuleEnsemble& event );
98 void MakeRules(
const std::vector< const TMVA::DecisionTree *>& forest );
113 void SetRules(
const std::vector< TMVA::Rule *> & rules );
173 const std::vector<Double_t> & coefs,
174 const std::vector<Double_t> & lincoefs)
const;
177 const std::vector<Double_t> & coefs,
178 const std::vector<Double_t> & lincoefs);
185 const std::vector<Double_t> & coefs,
186 const std::vector<Double_t> & lincoefs)
const;
322 void PrintRaw ( std::ostream& os )
const;
323 void*
AddXMLTo (
void* parent )
const;
326 void ReadRaw ( std::istream& istr );
438 for (
Int_t i=0; i<nrules; i++ ) {
440 rval +=
fRules[i]->GetCoefficient();
454 const std::vector<Double_t> & coefs,
455 const std::vector<Double_t> & lincoefs )
const 466 for (
Int_t i=0; i<nrules; i++ ) {
492 const std::vector<Double_t> & coefs,
493 const std::vector<Double_t> & lincoefs )
511 for (
UInt_t ir = 0; ir<nrules; ir++) {
513 rval +=
fRules[rind]->GetCoefficient();
530 const std::vector<Double_t> & coefs,
531 const std::vector<Double_t> & lincoefs )
const 540 for (
UInt_t ir = 0; ir<nrules; ir++) {
567 Double_t val = (*fRuleMapEvents)[evtidx]->GetValue(vind);
Double_t GetLinCoefficients(int i) const
Double_t GetImportanceRef() const
void MakeRuleMap(const std::vector< const TMVA::Event *> *events=0, UInt_t ifirst=0, UInt_t ilast=0)
Makes rule map for all events.
void SetLinDP(const std::vector< Double_t > &xmax)
Double_t GetRulePBS(int i) const
void SetEvent(const Event &e)
Double_t GetRulePTag(int i) const
void SetLinDM(const std::vector< Double_t > &xmin)
void ClearLinNorm(Double_t val=1.0)
std::vector< TH1F *> fLinPDFS
const std::vector< Double_t > & GetLinNorm() const
Double_t EvalLinEventRaw(UInt_t vind, const Event &e, Bool_t norm) const
RuleEnsemble()
constructor
Rule * MakeTheRule(const Node *node)
Make a Rule from a given Node.
UInt_t GetNLinear() const
Int_t CalcNRules(const TMVA::DecisionTree *dtree)
calculate the number of rules
Double_t CalcLinNorm(Double_t stdev)
const std::vector< UInt_t > & GetEventRuleMap(UInt_t evtidx) const
virtual ~RuleEnsemble()
destructor
const std::vector< TMVA::Rule * > & GetRulesConst() const
Double_t GetAverageRuleSigma() const
tomato 1-D histogram with a float per channel (see TH1 documentation)}
std::vector< Double_t > fLinDP
const std::vector< Double_t > & GetVarImportance() const
Short_t Min(Short_t a, Short_t b)
std::vector< Double_t > fRulePBB
const Event * GetEvent() const
Double_t GetVarImportance(int i) const
void CleanupLinear()
cleanup linear model
const std::vector< Double_t > & GetLinCoefficients() const
Double_t GetEventLinearValNorm(UInt_t i) const
std::vector< TMVA::Rule *> fRules
std::vector< Char_t > fLinTermOK
void SetAverageRuleSigma(Double_t v)
Bool_t DoOnlyLinear() const
void SetLinCoefficients(const std::vector< Double_t > &v)
void SetMsgType(EMsgType t)
void SetImportanceRef(Double_t impref)
set reference importance
void RuleResponseStats()
calculate various statistics for this rule
friend std::ostream & operator<<(std::ostream &os, const RuleEnsemble &rules)
Double_t GetRuleMinDist() const
std::vector< Double_t > fLinNorm
void RemoveSimilarRules()
remove rules that behave similar
void Copy(RuleEnsemble const &other)
copy function
Double_t GetLinNorm(int i) const
Double_t GetEventLinearVal(UInt_t i) const
Double_t GetEventRuleVal(UInt_t i) const
const std::vector< Double_t > & GetLinImportance() const
Double_t PdfRule(Double_t &nsig, Double_t &ntot) const
This function returns Pr( y = 1 | x ) for rules.
Double_t FStar() const
We want to estimate F* = argmin Eyx( L(y,F(x) ), min wrt F(x) F(x) = FL(x) + FR(x) ...
void SetRules(const std::vector< TMVA::Rule *> &rules)
set rules
void Print() const
print function
std::vector< TH1F *> fLinPDFB
Bool_t DoOnlyRules() const
void SetRuleFit(const RuleFit *rf)
std::vector< Double_t > fRulePSB
void CalcImportance()
calculate the importance of each rule
ELearningModel GetLearningModel() const
std::vector< Double_t > fLinCoefficients
void CleanupRules()
cleanup rules
Double_t GetRulePSB(int i) const
Double_t GetImportanceCut() const
Double_t GetRulePBB(int i) const
UInt_t GetRulesNCuts(int i) const
void * AddXMLTo(void *parent) const
write rules to XML
void CalcVarImportance()
Calculates variable importance using eq (35) in RuleFit paper by Friedman et.al.
ELearningModel fLearningModel
Double_t CalcRuleImportance()
calculate importance of each rule
void PrintRuleGen() const
print rule generation info
std::vector< Double_t > fLinDM
void MakeRulesFromTree(const DecisionTree *dtree)
create rules from the decsision tree structure
Double_t CoefficientRadius()
Calculates sqrt(Sum(a_i^2)), i=1..N (NOTE do not include a0)
void SetOffset(Double_t v=0.0)
void ClearCoefficients(Double_t val=0)
const TMVA::Event * GetRuleMapEvent(UInt_t evtidx) const
void AddRule(const Node *node)
add a new rule to the tree
void SetImportanceCut(Double_t minimp=0)
MsgLogger & Log() const
message logger
Double_t PdfLinear(Double_t &nsig, Double_t &ntot) const
This function returns Pr( y = 1 | x ) for the linear terms.
void RuleStatistics()
calculate various statistics for this rule
const RuleFit * GetRuleFit() const
void ClearLinCoefficients(Double_t val=0)
std::ostream & operator<<(std::ostream &os, const BinaryTree &tree)
print the tree recursinvely using the << operator
Bool_t IsLinTermOK(int i) const
Bool_t IsRuleMapOK() const
Double_t GetRulePSS(int i) const
void ReadFromXML(void *wghtnode)
read rules from XML
const std::vector< const TMVA::Event * > * GetTrainingEvents() const
get list of training events from the rule fitter
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
void SetLinCoefficient(UInt_t i, Double_t v)
Double_t GetLinQuantile() const
void PrintRaw(std::ostream &os) const
write rules to stream
std::vector< Char_t > fEventRuleVal
void FindNEndNodes(const TMVA::Node *node, Int_t &nendnodes)
find the number of leaf nodes
void Initialize(const RuleFit *rf)
Initializes all member variables with default values.
void SetCoefficients(const std::vector< Double_t > &v)
set all rule coefficients
std::vector< Double_t > fVarImportance
std::vector< Double_t > fEventLinearVal
Double_t GetLinDM(int i) const
void MakeLinearTerms()
Make the linear terms as in eq 25, ref 2 For this the b and (1-b) quatiles are needed.
std::vector< Double_t > fLinImportance
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Double_t fAverageRuleSigma
void MakeRules(const std::vector< const TMVA::DecisionTree *> &forest)
Makes rules from the given decision tree.
Double_t GetAverageSupport() const
std::vector< Double_t > fRulePBS
void CalcRuleSupport()
calculate the support for all rules
const std::vector< const TMVA::Event * > * fRuleMapEvents
const MethodBase * GetMethodBase() const
Get a pointer to the original MethodRuleFit.
std::vector< Double_t > fRulePSS
void operator=(const RuleEnsemble &other)
void MakeModel()
create model
Double_t GetOffset() const
Abstract ClassifierFactory template that handles arbitrary types.
const Rule * GetRulesConst(int i) const
Double_t EvalLinEvent() const
Short_t Max(Short_t a, Short_t b)
const MethodRuleFit * GetMethodRuleFit() const
Get a pointer to the original MethodRuleFit.
void SetLinNorm(const std::vector< Double_t > &norm)
void ResetCoefficients()
reset all rule coefficients
Double_t GetLinDP(int i) const
std::vector< TMVA::Rule * > & GetRules()
void GetCoefficients(std::vector< Double_t > &v)
Retrieve all rule coefficients.
void AddOffset(Double_t v)
Double_t EvalEvent() const
Double_t Sqrt(Double_t x)
Double_t CalcLinImportance()
calculate the linear importance for each rule
void SetCoefficient(UInt_t i, Double_t v)
Double_t GetLinImportance(int i) const
double norm(double *x, double *p)
std::vector< Double_t > fRulePTag
void SetRuleMinDist(Double_t d)
const Event * GetTrainingEvent(UInt_t i) const
get the training event from the rule fitter
std::vector< Double_t > fRuleVarFrac
void SetLinQuantile(Double_t q)
std::vector< std::vector< UInt_t > > fRuleMap
void ReadRaw(std::istream &istr)
read rule ensemble from stream