Logo ROOT   6.08/07
Reference Guide
SeparationBase.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : SeparationBase *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: An interface to different separation critiera useded in various *
11  * training algorithms, as there are: *
12  * *
13  * There are two things: the Separation Index, and the Separation Gain *
14  * Separation Index: *
15  * Measure of the "purity" of a sample. If all elements (events) in the *
16  * sample belong to the same class (e.g. signal or backgr), than the *
17  * separation index is 0 (meaning 100% purity (or 0% purity as it is *
18  * symmetric. The index becomes maximal, for perfectly mixed samples *
19  * eg. purity=50% , N_signal = N_bkg *
20  * *
21  * Separation Gain: *
22  * the measure of how the quality of separation of the sample increases *
23  * by splitting the sample e.g. into a "left-node" and a "right-node" *
24  * (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right) *
25  * this is then the quality crition which is optimized for when trying *
26  * to increase the information in the system (making the best selection *
27  * *
28  * Authors (alphabetical): *
29  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
30  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
31  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
32  * *
33  * Copyright (c) 2005: *
34  * CERN, Switzerland *
35  * U. of Victoria, Canada *
36  * Heidelberg U., Germany *
37  * *
38  * Redistribution and use in source and binary forms, with or without *
39  * modification, are permitted according to the terms listed in LICENSE *
40  * (http://ttmva.sourceforge.net/LICENSE) *
41  **********************************************************************************/
42 
43 #include "TMVA/SeparationBase.h"
44 
45 #include "TMath.h"
46 #include "TString.h"
47 
48 #include <iostream>
49 #include <limits>
50 
52 
54 fName(""),
55  fPrecisionCut(TMath::Sqrt(std::numeric_limits<double>::epsilon()))
56 {
57  // default constructor
58 }
59 
60 //copy constructor
62  fName(s.fName),
63  fPrecisionCut(TMath::Sqrt(std::numeric_limits<double>::epsilon()))
64 {
65  // copy constructor
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Separation Gain:
70 /// the measure of how the quality of separation of the sample increases
71 /// by splitting the sample e.g. into a "left-node" and a "right-node"
72 /// (N * Index_parent) - (N_left * Index_left) - (N_right * Index_right)
73 /// this is then the quality crition which is optimized for when trying
74 /// to increase the information in the system (making the best selection
75 
77  const Double_t& nTotS, const Double_t& nTotB)
78 {
79  if ( (nTotS-nSelS)==nSelS && (nTotB-nSelB)==nSelB) return 0.;
80 
81  // Double_t parentIndex = (nTotS+nTotB) *this->GetSeparationIndex(nTotS,nTotB);
82 
83  // Double_t leftIndex = ( ((nTotS - nSelS) + (nTotB - nSelB))
84  // * this->GetSeparationIndex(nTotS-nSelS,nTotB-nSelB) );
85  // Double_t rightIndex = (nSelS+nSelB) * this->GetSeparationIndex(nSelS,nSelB);
86 
87 
88  Double_t parentIndex = this->GetSeparationIndex(nTotS,nTotB);
89 
90  Double_t leftIndex = ( ((nTotS - nSelS) + (nTotB - nSelB))/(nTotS+nTotB)
91  * this->GetSeparationIndex(nTotS-nSelS,nTotB-nSelB) );
92  Double_t rightIndex = (nSelS+nSelB)/(nTotS+nTotB) * this->GetSeparationIndex(nSelS,nSelB);
93 
94  Double_t diff = parentIndex - leftIndex - rightIndex;
95  //Double_t diff = (parentIndex - leftIndex - rightIndex)/(nTotS+nTotB);
96 
97  if(diff<fPrecisionCut ) {
98  // std::cout << " Warning value in GetSeparation is below numerical presicion "
99  // << diff/parentIndex
100  // << std::endl;
101  return 0;
102  }
103 
104  return diff;
105 }
106 
107 
STL namespace.
Double_t Sqrt(Double_t x)
REAL epsilon
Definition: triangle.c:617
virtual Double_t GetSeparationGain(const Double_t &nSelS, const Double_t &nSelB, const Double_t &nTotS, const Double_t &nTotB)
Separation Gain: the measure of how the quality of separation of the sample increases by splitting th...
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
Abstract ClassifierFactory template that handles arbitrary types.
virtual Double_t GetSeparationIndex(const Double_t &s, const Double_t &b)=0