ROOT  6.06/09
Reference Guide
GiniIndex.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : TMVA::GiniIndex *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: Implementation of the GiniIndex as separation criterion *
11  * Large Gini Indices (maximum 0.5) mean , that the sample is well *
12  * mixed (same amount of signal and bkg) *
13  * bkg. Small Indices mean, well separated. *
14  * general defniniton: *
15  * Gini(Sample M) = 1 - (c(1)/N)^2 - (c(2)/N)^2 .... - (c(k)/N)^2 *
16  * Where: M is a smaple of whatever N elements (events) *
17  * that belong to K different classes *
18  * c(k) is the number of elements that belong to class k *
19  * for just Signal and Background classes this boils down to: *
20  * Gini(Sample) = 2s*b/(s+b)^2 *
21  * *
22  * Authors (alphabetical): *
23  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
24  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
25  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
26  * *
27  * Copyright (c) 2005: *
28  * CERN, Switzerland *
29  * U. of Victoria, Canada *
30  * Heidelberg U., Germany *
31  * *
32  * Redistribution and use in source and binary forms, with or without *
33  * modification, are permitted according to the terms listed in LICENSE *
34  * (http://tmva.sourceforge.net/LICENSE) *
35  **********************************************************************************/
36 
37 //_______________________________________________________________________
38 //
39 // Implementation of the GiniIndex as separation criterion
40 //
41 //_______________________________________________________________________
42 
43 #include "TMVA/GiniIndex.h"
44 
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// Gini(Sample M) = 1 - (c(1)/N)^2 - (c(2)/N)^2 .... - (c(k)/N)^2
49 /// Where: M is a smaple of whatever N elements (events)
50 /// that belong to K different classes
51 /// c(k) is the number of elements that belong to class k
52 /// for just Signal and Background classes this boils down to:
53 /// Gini(Sample) = 2s*b/(s+b)^2 ( = 2 * purity * (1-purity) )
54 ///
55 /// !! what we use here is 2*Gini.. as for the later use the factor
56 /// 2 is irrelevant and hence I'd like to save this calculation
57 
58 Double_t TMVA::GiniIndex::GetSeparationIndex( const Double_t &s, const Double_t &b )
59 {
60  if (s+b <= 0) return 0;
61  if (s<=0 || b <=0) return 0;
62  // else return s*b/(s+b)/(s+b);
63  else return 2*s*b/(s+b)/(s+b);
64 }
65 
66 
double Double_t
Definition: RtypesCore.h:55
ClassImp(TMVA::GiniIndex) Double_t TMVA
Gini(Sample M) = 1 - (c(1)/N)^2 - (c(2)/N)^2 ....
Definition: GiniIndex.cxx:45
Abstract ClassifierFactory template that handles arbitrary types.