ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tmva
tmva
src
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
45
#include "
Rtypes.h
"
46
47
ClassImp
(
TMVA::GiniIndex
)
48
49
////////////////////////////////////////////////////////////////////////////////
50
/// Gini(Sample M) = 1 - (c(1)/N)^2 - (c(2)/N)^2 .... - (c(k)/N)^2
51
/// Where: M is a smaple of whatever N elements (events)
52
/// that belong to K different classes
53
/// c(k) is the number of elements that belong to class k
54
/// for just Signal and Background classes this boils down to:
55
/// Gini(Sample) = 2s*b/(s+b)^2 ( = 2 * purity * (1-purity) )
56
///
57
/// !! what we use here is 2*Gini.. as for the later use the factor
58
/// 2 is irrelevant and hence I'd like to save this calculation
59
60
Double_t
TMVA::GiniIndex::GetSeparationIndex( const
Double_t
&s, const
Double_t
&b )
61
{
62
if
(s+b <= 0)
return
0;
63
if
(s<=0 || b <=0)
return
0;
64
// else return s*b/(s+b)/(s+b);
65
else
return
2*s*b/(s+b)/(s+b);
66
}
67
68
Rtypes.h
GiniIndex.h
TMVA::GiniIndex
Definition:
GiniIndex.h:65
Double_t
double Double_t
Definition:
RtypesCore.h:55
ClassImp
ClassImp(TMVA::GiniIndex) Double_t TMVA
Gini(Sample M) = 1 - (c(1)/N)^2 - (c(2)/N)^2 ....
Definition:
GiniIndex.cxx:47