67 for (std::vector<TMatrixD*>::iterator it = fDecorrMatrices.begin(); it != fDecorrMatrices.end(); ++it) {
68 if ((*it) != 0)
delete (*it);
86 if (!IsEnabled() || IsCreated())
return kTRUE;
88 Log() << kINFO <<
"Preparing the Decorrelation transformation..." <<
Endl;
90 Int_t inputSize = fGet.size();
91 SetNVariables(inputSize);
93 if (inputSize > 200) {
94 Log() << kINFO <<
"----------------------------------------------------------------------------"
97 <<
": More than 200 variables, will not calculate decorrelation matrix "
99 Log() << kINFO <<
"----------------------------------------------------------------------------"
104 CalcSQRMats(
events, GetNClasses() );
125 Log() << kFATAL <<
"Transformation matrix all classes is not defined"
128 Log() << kFATAL <<
"Transformation matrix for class " <<
whichMatrix <<
" is not defined"
132 const Int_t nvar = fGet.size();
133 std::vector<TString>*
strVec =
new std::vector<TString>;
139 str += ((*m)(
ivar,
jvar) > 0) ?
" + " :
" - ";
155 Log() << kFATAL <<
"VariableDecorrTransform::GetTransformationStrings : unknown type '" <<
type <<
"'." <<
Endl;
170 Log() << kFATAL <<
"Transformation matrix not yet created"
186 Log() << kFATAL <<
"Transformation matrix all classes is not defined"
189 Log() << kFATAL <<
"Transformation matrix for class " <<
whichMatrix <<
" is not defined"
193 if (fTransformedEvent==0 || fTransformedEvent->GetNVariables()!=
ev->GetNVariables()) {
194 if (fTransformedEvent!=0) {
delete fTransformedEvent; fTransformedEvent = 0; }
195 fTransformedEvent =
new Event();
199 const Int_t nvar = fGet.size();
201 std::vector<Float_t>
input;
202 std::vector<Char_t>
mask;
209 Log() << kFATAL <<
"You mixed variables and targets in the decorrelation transformation. This is not possible." <<
Endl;
212 return fTransformedEvent;
226 return fTransformedEvent;
235 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;
238 return fBackTransformedEvent;
247 for (std::vector<TMatrixD*>::iterator it = fDecorrMatrices.begin();
248 it != fDecorrMatrices.end(); ++it)
249 if (0 != (*it) ) {
delete (*it); *it=0; }
262 Log() << kFATAL <<
"<GetSQRMats> Zero pointer returned for SQR matrix" <<
Endl;
264 delete (*covMat)[
cls];
276 for (std::vector<TMatrixD*>::const_iterator
itm = fDecorrMatrices.
begin();
itm != fDecorrMatrices.
end(); ++
itm) {
277 o <<
"# correlation matrix " << std::endl;
279 o <<
cls <<
" " <<
mat->GetNrows() <<
" x " <<
mat->GetNcols() << std::endl;
280 for (
Int_t row = 0; row<
mat->GetNrows(); row++) {
281 for (
Int_t col = 0; col<
mat->GetNcols(); col++) {
282 o << std::setprecision(12) << std::setw(20) << (*mat)[row][col] <<
" ";
288 o <<
"##" << std::endl;
289 o << std::setprecision(
dp);
302 for (std::vector<TMatrixD*>::const_iterator
itm = fDecorrMatrices.
begin();
itm != fDecorrMatrices.
end(); ++
itm) {
325 for( std::vector<TMatrixD*>::iterator it = fDecorrMatrices.begin(); it != fDecorrMatrices.end(); ++it )
326 if( (*it) != 0 )
delete (*it);
327 fDecorrMatrices.clear();
357 s >> (*mat)[row][col];
360 fDecorrMatrices.push_back(
mat);
372 istr.getline(buf,512);
376 while (!(buf[0]==
'#'&& buf[1]==
'#')) {
378 while (*
p==
' ' || *
p==
'\t')
p++;
379 if (*
p==
'#' || *
p==
'\0') {
380 istr.getline(buf,512);
383 std::stringstream
sstr(buf);
392 if (fDecorrMatrices.size() <=
cls ) fDecorrMatrices.resize(
cls+1);
393 if (fDecorrMatrices.at(
cls) != 0)
delete fDecorrMatrices.at(
cls);
396 for (
Int_t row = 0; row<
mat->GetNrows(); row++) {
397 for (
Int_t col = 0; col<
mat->GetNcols(); col++) {
398 istr >> (*mat)[row][col];
402 istr.getline(buf,512);
416 for (std::vector<TMatrixD*>::iterator
itm = fDecorrMatrices.
begin();
itm != fDecorrMatrices.
end(); ++
itm) {
417 Log() << kINFO <<
"Transformation matrix "<<
cls <<
":" <<
Endl;
434 fout <<
" double fDecTF_"<<
trCounter<<
"["<<
numC<<
"]["<<
mat->GetNrows()<<
"]["<<
mat->GetNcols()<<
"];" << std::endl;
439 fout <<
"//_______________________________________________________________________" << std::endl;
441 fout <<
"{" << std::endl;
442 fout <<
" // Decorrelation transformation, initialisation" << std::endl;
445 for (
int i=0; i<
matx->GetNrows(); i++) {
446 for (
int j=0;
j<
matx->GetNcols();
j++) {
447 fout <<
" fDecTF_"<<
trCounter<<
"["<<
icls<<
"]["<<i<<
"]["<<
j<<
"] = " << std::setprecision(12) << (*matx)[i][
j] <<
";" << std::endl;
451 fout <<
"}" << std::endl;
454 fout <<
"//_______________________________________________________________________" << std::endl;
455 fout <<
"inline void " <<
fcncName <<
"::Transform_"<<
trCounter<<
"( std::vector<double>& iv, int cls) const" << std::endl;
456 fout <<
"{" << std::endl;
457 fout <<
" // Decorrelation transformation" << std::endl;
458 fout <<
" if (cls < 0 || cls > "<<GetNClasses()<<
") {"<< std::endl;
459 fout <<
" if ("<<GetNClasses()<<
" > 1 ) cls = "<<GetNClasses()<<
";"<< std::endl;
460 fout <<
" else cls = "<<(fDecorrMatrices.size()==1?0:2)<<
";"<< std::endl;
461 fout <<
" }"<< std::endl;
465 fout <<
" std::vector<double> tv;" << std::endl;
466 fout <<
" for (int i=0; i<"<<
matx->GetNrows()<<
";i++) {" << std::endl;
467 fout <<
" double v = 0;" << std::endl;
468 fout <<
" for (int j=0; j<"<<
matx->GetNcols()<<
"; j++)" << std::endl;
469 fout <<
" v += iv[indicesGet.at(j)] * fDecTF_"<<
trCounter<<
"[cls][i][j];" << std::endl;
470 fout <<
" tv.push_back(v);" << std::endl;
471 fout <<
" }" << std::endl;
472 fout <<
" for (int i=0; i<"<<
matx->GetNrows()<<
";i++) iv[indicesPut.at(i)] = tv[i];" << std::endl;
473 fout <<
"}" << std::endl;
476 fout << std::setprecision(
dp);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TMatrixT< Double_t > TMatrixD
const_iterator begin() const
const_iterator end() const
Class that contains all the data information.
Singleton class for Global types used by TMVA.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
MsgLogger & Endl(MsgLogger &ml)
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.