#include "Riostream.h"
#include "TMVA/Ranking.h"
#include "TString.h"
ClassImp(TMVA::Ranking)
TMVA::Ranking::Ranking()
: fLogger( "" )
{
fRanking.clear();
}
TMVA::Ranking::Ranking( const TString& context, const TString& rankingDiscriminatorName )
: fContext( context ),
fRankingDiscriminatorName( rankingDiscriminatorName ),
fLogger( fContext.Data() )
{
}
TMVA::Ranking::~Ranking()
{
for (std::vector<Rank*>::iterator ir = fRanking.begin(); ir != fRanking.end(); ir++ )
delete *ir;
fRanking.clear();
}
void TMVA::Ranking::AddRank( const Rank& rank )
{
fRanking.push_back( new Rank(rank) );
UInt_t sizeofarray=fRanking.size();
for (UInt_t i=0; i<sizeofarray; i++) {
for (UInt_t j=sizeofarray-1; j>i; j--) {
if (*fRanking[j-1] < *fRanking[j]) {
Rank * temp = fRanking[j-1];fRanking[j-1] = fRanking[j]; fRanking[j] = temp;
}
}
}
for (UInt_t i=0; i<fRanking.size(); i++) fRanking[i]->SetRank( i+1 );
}
void TMVA::Ranking::Print() const
{
Int_t maxL = 0;
for (std::vector<Rank*>::const_iterator ir = fRanking.begin(); ir != fRanking.end(); ir++ )
if ((*ir)->GetVariable().Length() > maxL) maxL = (*ir)->GetVariable().Length();
fLogger << kINFO << "Ranking result (top variable is best ranked)" << Endl;
fLogger << kINFO << "----------------------------------------------------------------" << Endl;
fLogger << kINFO << setiosflags(ios::left)
<< setw(5) << "Rank : "
<< setw(maxL+0) << "Variable "
<< resetiosflags(ios::right)
<< " : " << fRankingDiscriminatorName << Endl;
fLogger << kINFO << "----------------------------------------------------------------" << Endl;
for (std::vector<Rank*>::const_iterator ir = fRanking.begin(); ir != fRanking.end(); ir++ ) {
fLogger << kINFO
<< Form( "%4i : ",(*ir)->GetRank() )
<< setw(TMath::Max(maxL+0,9)) << (*ir)->GetVariable().Data()
<< Form( " : %3.3e", (*ir)->GetRankValue() ) << Endl;
}
fLogger << kINFO << "----------------------------------------------------------------" << Endl;
}
TMVA::Rank::Rank( TString variable, Double_t rankValue )
: fVariable( variable ),
fRankValue( rankValue ),
fRank( -1 )
{
}
TMVA::Rank::~Rank()
{
}
Bool_t TMVA::Rank::operator< ( const Rank& other ) const
{
if (fRankValue < other.fRankValue) return true;
else return false;
}
Bool_t TMVA::Rank::operator> ( const Rank& other ) const
{
if (fRankValue > other.fRankValue) return true;
else return false;
}
Last change: Wed Jun 25 08:48:44 2008
Last generated: 2008-06-25 08:48
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.