diff --git a/tmva/src/MethodBDT.cxx b/tmva/src/MethodBDT.cxx index 2c3850de0a36f55b254fb5e6c0b7d4fdb7e59639..580045a67f905667a68c0e45379fa5ab6a0aeb44 100644 --- a/tmva/src/MethodBDT.cxx +++ b/tmva/src/MethodBDT.cxx @@ -588,13 +588,31 @@ std::map<TString,Double_t> TMVA::MethodBDT::OptimizeTuningParameters(TString fo // the actual VALUES at (at least for the scan, guess also in GA) are always // read from the middle of the bins. Hence.. the choice of Intervals e.g. for the // MaxDepth, in order to make nice interger values!!! - tuneParameters.insert(std::pair<TString,Interval>("MaxDepth", Interval(1,5,5))); //==stepsize - // tuneParameters.insert(std::pair<TString,Interval>("MaxDepth", Interval(1,15.,15))); // stepsize 1 - // tuneParameters.insert(std::pair<TString,Interval>("NodeMinEvents", Interval(50,500,10))); // 50 to 500 stepsize 25 - // tuneParameters.insert(std::pair<TString,Interval>("NTrees", Interval(50,1000,20))); // stepsize 50 + + // find some reasonable ranges for the optimisation of NodeMinEvents: + + Int_t N = Int_t( Data()->GetNEvtSigTrain()) ; + Int_t min = TMath::Max( 20, ( ( N/10000 - (N/10000)%10) ) ); + Int_t max = TMath::Max( min*10, TMath::Min( 10000, ( ( N/10 - (N/10) %100) ) ) ); + + tuneParameters.insert(std::pair<TString,Interval>("MaxDepth", Interval(1,10,10))); // stepsize 1 + tuneParameters.insert(std::pair<TString,Interval>("NodeMinEvents", Interval(min,max,10))); // + tuneParameters.insert(std::pair<TString,Interval>("NTrees", Interval(50,1000,20))); // stepsize 50 // tuneParameters.insert(std::pair<TString,Interval>("NodePurityLimit",Interval(.4,.6,3))); // stepsize .1 tuneParameters.insert(std::pair<TString,Interval>("AdaBoostBeta", Interval(.5,1.50,10))); //== stepsize .1 + Log() << kINFO << "Automatic optimisation of tuning parameters in BDT uses:" << Endl; + + std::map<TString,TMVA::Interval>::iterator it; + + for (it=tuneParameters.begin(); it!=tuneParameters.end();it++) { + Log() << kINFO << it->first + << " in range from: " << it->second.GetMin() + << " to: " << it->second.GetMax() + << " in : " << it->second.GetNbins() << " steps" + << Endl; + } + Log() << kINFO << " using the options: " << fomType << " and " << fitType << Endl; OptimizeConfigParameters optimize(this, tuneParameters, fomType, fitType); tunedParameters=optimize.optimize(); diff --git a/tmva/src/OptimizeConfigParameters.cxx b/tmva/src/OptimizeConfigParameters.cxx index b1e45bc61cd96117a53d6a1354c8f18b664c557b..461a6cb5dc74c9dd44d8ced51643410ee4b3a9ac 100644 --- a/tmva/src/OptimizeConfigParameters.cxx +++ b/tmva/src/OptimizeConfigParameters.cxx @@ -95,7 +95,7 @@ TMVA::OptimizeConfigParameters::~OptimizeConfigParameters() std::map<TString,Double_t> TMVA::OptimizeConfigParameters::optimize() { if (fOptimizationFitType == "Scan" ) this->optimizeScan(); - else if (fOptimizationFitType == "GA" || fOptimizationFitType == "Minuit" ) this->optimizeFit(); + else if (fOptimizationFitType == "FitGA" || fOptimizationFitType == "Minuit" ) this->optimizeFit(); else { Log() << kFATAL << "You have chosen as optimization type " << fOptimizationFitType << " that is not (yet) coded --> exit()" << Endl; @@ -179,14 +179,14 @@ void TMVA::OptimizeConfigParameters::optimizeFit() fitter = new MinuitFitter( *this, "FitterMinuit_BDTOptimize", ranges, opt ); - }else if ( fOptimizationFitType == "GA" ) { + }else if ( fOptimizationFitType == "FitGA" ) { TString opt="PopSize=20:Steps=30:Cycles=3:ConvCrit=0.01:SaveBestCycle=5"; fitter = new GeneticFitter( *this, "FitterGA_BDTOptimize", ranges, opt ); } else { Log() << kWARNING << " you did not specify a valid OptimizationFitType " - << " will use the default (GA) " << Endl; + << " will use the default (FitGA) " << Endl; TString opt="PopSize=20:Steps=30:Cycles=3:ConvCrit=0.01:SaveBestCycle=5"; fitter = new GeneticFitter( *this, "FitterGA_BDTOptimize", diff --git a/tmva/src/RegressionVariance.cxx b/tmva/src/RegressionVariance.cxx index 24462a288b945fb76c2e957728e5eeee4d76fd52..a4bbe0cc4581ab1d1d420dd6d50c354350bbe5e6 100644 --- a/tmva/src/RegressionVariance.cxx +++ b/tmva/src/RegressionVariance.cxx @@ -34,6 +34,7 @@ * (http://ttmva.sourceforge.net/LICENSE) * **********************************************************************************/ #include <iostream> +#include "TMath.h" #include "TMVA/RegressionVariance.h" ClassImp(TMVA::RegressionVariance) @@ -53,13 +54,14 @@ Double_t TMVA::RegressionVariance::GetSeparationGain(const Double_t &nLeft, // 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... - + if ( nTot==nLeft || nLeft==0 ) return 0.; 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); }