From 868757974494df105d61b749e52acb0c8fac70a3 Mon Sep 17 00:00:00 2001 From: Olivier Couet <olivier.couet@cern.ch> Date: Tue, 20 Dec 2016 11:19:40 +0100 Subject: [PATCH] - Doxygen format - in group TMVA - remove trailing spaces - spell check - math formula --- tmva/tmva/inc/TMVA/ROCCurve.h | 14 +-- tmva/tmva/inc/TMVA/RegressionVariance.h | 28 +++--- tmva/tmva/inc/TMVA/Rule.h | 16 ++-- tmva/tmva/src/ROCCalc.cxx | 99 ++++++++++---------- tmva/tmva/src/ROCCurve.cxx | 114 ++++++++++++------------ tmva/tmva/src/RegressionVariance.cxx | 55 ++++++++---- tmva/tmva/src/Results.cxx | 23 ++--- tmva/tmva/src/ResultsClassification.cxx | 12 +-- tmva/tmva/src/ResultsMulticlass.cxx | 53 ++++++----- tmva/tmva/src/ResultsRegression.cxx | 18 ++-- tmva/tmva/src/RootFinder.cxx | 33 +++---- tmva/tmva/src/Rule.cxx | 67 +++++++------- 12 files changed, 278 insertions(+), 254 deletions(-) diff --git a/tmva/tmva/inc/TMVA/ROCCurve.h b/tmva/tmva/inc/TMVA/ROCCurve.h index e79655946b2..5adb82b0322 100644 --- a/tmva/tmva/inc/TMVA/ROCCurve.h +++ b/tmva/tmva/inc/TMVA/ROCCurve.h @@ -1,4 +1,4 @@ -// @(#)root/tmva $Id$ +// @(#)root/tmva $Id$ // Author: Omar Zapata, Lorenzo Moneta, Sergei Gleyzer /********************************************************************************** @@ -45,20 +45,20 @@ namespace TMVA { class ROCCurve { - + public: ROCCurve( const std::vector<Float_t> & mvaS, const std::vector<Bool_t> & mvat); - + ~ROCCurve(); - + Double_t GetROCIntegral(); - TGraph* GetROCCurve(const UInt_t points=100);//nvidisions = #points -1 - + TGraph* GetROCCurve(const UInt_t points=100);//n divisions = #points -1 + private: void EpsilonCount(); mutable MsgLogger* fLogger; //! message logger - MsgLogger& Log() const { return *fLogger; } + MsgLogger& Log() const { return *fLogger; } TGraph *fGraph; std::vector<Float_t> fMvaS; std::vector<Float_t> fMvaB; diff --git a/tmva/tmva/inc/TMVA/RegressionVariance.h b/tmva/tmva/inc/TMVA/RegressionVariance.h index 1af11e9ddb2..240a281b069 100644 --- a/tmva/tmva/inc/TMVA/RegressionVariance.h +++ b/tmva/tmva/inc/TMVA/RegressionVariance.h @@ -1,5 +1,5 @@ // @(#)root/tmva $Id$ -// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss +// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss /********************************************************************************** * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * @@ -7,7 +7,7 @@ * Class : RegressionVariance * * Web : http://tmva.sourceforge.net * * * - * Description: Calculate the separation critiera useded in regression * + * Description: Calculate the separation criteria used in regression * * * * There are two things: the Separation Index, and the Separation Gain * * Separation Index: * @@ -17,7 +17,7 @@ * the measure of how the quality of separation of the sample increases * * by splitting the sample e.g. into a "left-node" and a "right-node" * * (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) * - * this is then the quality crition which is optimized for when trying * + * this is then the quality criteria which is optimized for when trying * * to increase the information in the system (making the best selection * * * * * @@ -25,9 +25,9 @@ * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany * * * * Copyright (c) 2005: * - * CERN, Switzerland * - * U. of Victoria, Canada * - * Heidelberg U., Germany * + * CERN, Switzerland * + * U. of Victoria, Canada * + * Heidelberg U., Germany * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted according to the terms listed in LICENSE * @@ -42,7 +42,7 @@ // RegressionVariance // // // // Calculate the "SeparationGain" for Regression analysis // -// separation critiera used in various training algorithms // +// separation criteria used in various training algorithms // // // // There are two things: the Separation Index, and the Separation Gain // // Separation Index: // @@ -52,8 +52,8 @@ // the measure of how the quality of separation of the sample increases // // by splitting the sample e.g. into a "left-node" and a "right-node" // // (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) // -// this is then the quality crition which is optimized for when trying // -// to increase the information in the system (making the best selection // +// this is then the quality criteria which is optimized for when trying // +// to increase the information in the system (making the best selection // // // ////////////////////////////////////////////////////////////////////////// @@ -80,8 +80,8 @@ namespace TMVA { // destructor virtual ~RegressionVariance(){} - // Return the gain in separation of the original sample is splitted in two sub-samples - // (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) + // Return the gain in separation of the original sample is split in two sub-samples + // (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) Double_t GetSeparationGain( const Double_t &nLeft, const Double_t &targetLeft, const Double_t &target2Left, const Double_t &nTot, const Double_t &targetTot, const Double_t &target2Tot ); @@ -93,9 +93,9 @@ namespace TMVA { protected: - TString fName; // name of the concrete Separation Index impementation - - ClassDef(RegressionVariance,0); // Interface to different separation critiera used in training algorithms + TString fName; // name of the concrete Separation Index implementation + + ClassDef(RegressionVariance,0); // Interface to different separation criteria used in training algorithms }; diff --git a/tmva/tmva/inc/TMVA/Rule.h b/tmva/tmva/inc/TMVA/Rule.h index 89e8ffb9d89..e1db0919201 100644 --- a/tmva/tmva/inc/TMVA/Rule.h +++ b/tmva/tmva/inc/TMVA/Rule.h @@ -1,4 +1,4 @@ -// @(#)root/tmva $Id$ +// @(#)root/tmva $Id$ // Author: Andreas Hoecker, Joerg Stelzer, Fredrik Tegenfeldt, Helge Voss /********************************************************************************** @@ -7,9 +7,9 @@ * Class : Rule * * * * Description: * - * A class describung a 'rule' * + * A class describing a 'rule' * * Each internal node of a tree defines a rule from all the parental nodes. * - * A rule consists of atleast 2 nodes. * + * A rule consists of at least 2 nodes. * * Input: a decision tree (in the constructor) * * its coefficient * * * @@ -19,9 +19,9 @@ * Helge Voss <Helge.Voss@cern.ch> - MPI-KP Heidelberg, Ger. * * * * Copyright (c) 2005: * - * CERN, Switzerland * + * CERN, Switzerland * * Iowa State U. * - * MPI-K Heidelberg, Germany * + * MPI-K Heidelberg, Germany * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted according to the terms listed in LICENSE * @@ -55,7 +55,7 @@ namespace TMVA { class Rule { - // ouput operator for a Rule + // output operator for a Rule friend std::ostream& operator<< ( std::ostream& os, const Rule & rule ); public: @@ -110,7 +110,7 @@ namespace TMVA { // evaluate the Rule for the given Event using the coefficient // inline Double_t EvalEvent( const Event& e, Bool_t norm ) const; - // evaluate the Rule for the given Event, not using normalization or the coefficent + // evaluate the Rule for the given Event, not using normalization or the coefficient inline Bool_t EvalEvent( const Event& e ) const; // test if two rules are equal @@ -187,7 +187,7 @@ namespace TMVA { Double_t fSSBNeve; // N(events) reaching the last node in reevaluation mutable MsgLogger* fLogger; //! message logger - MsgLogger& Log() const { return *fLogger; } + MsgLogger& Log() const { return *fLogger; } }; diff --git a/tmva/tmva/src/ROCCalc.cxx b/tmva/tmva/src/ROCCalc.cxx index cd21b4c96b5..50a3f9a1eb5 100644 --- a/tmva/tmva/src/ROCCalc.cxx +++ b/tmva/tmva/src/ROCCalc.cxx @@ -1,3 +1,8 @@ +/*! \class TMVA::ROCCalc +\ingroup TMVA + +*/ + #include <algorithm> #include <cstdlib> #include <errno.h> @@ -78,15 +83,15 @@ TMVA::ROCCalc::ROCCalc(TH1* mvaS, TH1* mvaB) : { fUseSplines = kTRUE; fNbins = 100; - // fmvaS = (TH1*) mvaS->Clone("MVA Signal"); fmvaS->SetTitle("MVA Signal"); + // fmvaS = (TH1*) mvaS->Clone("MVA Signal"); fmvaS->SetTitle("MVA Signal"); // fmvaB = (TH1*) mvaB->Clone("MVA Backgr"); fmvaB->SetTitle("MVA Backgr"); fmvaS = mvaS; fmvaS->SetTitle("MVA Signal"); fmvaB = mvaB; fmvaB->SetTitle("MVA Backgr"); fXmax = fmvaS->GetXaxis()->GetXmax(); - fXmin = fmvaS->GetXaxis()->GetXmin(); - - if (TMath::Abs(fXmax-fmvaB->GetXaxis()->GetXmax()) > 0.000001 || - TMath::Abs(fXmin-fmvaB->GetXaxis()->GetXmin()) > 0.000001 || + fXmin = fmvaS->GetXaxis()->GetXmin(); + + if (TMath::Abs(fXmax-fmvaB->GetXaxis()->GetXmax()) > 0.000001 || + TMath::Abs(fXmin-fmvaB->GetXaxis()->GetXmin()) > 0.000001 || fmvaB->GetNbinsX() != fmvaS->GetNbinsX()) { Log() << kERROR << "Cannot cal ROC curve etc, as in put mvaS and mvaB have differen #nbins or range "<<Endl; fStatus=kFALSE; @@ -97,19 +102,19 @@ TMVA::ROCCalc::ROCCalc(TH1* mvaS, TH1* mvaB) : if (!strcmp(fmvaB->GetYaxis()->GetTitle(),"")) fmvaB->SetYTitle("#entries"); ApplySignalAndBackgroundStyle(fmvaS, fmvaB); // std::cout<<"mvaS->GetNbinsX()"<<mvaS->GetNbinsX()<<std::endl; - // std::cout<<"mvaB->GetNbinsX()"<<mvaB->GetNbinsX()<<std::endl; + // std::cout<<"mvaB->GetNbinsX()"<<mvaB->GetNbinsX()<<std::endl; //the output of mvaS->GetNbinsX() is about 40 and if we divide it by 100 the results is 0 //the I will divide it by 10 anyway doing some tests ROC integral is the same - fmvaSpdf = mvaS->RebinX(mvaS->GetNbinsX()/10,"MVA Signal PDF"); + fmvaSpdf = mvaS->RebinX(mvaS->GetNbinsX()/10,"MVA Signal PDF"); fmvaBpdf = mvaB->RebinX(mvaB->GetNbinsX()/10,"MVA Backgr PDF"); if(fmvaSpdf==0||fmvaBpdf==0) { Log() << kERROR << "Cannot Rebin Histograms mvaS and mvaB, ROC values will be calculated without Rebin histograms."<<Endl; fStatus=kFALSE; - fmvaSpdf = (TH1*)mvaS->Clone("MVA Signal PDF"); + fmvaSpdf = (TH1*)mvaS->Clone("MVA Signal PDF"); fmvaBpdf = (TH1*)mvaB->Clone("MVA Backgr PDF"); } - fmvaSpdf->SetTitle("MVA Signal PDF"); + fmvaSpdf->SetTitle("MVA Signal PDF"); fmvaBpdf->SetTitle("MVA Backgr PDF"); fmvaSpdf->Scale(1./fmvaSpdf->GetSumOfWeights()); fmvaBpdf->Scale(1./fmvaBpdf->GetSumOfWeights()); @@ -120,15 +125,10 @@ TMVA::ROCCalc::ROCCalc(TH1* mvaS, TH1* mvaB) : fCutOrientation = (fmvaS->GetMean() > fmvaB->GetMean()) ? +1 : -1; fNevtS = 0; - + } //////////////////////////////////////////////////////////////////////////////// -/// Int_t c_Canvas = TColor::GetColor( "#f0f0f0" ); -/// Int_t c_FrameFill = TColor::GetColor( "#fffffd" ); -/// Int_t c_TitleBox = TColor::GetColor( "#5D6B7D" ); -/// Int_t c_TitleBorder = TColor::GetColor( "#7D8B9D" ); -/// Int_t c_TitleText = TColor::GetColor( "#FFFFFF" ); void TMVA::ROCCalc::ApplySignalAndBackgroundStyle( TH1* sig, TH1* bkg, TH1* any ) { Int_t c_SignalLine = TColor::GetColor( "#0000ee" ); @@ -158,7 +158,7 @@ void TMVA::ROCCalc::ApplySignalAndBackgroundStyle( TH1* sig, TH1* bkg, TH1* any sig->SetFillStyle( FillStyle__S ); sig->SetFillColor( FillColor__S ); } - + if (bkg != NULL) { bkg->SetLineColor( LineColor__B ); bkg->SetLineWidth( LineWidth__B ); @@ -174,7 +174,6 @@ void TMVA::ROCCalc::ApplySignalAndBackgroundStyle( TH1* sig, TH1* bkg, TH1* any } } - //////////////////////////////////////////////////////////////////////////////// /// destructor @@ -197,7 +196,7 @@ TMVA::ROCCalc::~ROCCalc() { /// get the ROC curve TH1D* TMVA::ROCCalc::GetROC(){ - // first get the cumulative distributions of the mva distribution + // first get the cumulative distributions of the mva distribution // --> efficiencies vs cut value fNevtS = fmvaS->GetSumOfWeights(); // needed to get the error on the eff.. will only be correct if the histogram is not scaled to "integral == 1" Yet; if (fNevtS < 2) { @@ -223,7 +222,7 @@ TH1D* TMVA::ROCCalc::GetROC(){ if(rejBvsS==0) rejBvsS = new TH1D( "rejBvsS", "ROC-Curve", fNbins, 0, 1 ); rejBvsS->SetXTitle( "Signal eff" ); rejBvsS->SetYTitle( "Backgr rejection (1-eff)" ); - + // inverse background eff (1/eff.) versus signal efficiency if(inveffBvsS ==0) inveffBvsS = new TH1D("invBeffvsSeff", "ROC-Curve" , fNbins, 0, 1 ); inveffBvsS->SetXTitle( "Signal eff" ); @@ -257,21 +256,21 @@ TH1D* TMVA::ROCCalc::GetROC(){ if (effB>std::numeric_limits<double>::epsilon()) inveffBvsS->SetBinContent( bini, 1.0/effB ); } - + // create splines for histogram fSpleffBvsS = new TSpline1( "effBvsS", new TGraph( effBvsS ) ); - + // search for overlap point where, when cutting on it, // one would obtain: eff_S = rej_B = 1 - eff_B Double_t effS = 0., rejB = 0., effS_ = 0., rejB_ = 0.; Int_t nbins = 5000; for (Int_t bini=1; bini<=nbins; bini++) { - + // get corresponding signal and background efficiencies effS = (bini - 0.5)/Float_t(nbins); rejB = 1.0 - fSpleffBvsS->Eval( effS ); - + // find signal efficiency that corresponds to required background efficiency if ((effS - rejB)*(effS_ - rejB_) < 0) break; effS_ = effS; @@ -279,7 +278,7 @@ TH1D* TMVA::ROCCalc::GetROC(){ } // find cut that corresponds to signal efficiency and update signal-like criterion fSignalCut = Root( 0.5*(effS + effS_) ); - + return rejBvsS; } @@ -294,19 +293,19 @@ Double_t TMVA::ROCCalc::GetROCIntegral(){ // compute area of rej-vs-eff plot Double_t integral = 0; for (Int_t bini=1; bini<=nbins; bini++) { - + // get corresponding signal and background efficiencies effS = (bini - 0.5)/Float_t(nbins); effB = fSpleffBvsS->Eval( effS ); integral += (1.0 - effB); } integral /= nbins; - + return integral; } //////////////////////////////////////////////////////////////////////////////// -/// get the signal efficiency for a particular backgroud efficiency +/// get the signal efficiency for a particular background efficiency /// that will be the value of the efficiency retured (does not affect /// the efficiency-vs-bkg plot which is done anyway. @@ -327,11 +326,11 @@ Double_t TMVA::ROCCalc::GetEffSForEffBof(Double_t effBref, Double_t &effSerr){ effSOld = effS; effBOld = effB; } - + // take mean between bin above and bin below effS = 0.5*(effS + effSOld); - - + + if (fNevtS > 0) effSerr = TMath::Sqrt( effS*(1.0 - effS)/fNevtS ); else effSerr = 0; @@ -348,7 +347,7 @@ Double_t TMVA::ROCCalc::GetEffForRoot( Double_t theCut ) // retrieve the class object if (fUseSplines) retVal = fSplmvaCumS->Eval( theCut ); else retVal = fmvaScumul->GetBinContent( fmvaScumul->FindBin( theCut ) ); - + // caution: here we take some "forbidden" action to hide a problem: // in some cases, in particular for likelihood, the binned efficiency distributions // do not equal 1, at xmin, and 0 at xmax; of course, in principle we have the @@ -374,7 +373,7 @@ Double_t TMVA::ROCCalc::Root( Double_t refValue ) if (fb*fa > 0) { Log() << kWARNING << "<ROCCalc::Root> initial interval w/o root: " << "(a=" << a << ", b=" << b << ")," - << " (Eff_a=" << GetEffForRoot( a ) + << " (Eff_a=" << GetEffForRoot( a ) << ", Eff_b=" << GetEffForRoot( b ) << "), " << "(fa=" << fa << ", fb=" << fb << "), " << "refValue = " << refValue << Endl; @@ -392,7 +391,7 @@ Double_t TMVA::ROCCalc::Root( Double_t refValue ) c = a; fc = fa; d = b - a; e = b - a; } - + if (TMath::Abs(fc) < TMath::Abs(fb)) { ac_equal = kTRUE; a = b; b = c; c = a; @@ -402,14 +401,14 @@ Double_t TMVA::ROCCalc::Root( Double_t refValue ) Double_t tol = 0.5 * 2.2204460492503131e-16 * TMath::Abs(b); Double_t m = 0.5 * (c - b); if (fb == 0 || TMath::Abs(m) <= tol || TMath::Abs(fb) < fAbsTol) return b; - + // Bounds decreasing too slowly: use bisection - if (TMath::Abs (e) < tol || TMath::Abs (fa) <= TMath::Abs (fb)) { d = m; e = m; } + if (TMath::Abs (e) < tol || TMath::Abs (fa) <= TMath::Abs (fb)) { d = m; e = m; } else { // Attempt inverse cubic interpolation Double_t p, q, r; Double_t s = fb / fa; - + if (ac_equal) { p = 2 * m * s; q = 1 - s; } else { q = fa / fc; r = fb / fc; @@ -419,7 +418,7 @@ Double_t TMVA::ROCCalc::Root( Double_t refValue ) // Check whether we are in bounds if (p > 0) q = -q; else p = -p; - + Double_t min1 = 3 * m * q - TMath::Abs (tol * q); Double_t min2 = TMath::Abs (e * q); if (2 * p < (min1 < min2 ? min1 : min2)) { @@ -439,7 +438,7 @@ Double_t TMVA::ROCCalc::Root( Double_t refValue ) } // Return our best guess if we run out of iterations - Log() << kWARNING << "<ROCCalc::Root> maximum iterations (" << fMaxIter + Log() << kWARNING << "<ROCCalc::Root> maximum iterations (" << fMaxIter << ") reached before convergence" << Endl; return b; @@ -450,9 +449,9 @@ Double_t TMVA::ROCCalc::Root( Double_t refValue ) TH1* TMVA::ROCCalc::GetPurity( Int_t nStot, Int_t nBtot) { if (fnStot!=nStot || fnBtot!=nBtot || !fSignificance) { - GetSignificance(nStot, nBtot); - fnStot=nStot; - fnBtot=nBtot; + GetSignificance(nStot, nBtot); + fnStot=nStot; + fnBtot=nBtot; } return fPurity; } @@ -476,7 +475,7 @@ TH1* TMVA::ROCCalc::GetSignificance( Int_t nStot, Int_t nBtot) fPurity->SetYTitle("Purity: S/(S+B)"); fPurity->SetLineColor(3); fPurity->SetLineWidth(5); - + Double_t maxSig=0; for (Int_t i=1; i<=fSignificance->GetNbinsX(); i++) { Double_t S = fmvaScumul->GetBinContent( i ) * nStot; @@ -498,7 +497,7 @@ TH1* TMVA::ROCCalc::GetSignificance( Int_t nStot, Int_t nBtot) fSignificance->SetBinContent( i, sig ); } - /* + /* TLatex* line1; TLatex* line2; TLatex tl; @@ -508,18 +507,10 @@ TH1* TMVA::ROCCalc::GetSignificance( Int_t nStot, Int_t nBtot) line1 = tl.DrawLatex( 0.15, 0.23, Form("For %1.0f signal and %1.0f background", nStot, nBtot)); tl.DrawLatex( 0.15, 0.19, "events the maximum S/Sqrt(S+B) is"); - line2 = tl.DrawLatex( 0.15, 0.15, Form("%4.2f when cutting at %5.2f", - maxSig, + line2 = tl.DrawLatex( 0.15, 0.15, Form("%4.2f when cutting at %5.2f", + maxSig, fSignificance->GetXaxis()->GetBinCenter(maxbin)) ); - */ + */ return fSignificance; } - - - - - - - - diff --git a/tmva/tmva/src/ROCCurve.cxx b/tmva/tmva/src/ROCCurve.cxx index d50f743fd10..f8cd0114936 100644 --- a/tmva/tmva/src/ROCCurve.cxx +++ b/tmva/tmva/src/ROCCurve.cxx @@ -1,4 +1,4 @@ -// @(#)root/tmva $Id$ +// @(#)root/tmva $Id$ // Author: Omar Zapata, Lorenzo Moneta, Sergei Gleyzer and Simon Pfreundschuh /********************************************************************************** @@ -20,6 +20,10 @@ * U. of Florida, USA * **********************************************************************************/ +/*! \class TMVA::ROCCurve +\ingroup TMVA + +*/ #ifndef ROOT_TMVA_Tools #include "TMVA/Tools.h" #endif @@ -44,6 +48,7 @@ using namespace std; +//////////////////////////////////////////////////////////////////////////////// TMVA::ROCCurve::ROCCurve(const std::vector<Float_t> & mva, const std::vector<Bool_t> & mvat) : fLogger ( new TMVA::MsgLogger("ROCCurve") ),fGraph(NULL) @@ -56,8 +61,6 @@ TMVA::ROCCurve::ROCCurve(const std::vector<Float_t> & mva, const std::vector<Boo } } - - //////////////////////////////////////////////////////////////////////////////// /// destructor @@ -65,12 +68,12 @@ TMVA::ROCCurve::~ROCCurve() { delete fLogger; if(fGraph) delete fGraph; } - + //////////////////////////////////////////////////////////////////////////////// /// ROC Integral (AUC) Double_t TMVA::ROCCurve::GetROCIntegral(){ - + Float_t integral=0; int ndivisions = 40; fEpsilonSig.push_back(0); @@ -85,25 +88,25 @@ Double_t TMVA::ROCCurve::GetROCIntegral(){ Float_t bcounter = 0.0; Float_t ccounter = 0.0; Float_t dcounter = 0.0; - + for(UInt_t j=0;j<fMvaS.size();j++) { if(fMvaS[j] > i) acounter++; else bcounter++; - + if(fMvaB[j] > i) ccounter++; else dcounter++; } - + if(acounter != 0 || bcounter != 0) { - epsilon_s = 1.0*bcounter/(acounter+bcounter); + epsilon_s = 1.0*bcounter/(acounter+bcounter); } fEpsilonSig.push_back(epsilon_s); - + if(ccounter != 0 || dcounter != 0) { - epsilon_b = 1.0*dcounter/(ccounter+dcounter); + epsilon_b = 1.0*dcounter/(ccounter+dcounter); } fEpsilonBgk.push_back(epsilon_b); } @@ -117,55 +120,48 @@ Double_t TMVA::ROCCurve::GetROCIntegral(){ } +//////////////////////////////////////////////////////////////////////////////// + TGraph* TMVA::ROCCurve::GetROCCurve(const UInt_t points) { - - const UInt_t ndivisions = points - 1; - fEpsilonSig.resize(points); - fEpsilonBgk.resize(points); - // Fixed values. - fEpsilonSig[0] = 0.0; - fEpsilonSig[ndivisions] = 1.0; - fEpsilonBgk[0] = 1.0; - fEpsilonBgk[ndivisions] = 0.0; - - for(UInt_t i = 1; i < ndivisions; i++) - { - Float_t threshold = -1.0 + i * 2.0 / (Float_t) ndivisions; - Float_t true_positives = 0.0; - Float_t false_positives = 0.0; - Float_t true_negatives = 0.0; - Float_t false_negatives = 0.0; - - for(UInt_t j=0; j<fMvaS.size(); j++) - { - if(fMvaS[j] > threshold) - true_positives += 1.0; - else - false_negatives += 1.0; - - if(fMvaB[j] > threshold) - false_positives += 1.0; - else - true_negatives += 1.0; - } - - fEpsilonSig[ndivisions - i] = 0.0; - if ((true_positives > 0.0) || (false_negatives > 0.0)) - fEpsilonSig[ndivisions - i] = - true_positives / (true_positives + false_negatives); - - fEpsilonBgk[ndivisions - i] =0.0; - if ((true_negatives > 0.0) || (false_positives > 0.0)) - fEpsilonBgk[ndivisions - i] = - true_negatives / (true_negatives + false_positives); - - } - - if(!fGraph) fGraph=new TGraph(fEpsilonSig.size(),&fEpsilonSig[0],&fEpsilonBgk[0]); - return fGraph; -} - - + const UInt_t ndivisions = points - 1; + fEpsilonSig.resize(points); + fEpsilonBgk.resize(points); + // Fixed values. + fEpsilonSig[0] = 0.0; + fEpsilonSig[ndivisions] = 1.0; + fEpsilonBgk[0] = 1.0; + fEpsilonBgk[ndivisions] = 0.0; + + for (UInt_t i = 1; i < ndivisions; i++) { + Float_t threshold = -1.0 + i * 2.0 / (Float_t) ndivisions; + Float_t true_positives = 0.0; + Float_t false_positives = 0.0; + Float_t true_negatives = 0.0; + Float_t false_negatives = 0.0; + + for (UInt_t j=0; j<fMvaS.size(); j++) { + if(fMvaS[j] > threshold) + true_positives += 1.0; + else + false_negatives += 1.0; + + if(fMvaB[j] > threshold) + false_positives += 1.0; + else + true_negatives += 1.0; + } + fEpsilonSig[ndivisions - i] = 0.0; + if ((true_positives > 0.0) || (false_negatives > 0.0)) + fEpsilonSig[ndivisions - i] = + true_positives / (true_positives + false_negatives); + fEpsilonBgk[ndivisions - i] =0.0; + if ((true_negatives > 0.0) || (false_positives > 0.0)) + fEpsilonBgk[ndivisions - i] = + true_negatives / (true_negatives + false_positives); + } + if(!fGraph) fGraph=new TGraph(fEpsilonSig.size(),&fEpsilonSig[0],&fEpsilonBgk[0]); + return fGraph; +} diff --git a/tmva/tmva/src/RegressionVariance.cxx b/tmva/tmva/src/RegressionVariance.cxx index 5122e410d71..60e7773d4a2 100644 --- a/tmva/tmva/src/RegressionVariance.cxx +++ b/tmva/tmva/src/RegressionVariance.cxx @@ -1,4 +1,4 @@ -// @(#)root/tmva $Id$ +// @(#)root/tmva $Id$ // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss /********************************************************************************** @@ -7,7 +7,7 @@ * Class : RegressionVariance * * Web : http://tmva.sourceforge.net * * * - * Description: Calculate the separation critiera useded in regression * + * Description: Calculate the separation criteria used in regression * * * * There are two things: the Separation Index, and the Separation Gain * * Separation Index: * @@ -17,7 +17,7 @@ * the measure of how the quality of separation of the sample increases * * by splitting the sample e.g. into a "left-node" and a "right-node" * * (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) * - * this is then the quality crition which is optimized for when trying * + * this is then the quality criteria which is optimized for when trying * * to increase the information in the system (making the best selection * * * * * @@ -25,13 +25,13 @@ * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany * * * * Copyright (c) 2005: * - * CERN, Switzerland * - * U. of Victoria, Canada * - * Heidelberg U., Germany * + * CERN, Switzerland * + * U. of Victoria, Canada * + * Heidelberg U., Germany * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted according to the terms listed in LICENSE * - * (http://ttmva.sourceforge.net/LICENSE) * + * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ #include <iostream> #include "TMath.h" @@ -39,20 +39,37 @@ ClassImp(TMVA::RegressionVariance) +/*! \class TMVA::RegressionVariance +\ingroup TMVA +Calculate the "SeparationGain" for Regression analysis +separation criteria used in various training algorithms + +There are two things: the Separation Index, and the Separation Gain +Separation Index: +Measure of the "Variance" of a sample. + +Separation Gain: +the measure of how the quality of separation of the sample increases +by splitting the sample e.g. into a "left-node" and a "right-node" +(N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) +this is then the quality criteria which is optimized for when trying +to increase the information in the system (making the best selection +*/ + //////////////////////////////////////////////////////////////////////////////// -/// Separation Gain: -/// the measure of how the quality of separation of the sample increases -/// by splitting the sample e.g. into a "left-node" and a "right-node" -/// (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) -/// this is then the quality crition which is optimized for when trying +/// Separation Gain: +/// the measure of how the quality of separation of the sample increases +/// by splitting the sample e.g. into a "left-node" and a "right-node" +/// (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) +/// this is then the quality criteria which is optimized for when trying /// to increase the information in the system /// for the Regression: as the "Gain is maximised", the RMS (sqrt(variance)) /// which is used as a "separation" index should be as small as possible. /// the "figure of merit" here has to be -(rms left+rms-right) or 1/rms... -Double_t TMVA::RegressionVariance::GetSeparationGain(const Double_t &nLeft, - const Double_t& targetLeft , const Double_t& target2Left , - const Double_t &nTot, +Double_t TMVA::RegressionVariance::GetSeparationGain(const Double_t &nLeft, + const Double_t& targetLeft , const Double_t& target2Left , + const Double_t &nTot, const Double_t& targetTot , const Double_t& target2Tot) { @@ -61,15 +78,15 @@ Double_t TMVA::RegressionVariance::GetSeparationGain(const Double_t &nLeft, Double_t parentIndex = nTot * this->GetSeparationIndex(nTot,targetTot,target2Tot); Double_t leftIndex = ( (nTot - nLeft) * this->GetSeparationIndex(nTot-nLeft,targetTot-targetLeft,target2Tot-target2Left) ); Double_t rightIndex = nLeft * this->GetSeparationIndex(nLeft,targetLeft,target2Left); - - // return 1/ (leftIndex + rightIndex); - return (parentIndex - leftIndex - rightIndex)/(parentIndex); + + // return 1/ (leftIndex + rightIndex); + return (parentIndex - leftIndex - rightIndex)/(parentIndex); } //////////////////////////////////////////////////////////////////////////////// /// Separation Index: a simple Variance -Double_t TMVA::RegressionVariance::GetSeparationIndex(const Double_t& n, +Double_t TMVA::RegressionVariance::GetSeparationIndex(const Double_t& n, const Double_t& target , const Double_t& target2) { // return TMath::Sqrt(( target2 - target*target/n) / n); diff --git a/tmva/tmva/src/Results.cxx b/tmva/tmva/src/Results.cxx index 4cfc702ce46..6750ebd5b9f 100644 --- a/tmva/tmva/src/Results.cxx +++ b/tmva/tmva/src/Results.cxx @@ -25,6 +25,11 @@ * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ +/*! \class TMVA::Results +\ingroup TMVA +Class that is the base-class for a vector of result +*/ + #include "TMVA/Results.h" #include "TMVA/MsgLogger.h" @@ -41,12 +46,10 @@ namespace TMVA { class DataSetInfo; } - - //////////////////////////////////////////////////////////////////////////////// /// constructor -TMVA::Results::Results( const DataSetInfo* dsi, TString resultsName ) +TMVA::Results::Results( const DataSetInfo* dsi, TString resultsName ) : fTreeType(Types::kTraining), fDsi(dsi), fStorage( new TList() ), @@ -56,7 +59,7 @@ TMVA::Results::Results( const DataSetInfo* dsi, TString resultsName ) fStorage->SetOwner(); } -TMVA::Results::Results( ) +TMVA::Results::Results( ) : fTreeType(Types::kTraining), fDsi(0), fStorage( new TList() ), @@ -70,7 +73,7 @@ fLogger( new MsgLogger("Results", kINFO)) //////////////////////////////////////////////////////////////////////////////// /// destructor -TMVA::Results::~Results() +TMVA::Results::~Results() { // delete result-histograms delete fStorage; @@ -104,7 +107,7 @@ void TMVA::Results::Store( TObject* obj, const char* alias ) //////////////////////////////////////////////////////////////////////////////// -TObject* TMVA::Results::GetObject(const TString & alias) const +TObject* TMVA::Results::GetObject(const TString & alias) const { std::map<TString, TObject*>::iterator it = fHistAlias->find(alias); @@ -118,13 +121,13 @@ TObject* TMVA::Results::GetObject(const TString & alias) const Bool_t TMVA::Results::DoesExist(const TString & alias) const { TObject* test = GetObject(alias); - + return test; } //////////////////////////////////////////////////////////////////////////////// -TH1* TMVA::Results::GetHist(const TString & alias) const +TH1* TMVA::Results::GetHist(const TString & alias) const { TH1* out=dynamic_cast<TH1*>(GetObject(alias)); if (!out) Log() <<kWARNING << "You have asked for histogram " << alias << " which does not seem to exist in *Results* .. better don't use it " << Endl; @@ -133,7 +136,7 @@ TH1* TMVA::Results::GetHist(const TString & alias) const //////////////////////////////////////////////////////////////////////////////// -TH2* TMVA::Results::GetHist2D(const TString & alias) const +TH2* TMVA::Results::GetHist2D(const TString & alias) const { TH2* out=dynamic_cast<TH2*>(GetObject(alias)); if (!out) Log() <<kWARNING << "You have asked for 2D histogram " << alias << " which does not seem to exist in *Results* .. better don't use it " << Endl; @@ -141,7 +144,7 @@ TH2* TMVA::Results::GetHist2D(const TString & alias) const } //////////////////////////////////////////////////////////////////////////////// -TGraph* TMVA::Results::GetGraph(const TString & alias) const +TGraph* TMVA::Results::GetGraph(const TString & alias) const { return (TGraph*)GetObject(alias); } diff --git a/tmva/tmva/src/ResultsClassification.cxx b/tmva/tmva/src/ResultsClassification.cxx index 4a664139159..57587b03338 100644 --- a/tmva/tmva/src/ResultsClassification.cxx +++ b/tmva/tmva/src/ResultsClassification.cxx @@ -25,6 +25,11 @@ * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ +/*! \class TMVA::ResultsClassification +\ingroup TMVA +Class that is the base-class for a vector of result +*/ + #include "TMVA/ResultsClassification.h" #include "TMVA/MsgLogger.h" @@ -43,7 +48,7 @@ namespace TMVA { //////////////////////////////////////////////////////////////////////////////// /// constructor -TMVA::ResultsClassification::ResultsClassification( const DataSetInfo* dsi, TString resultsName ) +TMVA::ResultsClassification::ResultsClassification( const DataSetInfo* dsi, TString resultsName ) : Results( dsi,resultsName ), fRet(1), fLogger( new MsgLogger(Form("ResultsClassification%s",resultsName.Data()) , kINFO) ) @@ -61,11 +66,8 @@ TMVA::ResultsClassification::~ResultsClassification() //////////////////////////////////////////////////////////////////////////////// /// set MVA response -void TMVA::ResultsClassification::SetValue( Float_t value, Int_t ievt ) +void TMVA::ResultsClassification::SetValue( Float_t value, Int_t ievt ) { if (ievt >= (Int_t)fMvaValues.size()) fMvaValues.resize( ievt+1 ); fMvaValues[ievt] = value; } - - - diff --git a/tmva/tmva/src/ResultsMulticlass.cxx b/tmva/tmva/src/ResultsMulticlass.cxx index 5abc33b2cf5..0efe0bece4b 100644 --- a/tmva/tmva/src/ResultsMulticlass.cxx +++ b/tmva/tmva/src/ResultsMulticlass.cxx @@ -27,6 +27,11 @@ * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ +/*! \class TMVA::ResultsMulticlass +\ingroup TMVA +Class which takes the results of a multiclass classification +*/ + #include "TMVA/ResultsMulticlass.h" #include "TMVA/DataSet.h" @@ -47,7 +52,7 @@ //////////////////////////////////////////////////////////////////////////////// /// constructor -TMVA::ResultsMulticlass::ResultsMulticlass( const DataSetInfo* dsi, TString resultsName ) +TMVA::ResultsMulticlass::ResultsMulticlass( const DataSetInfo* dsi, TString resultsName ) : Results( dsi, resultsName ), IFitterTarget(), fLogger( new MsgLogger(Form("ResultsMultiClass%s",resultsName.Data()) , kINFO) ), @@ -61,7 +66,7 @@ TMVA::ResultsMulticlass::ResultsMulticlass( const DataSetInfo* dsi, TString resu //////////////////////////////////////////////////////////////////////////////// /// destructor -TMVA::ResultsMulticlass::~ResultsMulticlass() +TMVA::ResultsMulticlass::~ResultsMulticlass() { delete fLogger; } @@ -71,19 +76,19 @@ TMVA::ResultsMulticlass::~ResultsMulticlass() void TMVA::ResultsMulticlass::SetValue( std::vector<Float_t>& value, Int_t ievt ) { if (ievt >= (Int_t)fMultiClassValues.size()) fMultiClassValues.resize( ievt+1 ); - fMultiClassValues[ievt] = value; + fMultiClassValues[ievt] = value; } - -//_______________________________________________________________________ - + +//////////////////////////////////////////////////////////////////////////////// + Double_t TMVA::ResultsMulticlass::EstimatorFunction( std::vector<Double_t> & cutvalues ){ - + DataSet* ds = GetDataSet(); ds->SetCurrentType( GetTreeType() ); Float_t truePositive = 0; Float_t falsePositive = 0; Float_t sumWeights = 0; - + for (Int_t ievt=0; ievt<ds->GetNEvents(); ievt++) { const Event* ev = ds->GetEvent(ievt); Float_t w = ev->GetWeight(); @@ -103,11 +108,11 @@ Double_t TMVA::ResultsMulticlass::EstimatorFunction( std::vector<Double_t> & cut else falsePositive += w; } - + Float_t eff = truePositive/sumWeights; Float_t pur = truePositive/(truePositive+falsePositive); Float_t effTimesPur = eff*pur; - + Float_t toMinimize = std::numeric_limits<float>::max(); if( effTimesPur > 0 ) toMinimize = 1./(effTimesPur); // we want to minimize 1/efficiency*purity @@ -118,48 +123,48 @@ Double_t TMVA::ResultsMulticlass::EstimatorFunction( std::vector<Double_t> & cut return toMinimize; } -//_______________________________________________________________________ +//////////////////////////////////////////////////////////////////////////////// +///calculate the best working point (optimal cut values) +///for the multiclass classifier std::vector<Double_t> TMVA::ResultsMulticlass::GetBestMultiClassCuts(UInt_t targetClass){ - //calculate the best working point (optimal cut values) - //for the multiclass classifier const DataSetInfo* dsi = GetDataSetInfo(); - Log() << kINFO << "Calculating best set of cuts for class " + Log() << kINFO << "Calculating best set of cuts for class " << dsi->GetClassInfo( targetClass )->GetName() << Endl; - + fClassToOptimize = targetClass; std::vector<Interval*> ranges(dsi->GetNClasses(), new Interval(-1,1)); - + const TString name( "MulticlassGA" ); const TString opts( "PopSize=100:Steps=30" ); GeneticFitter mg( *this, name, ranges, opts); - + std::vector<Double_t> result; mg.Run(result); fBestCuts.at(targetClass) = result; - + UInt_t n = 0; for( std::vector<Double_t>::iterator it = result.begin(); it<result.end(); it++ ){ Log() << kINFO << " cutValue[" <<dsi->GetClassInfo( n )->GetName() << "] = " << (*it) << ";"<< Endl; n++; } - + return result; } -//_______________________________________________________________________ +//////////////////////////////////////////////////////////////////////////////// +/// this function fills the mva response histos for multiclass classification void TMVA::ResultsMulticlass::CreateMulticlassHistos( TString prefix, Int_t nbins, Int_t /* nbins_high */ ) { - //this function fills the mva response histos for multiclass classification Log() << kINFO << "Creating multiclass response histograms..." << Endl; - + DataSet* ds = GetDataSet(); ds->SetCurrentType( GetTreeType() ); const DataSetInfo* dsi = GetDataSetInfo(); - + std::vector<std::vector<TH1F*> > histos; Float_t xmin = 0.-0.0002; Float_t xmax = 1.+0.0002; @@ -201,7 +206,7 @@ void TMVA::ResultsMulticlass::CreateMulticlassHistos( TString prefix, Int_t nbi histos_highbin.at(iCls).push_back(new TH1F(name,name,nbins_high,xmin,xmax)); } } - + for (Int_t ievt=0; ievt<ds->GetNEvents(); ievt++) { const Event* ev = ds->GetEvent(ievt); Int_t cls = ev->GetClass(); diff --git a/tmva/tmva/src/ResultsRegression.cxx b/tmva/tmva/src/ResultsRegression.cxx index e190dac0b02..2b72ff0d776 100644 --- a/tmva/tmva/src/ResultsRegression.cxx +++ b/tmva/tmva/src/ResultsRegression.cxx @@ -25,6 +25,10 @@ * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ +/*! \class TMVA::ResultsRegression +\ingroup TMVA +Class that is the base-class for a vector of result +*/ #include "TMVA/ResultsRegression.h" #include "TMVA/DataSet.h" @@ -44,7 +48,7 @@ //////////////////////////////////////////////////////////////////////////////// /// constructor -TMVA::ResultsRegression::ResultsRegression( const DataSetInfo* dsi, TString resultsName ) +TMVA::ResultsRegression::ResultsRegression( const DataSetInfo* dsi, TString resultsName ) : Results( dsi, resultsName ), fLogger( new MsgLogger(Form("ResultsRegression%s",resultsName.Data()) , kINFO) ) { @@ -53,7 +57,7 @@ TMVA::ResultsRegression::ResultsRegression( const DataSetInfo* dsi, TString resu //////////////////////////////////////////////////////////////////////////////// /// destructor -TMVA::ResultsRegression::~ResultsRegression() +TMVA::ResultsRegression::~ResultsRegression() { delete fLogger; } @@ -63,7 +67,7 @@ TMVA::ResultsRegression::~ResultsRegression() void TMVA::ResultsRegression::SetValue( std::vector<Float_t>& value, Int_t ievt ) { if (ievt >= (Int_t)fRegValues.size()) fRegValues.resize( ievt+1 ); - fRegValues[ievt] = value; + fRegValues[ievt] = value; } //////////////////////////////////////////////////////////////////////////////// @@ -86,7 +90,7 @@ TH1F* TMVA::ResultsRegression::QuadraticDeviation( UInt_t tgtNum , Bool_t trunc Float_t val = regVal.at( tgtNum ) - ev->GetTarget( tgtNum ); val *= val; xmax = val> xmax? val: xmax; - } + } } xmax *= 1.1; Int_t nbins = 500; @@ -102,7 +106,7 @@ TH1F* TMVA::ResultsRegression::QuadraticDeviation( UInt_t tgtNum , Bool_t trunc val *= val; Float_t weight = ev->GetWeight(); if (!truncate || val<=truncvalue ) h->Fill( val, weight); - } + } return h; } @@ -112,7 +116,7 @@ TH2F* TMVA::ResultsRegression::DeviationAsAFunctionOf( UInt_t varNum, UInt_t tg { DataSet* ds = GetDataSet(); ds->SetCurrentType( GetTreeType() ); - + TString name( Form("tgt_%d_var_%d",tgtNum, varNum) ); const DataSetInfo* dsi = GetDataSetInfo(); Float_t xmin, xmax; @@ -173,7 +177,7 @@ TH2F* TMVA::ResultsRegression::DeviationAsAFunctionOf( UInt_t varNum, UInt_t tg ymax += 1.01*epsilon; - TH2F* h = new TH2F( name, name, nxbins, xmin, xmax, nybins, ymin, ymax ); + TH2F* h = new TH2F( name, name, nxbins, xmin, xmax, nybins, ymin, ymax ); h->SetDirectory(0); h->GetXaxis()->SetTitle( (takeTargets ? dsi->GetTargetInfo(varNum).GetTitle() : dsi->GetVariableInfo(varNum).GetTitle() ) ); diff --git a/tmva/tmva/src/RootFinder.cxx b/tmva/tmva/src/RootFinder.cxx index 83af3d8677e..6d2450776c4 100644 --- a/tmva/tmva/src/RootFinder.cxx +++ b/tmva/tmva/src/RootFinder.cxx @@ -1,4 +1,4 @@ -// @(#)root/tmva $Id$ +// @(#)root/tmva $Id$ // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss /********************************************************************************** @@ -16,15 +16,20 @@ * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada * * * * Copyright (c) 2005: * - * CERN, Switzerland * - * U. of Victoria, Canada * - * MPI-K Heidelberg, Germany * + * CERN, Switzerland * + * U. of Victoria, Canada * + * MPI-K Heidelberg, Germany * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted according to the terms listed in LICENSE * * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ +/*! \class TMVA::RootFinder +\ingroup TMVA +Root finding using Brents algorithm (translated from CERNLIB function RZERO) +*/ + #include "TMVA/RootFinder.h" #include "TMVA/MethodBase.h" @@ -39,11 +44,10 @@ ClassImp(TMVA::RootFinder) //////////////////////////////////////////////////////////////////////////////// /// constructor - TMVA::RootFinder::RootFinder(TMVA::MethodBase *method , - Double_t rootMin, + Double_t rootMin, Double_t rootMax, - Int_t maxIterations, + Int_t maxIterations, Double_t absTolerance ) : fRootMin( rootMin ), fRootMax( rootMax ), @@ -73,7 +77,7 @@ Double_t TMVA::RootFinder::Root( Double_t refValue ) if (fb*fa > 0) { Log() << kWARNING << "<Root> initial interval w/o root: " << "(a=" << a << ", b=" << b << ")," - << " (Eff_a=" << fMethod->GetValueForRoot( a ) + << " (Eff_a=" << fMethod->GetValueForRoot( a ) << ", Eff_b=" << fMethod->GetValueForRoot( b ) << "), " << "(fa=" << fa << ", fb=" << fb << "), " << "refValue = " << refValue << Endl; @@ -91,7 +95,7 @@ Double_t TMVA::RootFinder::Root( Double_t refValue ) c = a; fc = fa; d = b - a; e = b - a; } - + if (TMath::Abs(fc) < TMath::Abs(fb)) { ac_equal = kTRUE; a = b; b = c; c = a; @@ -101,14 +105,14 @@ Double_t TMVA::RootFinder::Root( Double_t refValue ) Double_t tol = 0.5 * 2.2204460492503131e-16 * TMath::Abs(b); Double_t m = 0.5 * (c - b); if (fb == 0 || TMath::Abs(m) <= tol || TMath::Abs(fb) < fAbsTol) return b; - + // Bounds decreasing too slowly: use bisection - if (TMath::Abs (e) < tol || TMath::Abs (fa) <= TMath::Abs (fb)) { d = m; e = m; } + if (TMath::Abs (e) < tol || TMath::Abs (fa) <= TMath::Abs (fb)) { d = m; e = m; } else { // Attempt inverse cubic interpolation Double_t p, q, r; Double_t s = fb / fa; - + if (ac_equal) { p = 2 * m * s; q = 1 - s; } else { q = fa / fc; r = fb / fc; @@ -118,7 +122,7 @@ Double_t TMVA::RootFinder::Root( Double_t refValue ) // Check whether we are in bounds if (p > 0) q = -q; else p = -p; - + Double_t min1 = 3 * m * q - TMath::Abs (tol * q); Double_t min2 = TMath::Abs (e * q); if (2 * p < (min1 < min2 ? min1 : min2)) { @@ -138,9 +142,8 @@ Double_t TMVA::RootFinder::Root( Double_t refValue ) } // Return our best guess if we run out of iterations - Log() << kWARNING << "<Root> maximum iterations (" << fMaxIter + Log() << kWARNING << "<Root> maximum iterations (" << fMaxIter << ") reached before convergence" << Endl; return b; } - diff --git a/tmva/tmva/src/Rule.cxx b/tmva/tmva/src/Rule.cxx index f137428b8e5..7af0933d7e1 100644 --- a/tmva/tmva/src/Rule.cxx +++ b/tmva/tmva/src/Rule.cxx @@ -8,9 +8,9 @@ * Web : http://tmva.sourceforge.net * * * * Description: * - * A class describung a 'rule' * + * A class describing a 'rule' * * Each internal node of a tree defines a rule from all the parental nodes. * - * A rule consists of atleast 2 nodes. * + * A rule consists of at least 2 nodes. * * Input: a decision tree (in the constructor) * * * * Authors (alphabetical): * @@ -27,22 +27,24 @@ * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ -//________________________________________________________________________________ -// -// Implementation of a rule -// -// A rule is simply a branch or a part of a branch in a tree. -// It fullfills the following: -// * First node is the root node of the originating tree -// * Consists of a minimum of 2 nodes -// * A rule returns for a given event: -// 0 : if the event fails at any node -// 1 : otherwise -// * If the rule contains <2 nodes, it returns 0 SHOULD NOT HAPPEN! -// -// The coefficient is found by either brute force or some sort of -// intelligent fitting. See the RuleEnsemble class for more info. -//________________________________________________________________________________ +/*! \class TMVA::Rule +\ingroup TMVA + +Implementation of a rule. + +A rule is simply a branch or a part of a branch in a tree. +It fulfills the following: + + - First node is the root node of the originating tree + - Consists of a minimum of 2 nodes + - A rule returns for a given event: + - 0 : if the event fails at any node + - 1 : otherwise + - If the rule contains <2 nodes, it returns 0 SHOULD NOT HAPPEN! + +The coefficient is found by either brute force or some sort of +intelligent fitting. See the RuleEnsemble class for more info. +*/ #include "TMVA/Rule.h" @@ -123,7 +125,7 @@ TMVA::Rule::Rule() //////////////////////////////////////////////////////////////////////////////// /// destructor -TMVA::Rule::~Rule() +TMVA::Rule::~Rule() { delete fCut; delete fLogger; @@ -149,21 +151,21 @@ Bool_t TMVA::Rule::ContainsVariable(UInt_t iv) const //////////////////////////////////////////////////////////////////////////////// -void TMVA::Rule::SetMsgType( EMsgType t ) +void TMVA::Rule::SetMsgType( EMsgType t ) { fLogger->SetMinType(t); } //////////////////////////////////////////////////////////////////////////////// -/// /// Compare two rules. -/// useCutValue: true -> calculate a distance between the two rules based on the cut values -/// if the rule cuts are not equal, the distance is < 0 (-1.0) -/// return true if d<mindist -/// false-> ignore mindist, return true if rules are equal, ignoring cut values -/// mindist: min distance allowed between rules; if < 0 => set useCutValue=false; /// +/// - useCutValue: +/// - true -> calculate a distance between the two rules based on the cut values +/// if the rule cuts are not equal, the distance is < 0 (-1.0) +/// return true if d<mindist +/// - false-> ignore mindist, return true if rules are equal, ignoring cut values +/// - mindist: min distance allowed between rules; if < 0 => set useCutValue=false; Bool_t TMVA::Rule::Equal( const Rule& other, Bool_t useCutValue, Double_t mindist ) const { @@ -179,10 +181,11 @@ Bool_t TMVA::Rule::Equal( const Rule& other, Bool_t useCutValue, Double_t mindis //////////////////////////////////////////////////////////////////////////////// /// Returns: -/// -1.0 : rules are NOT equal, i.e, variables and/or cut directions are wrong -/// >=0: rules are equal apart from the cutvalue, returns d = sqrt(sum(c1-c2)^2) -/// If not useCutValue, the distance is exactly zero if they are equal /// +/// * -1.0 : rules are NOT equal, i.e, variables and/or cut directions are wrong +/// * >=0: rules are equal apart from the cutvalue, returns \f$ d = \sqrt{\sum(c1-c2)^2} \f$ +/// +/// If not useCutValue, the distance is exactly zero if they are equal Double_t TMVA::Rule::RuleDist( const Rule& other, Bool_t useCutValue ) const { @@ -306,7 +309,7 @@ void TMVA::Rule::Print( std::ostream& os ) const os << " Importance = " << Form("%1.4f", fImportance/fImportanceRef) << std::endl; os << " Coefficient = " << Form("%1.4f", fCoefficient) << std::endl; os << " Support = " << Form("%1.4f", fSupport) << std::endl; - os << " S/(S+B) = " << Form("%1.4f", fSSB) << std::endl; + os << " S/(S+B) = " << Form("%1.4f", fSSB) << std::endl; for ( UInt_t i=0; i<nvars; i++) { os << " "; @@ -340,7 +343,7 @@ void TMVA::Rule::PrintLogger(const char *title) const << "Importance = " << Form("%1.4f", fImportance/fImportanceRef) << Endl; for ( UInt_t i=0; i<nvars; i++) { - + Log() << kINFO << " "; sel = fCut->GetSelector(i); valmin = fCut->GetCutMin(i); @@ -390,7 +393,7 @@ void TMVA::Rule::PrintRaw( std::ostream& os ) const //////////////////////////////////////////////////////////////////////////////// -void* TMVA::Rule::AddXMLTo( void* parent ) const +void* TMVA::Rule::AddXMLTo( void* parent ) const { void* rule = gTools().AddChild( parent, "Rule" ); const UInt_t nvars = fCut->GetNvars(); -- GitLab