38 #ifndef ROOT_TMVA_MsgLogger 41 #ifndef ROOT_TMVA_VariableDecorrTransform 44 #ifndef ROOT_TMVA_Tools 47 #ifndef ROOT_TMVA_DataSet 67 if ((*it) != 0)
delete (*it);
87 Log() <<
kINFO <<
"Preparing the Decorrelation transformation..." <<
Endl;
92 if (inputSize > 200) {
93 Log() <<
kINFO <<
"----------------------------------------------------------------------------" 96 <<
": More than 200 variables, will not calculate decorrelation matrix " 98 Log() <<
kINFO <<
"----------------------------------------------------------------------------" 115 Int_t whichMatrix = cls;
124 Log() <<
kFATAL <<
"Transformation matrix all classes is not defined" 127 Log() <<
kFATAL <<
"Transformation matrix for class " << whichMatrix <<
" is not defined" 132 std::vector<TString>* strVec =
new std::vector<TString>;
135 for (
Int_t ivar=0; ivar<nvar; ivar++) {
137 for (
Int_t jvar=0; jvar<nvar; jvar++) {
138 str += ((*m)(ivar,jvar) > 0) ?
" + " :
" - ";
154 Log() <<
kFATAL <<
"VariableDecorrTransform::GetTransformationStrings : unknown type '" << type <<
"'." <<
Endl;
157 strVec->push_back( str );
169 Log() <<
kFATAL <<
"Transformation matrix not yet created" 172 Int_t whichMatrix = cls;
185 Log() <<
kFATAL <<
"Transformation matrix all classes is not defined" 188 Log() <<
kFATAL <<
"Transformation matrix for class " << whichMatrix <<
" is not defined" 200 std::vector<Float_t> input;
201 std::vector<Char_t> mask;
204 if( hasMaskedEntries ){
207 if( numMasked>0 && numOK>0 ){
208 Log() <<
kFATAL <<
"You mixed variables and targets in the decorrelation transformation. This is not possible." <<
Endl;
215 for (
Int_t ivar=0; ivar<nvar; ivar++) vec(ivar) = input.at(ivar);
221 for (
Int_t ivar=0; ivar<nvar; ivar++) input.push_back( vec(ivar) );
234 Log() <<
kFATAL <<
"Inverse transformation for decorrelation transformation not yet implemented. Hence, this transformation cannot be applied together with regression if targets should be transformed. Please contact the authors if necessary." <<
Endl;
249 if (0 != (*it) ) {
delete (*it); *it=0; }
253 const UInt_t matNum = (maxCls<=1)?maxCls:maxCls+1;
259 for (
UInt_t cls=0; cls<matNum; cls++) {
262 Log() <<
kFATAL <<
"<GetSQRMats> Zero pointer returned for SQR matrix" <<
Endl;
264 delete (*covMat)[cls];
275 Int_t dp = o.precision();
277 o <<
"# correlation matrix " << std::endl;
279 o << cls <<
" " << mat->
GetNrows() <<
" x " << mat->
GetNcols() << std::endl;
282 o << std::setprecision(12) << std::setw(20) << (*mat)[row][col] <<
" ";
288 o <<
"##" << std::endl;
289 o << std::setprecision(dp);
326 if( (*it) != 0 )
delete (*it);
331 void* inpnode =
NULL;
354 std::stringstream s(content);
355 for (
Int_t row = 0; row<nrows; row++) {
356 for (
Int_t col = 0; col<ncols; col++) {
357 s >> (*mat)[row][col];
373 istr.getline(buf,512);
375 Int_t nrows(0), ncols(0);
377 while (!(buf[0]==
'#'&& buf[1]==
'#')) {
379 while (*p==
' ' || *p==
'\t') p++;
380 if (*p==
'#' || *p==
'\0') {
381 istr.getline(buf,512);
384 std::stringstream sstr(buf);
387 if (strvar==
"signal" || strvar==
"background") {
389 if(strvar==
"background") cls=1;
390 if(strvar==classname) classIdx = cls;
392 sstr >> nrows >> dummy >> ncols;
399 istr >> (*mat)[row][col];
403 istr.getline(buf,512);
418 Log() <<
kINFO <<
"Transformation matrix "<< cls <<
":" <<
Endl;
428 Int_t dp = fout.precision();
435 fout <<
" double fDecTF_"<<trCounter<<
"["<<numC<<
"]["<<mat->
GetNrows()<<
"]["<<mat->
GetNcols()<<
"];" << std::endl;
440 fout <<
"//_______________________________________________________________________" << std::endl;
441 fout <<
"inline void " << fcncName <<
"::InitTransform_"<<trCounter<<
"()" << std::endl;
442 fout <<
"{" << std::endl;
443 fout <<
" // Decorrelation transformation, initialisation" << std::endl;
444 for (
UInt_t icls = 0; icls < numC; icls++){
446 for (
int i=0; i<matx->
GetNrows(); i++) {
447 for (
int j=0; j<matx->
GetNcols(); j++) {
448 fout <<
" fDecTF_"<<trCounter<<
"["<<icls<<
"]["<<i<<
"]["<<j<<
"] = " << std::setprecision(12) << (*matx)[i][j] <<
";" << std::endl;
452 fout <<
"}" << std::endl;
455 fout <<
"//_______________________________________________________________________" << std::endl;
456 fout <<
"inline void " << fcncName <<
"::Transform_"<<trCounter<<
"( std::vector<double>& iv, int cls) const" << std::endl;
457 fout <<
"{" << std::endl;
458 fout <<
" // Decorrelation transformation" << std::endl;
459 fout <<
" if (cls < 0 || cls > "<<
GetNClasses()<<
") {"<< std::endl;
461 fout <<
" else cls = "<<(
fDecorrMatrices.size()==1?0:2)<<
";"<< std::endl;
462 fout <<
" }"<< std::endl;
466 fout <<
" std::vector<double> tv;" << std::endl;
467 fout <<
" for (int i=0; i<"<<matx->
GetNrows()<<
";i++) {" << std::endl;
468 fout <<
" double v = 0;" << std::endl;
469 fout <<
" for (int j=0; j<"<<matx->
GetNcols()<<
"; j++)" << std::endl;
470 fout <<
" v += iv[indicesGet.at(j)] * fDecTF_"<<trCounter<<
"[cls][i][j];" << std::endl;
471 fout <<
" tv.push_back(v);" << std::endl;
472 fout <<
" }" << std::endl;
473 fout <<
" for (int i=0; i<"<<matx->
GetNrows()<<
";i++) iv[indicesPut.at(i)] = tv[i];" << std::endl;
474 fout <<
"}" << std::endl;
477 fout << std::setprecision(dp);
MsgLogger & Endl(MsgLogger &ml)
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
std::vector< std::vector< double > > Data
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
UInt_t GetNVariables() const
accessor to the number of variables
static RooMathCoreReg dummy
Abstract ClassifierFactory template that handles arbitrary types.