119 Q =
dt->TestPrunedTreeQuality();
121 Log() << kDEBUG <<
"Node purity limit is: " <<
dt->GetNodePurityLimit() <<
Endl;
122 Log() << kDEBUG <<
"Sum of weights in pruning validation sample: " <<
W <<
Endl;
123 Log() << kDEBUG <<
"Quality of tree prior to any pruning is " << Q/
W <<
Endl;
130 catch(
const std::string &error) {
131 Log() << kERROR <<
"Couldn't initialize the tree meta data because of error ("
132 << error <<
")" <<
Endl;
136 Log() << kDEBUG <<
"Automatic cost complexity pruning is " << (
IsAutomatic()?
"on":
"off") <<
"." <<
Endl;
141 catch(
const std::string &error) {
142 Log() << kERROR <<
"Error optimizing pruning sequence ("
143 << error <<
")" <<
Endl;
147 Log() << kDEBUG <<
"Index of pruning sequence to stop at: " <<
fOptimalK <<
Endl;
154 info->PruneStrength = 0;
155 info->QualityIndex = Q/
W;
156 info->PruneSequence.clear();
157 Log() << kINFO <<
"no proper pruning could be calculated. Tree "
158 <<
dt->GetTreeID() <<
" will not be pruned. Do not worry if this "
159 <<
" happens for a few trees " <<
Endl;
182 if(
n ==
NULL )
return;
188 else n->SetNodeR( (s+
b)*
n->GetSeparationIndex() );
190 if(
n->GetLeft() !=
NULL &&
n->GetRight() !=
NULL) {
196 n->SetNTerminal(
n->GetLeft()->GetNTerminal() +
197 n->GetRight()->GetNTerminal());
199 n->SetSubTreeR( (
n->GetLeft()->GetSubTreeR() +
200 n->GetRight()->GetSubTreeR()));
202 n->SetAlpha( ((
n->GetNodeR() -
n->GetSubTreeR()) /
203 (
n->GetNTerminal() - 1)));
207 n->SetAlphaMinSubtree( std::min(
n->GetAlpha(), std::min(
n->GetLeft()->GetAlphaMinSubtree(),
208 n->GetRight()->GetAlphaMinSubtree())));
209 n->SetCC(
n->GetAlpha());
212 n->SetNTerminal( 1 );
n->SetTerminal( );
214 else n->SetSubTreeR( (s+
b)*
n->GetSeparationIndex() );
215 n->SetAlpha(std::numeric_limits<double>::infinity( ));
216 n->SetAlphaMinSubtree(std::numeric_limits<double>::infinity( ));
217 n->SetCC(
n->GetAlpha());
239 Double_t epsilon = std::numeric_limits<double>::epsilon();
250 qmin =
dt->TestPrunedTreeQuality()/weights;
262 while(
R->GetNTerminal() > 1) {
265 alpha =
TMath::Max(
R->GetAlphaMinSubtree(), alpha);
267 if(
R->GetAlphaMinSubtree() >=
R->GetAlpha() ) {
268 Log() << kDEBUG <<
"\nCaught trying to prune the root node!" <<
Endl;
289 Log() << kDEBUG <<
"\nCaught trying to prune the root node!" <<
Endl;
302 dt->PruneNodeInPlace(t);
310 t->
GetRight()->GetAlphaMinSubtree())));
315 Log() << kDEBUG <<
"after this pruning step I would have " <<
R->GetNTerminal() <<
" remaining terminal nodes " <<
Endl;
351 Log() << kDEBUG <<
"\n************ Summary for Tree " <<
dt->GetTreeID() <<
" *******" <<
Endl
354 Log() << kDEBUG <<
"Pruning strength parameters: [";
359 Log() << kDEBUG <<
"Misclassification rates: [";
#define R(a, b, c, d, e, f, g, h, i)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void SetCC(Double_t cc)
Set CC, if traininfo defined, otherwise Log Fatal.
Double_t GetSubTreeR() const
return the resubstitution estimate, R(T_t), of the tree rooted at this node, or -1 if traininfo undef...
void SetAlphaMinSubtree(Double_t g)
set the minimum alpha in the tree rooted at this node, if traininfo defined
Double_t GetAlphaMinSubtree() const
return the minimum alpha in the tree rooted at this node, or -1 if traininfo undefined
void SetSubTreeR(Double_t r)
set the resubstitution estimate, R(T_t), of the tree rooted at this node, if traininfo defined
virtual DecisionTreeNode * GetLeft() const
Double_t GetNodeR() const
return the node resubstitution estimate, R(t), for Cost Complexity pruning, or -1 if traininfo undefi...
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
void SetAlpha(Double_t alpha)
set the critical point alpha, if traininfo defined
virtual DecisionTreeNode * GetParent() const
void SetNTerminal(Int_t n)
set number of terminal nodes in the subtree rooted here, if traininfo defined
virtual DecisionTreeNode * GetRight() const
Implementation of a Decision Tree.
ostringstream derivative to redirect and format output
void SetMinType(EMsgType minType)
An interface to calculate the "SeparationGain" for different separation criteria used in various trai...
virtual Double_t GetSeparationIndex(const Double_t s, const Double_t b)=0
create variable transformations
MsgLogger & Endl(MsgLogger &ml)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.