72 UInt_t inputSize = fGet.size();
74 if (GetNClasses() <= 1 )
numC = 1;
79 fMin.at(i).resize(inputSize);
80 fMax.at(i).resize(inputSize);
81 fMin.at(i).assign(inputSize, 0);
82 fMax.at(i).assign(inputSize, 0);
91 if (!IsEnabled() || IsCreated())
return kTRUE;
93 Log() << kDEBUG <<
"\tPreparing the transformation." <<
Endl;
97 CalcNormalizationParams( events );
109 if (!IsCreated()) Log() << kFATAL <<
"Transformation not yet created" <<
Endl;
123 std::vector<Char_t>
mask;
126 if (fTransformedEvent==0) fTransformedEvent =
new Event();
133 std::vector<Char_t>::iterator
itMask =
mask.begin();
157 return fTransformedEvent;
165 if (!IsCreated()) Log() << kFATAL <<
"Transformation not yet created" <<
Endl;
170 if (GetNClasses() > 1 )
cls = GetNClasses();
176 std::vector<Char_t>
mask;
179 if (fBackTransformedEvent==0) fBackTransformedEvent =
new Event( *
ev );
202 return fBackTransformedEvent;
210 if (events.size() <= 1)
211 Log() << kFATAL <<
"Not enough events (found " << events.size() <<
") to calculate the normalization" <<
Endl;
214 std::vector<Char_t>
mask;
216 UInt_t inputSize = fGet.size();
233 std::vector<Event*>::const_iterator
evIt = events.begin();
276 std::vector<TString>*
strVec =
new std::vector<TString>(
size);
284 UInt_t idx = (*itGet).second;
292 (*strVec)[
iinp] = str;
305 o <<
"# min max for all variables for all classes one after the other and as a last entry for all classes together" << std::endl;
308 if (GetNClasses() <= 1 )
numC = 1;
310 UInt_t nvars = GetNVariables();
314 o <<
icls << std::endl;
316 o << std::setprecision(12) << std::setw(20) << fMin.at(
icls).at(
ivar) <<
" "
317 << std::setprecision(12) << std::setw(20) << fMax.at(
icls).at(
ivar) << std::endl;
319 o << std::setprecision(12) << std::setw(20) << fMin.at(
icls).at(nvars+
itgt) <<
" "
320 << std::setprecision(12) << std::setw(20) << fMax.at(
icls).at(nvars+
itgt) << std::endl;
322 o <<
"##" << std::endl;
334 Int_t numC = (GetNClasses()<= 1)?1:GetNClasses()+1;
415 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
ivar));
418 fGet.push_back(std::pair<Char_t,UInt_t>(
't',
itgt));
463 UInt_t nvars = GetNVariables();
465 if(var.size() != nvars)
466 Log() << kFATAL <<
"<BuildTransformationFromVarInfo> can't build transformation,"
467 <<
" since the number of variables disagree" <<
Endl;
469 UInt_t numC = (GetNClasses()<=1)?1:GetNClasses()+1;
470 fMin.clear();fMin.resize(
numC );
471 fMax.clear();fMax.resize(
numC );
475 fMin[
cls].resize(nvars+GetNTargets(),0);
476 fMax[
cls].resize(nvars+GetNTargets(),0);
478 for(std::vector<TMVA::VariableInfo>::const_iterator
v = var.begin();
v!=var.end(); ++
v, ++
vidx) {
481 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
vidx));
492 UInt_t nvars = GetNVariables();
495 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
ivar));
498 fGet.push_back(std::pair<Char_t,UInt_t>(
't',
itgt));
502 istr.getline(buf,512);
506 while (!(buf[0]==
'#'&& buf[1]==
'#')) {
508 while (*
p==
' ' || *
p==
'\t')
p++;
509 if (*
p==
'#' || *
p==
'\0') {
510 istr.getline(buf,512);
513 std::stringstream
sstr(buf);
525 istr.getline(buf,512);
540 Log() << kINFO <<
"Transformation for all classes based on these ranges:" <<
Endl;
542 Log() << kINFO <<
"Transformation for class " <<
icls <<
" based on these ranges:" <<
Endl;
545 UInt_t idx = (*itGet).second;
548 Log() <<
typeString.Data() << std::setw(20) << fMin[
icls][idx] << std::setw(20) << fMax[
icls][idx] <<
Endl;
571 fout <<
"//_______________________________________________________________________" << std::endl;
573 fout <<
"{" << std::endl;
576 fout <<
" // Normalization transformation, initialisation" << std::endl;
581 fout <<
" fMin_" <<
trCounter <<
"[" <<
icls <<
"][" <<
ivar <<
"] = " << std::setprecision(12) << min
583 fout <<
" fMax_" <<
trCounter <<
"[" <<
icls <<
"][" <<
ivar <<
"] = " << std::setprecision(12) << max
591 fout <<
"}" << std::endl;
593 fout <<
"//_______________________________________________________________________" << std::endl;
594 fout <<
"inline void " <<
fcncName <<
"::Transform_" <<
trCounter <<
"( std::vector<double>& iv, int cls) const"
596 fout <<
"{" << std::endl;
597 fout <<
" // Normalization transformation" << std::endl;
598 fout <<
" if (cls < 0 || cls > " << GetNClasses() <<
") {" << std::endl;
599 fout <<
" if (" << GetNClasses() <<
" > 1 ) cls = " << GetNClasses() <<
";" << std::endl;
600 fout <<
" else cls = " << (fMin.size() == 1 ? 0 : 2) <<
";" << std::endl;
601 fout <<
" }" << std::endl;
602 fout <<
" const int nVar = " <<
nVar <<
";" << std::endl << std::endl;
603 fout <<
" // get indices of used variables" << std::endl;
605 fout <<
" static std::vector<double> dv;"
607 fout <<
" dv.resize(nVar);" << std::endl;
608 fout <<
" for (int ivar=0; ivar<nVar; ivar++) dv[ivar] = iv[indicesGet.at(ivar)];" << std::endl;
610 fout <<
" for (int ivar=0;ivar<" <<
nVar <<
";ivar++) {" << std::endl;
611 fout <<
" double offset = fOff_" <<
trCounter <<
"[cls][ivar];" << std::endl;
612 fout <<
" double scale = fScal_" <<
trCounter <<
"[cls][ivar];" << std::endl;
613 fout <<
" iv[indicesPut.at(ivar)] = scale*dv[ivar]-offset;" << std::endl;
614 fout <<
" }" << std::endl;
615 fout <<
"}" << std::endl;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char Char_t
Character 1 byte (char)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
float Float_t
Float 4 bytes (float)
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 offset
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
const_iterator begin() const
const_iterator end() const
Class that contains all the data information.
Singleton class for Global types used by TMVA.
Class for type info of MVA input variable.
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 Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.