76 UInt_t inputSize = fGet.size();
78 if (GetNClasses() <= 1 )
numC = 1;
83 fMin.at(i).resize(inputSize);
84 fMax.at(i).resize(inputSize);
85 fMin.at(i).assign(inputSize, 0);
86 fMax.at(i).assign(inputSize, 0);
95 if (!IsEnabled() || IsCreated())
return kTRUE;
97 Log() << kDEBUG <<
"\tPreparing the transformation." <<
Endl;
101 CalcNormalizationParams( events );
113 if (!IsCreated()) Log() << kFATAL <<
"Transformation not yet created" <<
Endl;
127 std::vector<Char_t>
mask;
130 if (fTransformedEvent==0) fTransformedEvent =
new Event();
137 std::vector<Char_t>::iterator
itMask =
mask.begin();
157 fabs(max)>fabs(min) ?
valnorm=val/fabs(max) :
valnorm=val/fabs(min);
167 return fTransformedEvent;
175 if (!IsCreated()) Log() << kFATAL <<
"Transformation not yet created" <<
Endl;
180 if (GetNClasses() > 1 )
cls = GetNClasses();
186 std::vector<Char_t>
mask;
189 if (fBackTransformedEvent==0) fBackTransformedEvent =
new Event( *
ev );
208 fabs(max)>fabs(min) ?
valnorm=val*fabs(max) :
valnorm=val*fabs(min);
218 return fBackTransformedEvent;
226 if (events.size() <= 1)
227 Log() << kFATAL <<
"Not enough events (found " << events.size() <<
") to calculate the normalization" <<
Endl;
230 std::vector<Char_t>
mask;
232 UInt_t inputSize = fGet.size();
249 std::vector<Event*>::const_iterator
evIt = events.begin();
292 std::vector<TString>*
strVec =
new std::vector<TString>(
size);
300 UInt_t idx = (*itGet).second;
305 scale = 1.0/(max-min);
308 fabs(max)>fabs(min) ?
scale=.5/fabs(max) :
scale=.5/fabs(min);
315 (*strVec)[
iinp] = str;
328 o <<
"# min max for all variables for all classes one after the other and as a last entry for all classes together" << std::endl;
331 if (GetNClasses() <= 1 )
numC = 1;
333 UInt_t nvars = GetNVariables();
337 o <<
icls << std::endl;
339 o << std::setprecision(12) << std::setw(20) << fMin.at(
icls).at(
ivar) <<
" "
340 << std::setprecision(12) << std::setw(20) << fMax.at(
icls).at(
ivar) << std::endl;
342 o << std::setprecision(12) << std::setw(20) << fMin.at(
icls).at(nvars+
itgt) <<
" "
343 << std::setprecision(12) << std::setw(20) << fMax.at(
icls).at(nvars+
itgt) << std::endl;
345 o <<
"##" << std::endl;
358 Int_t numC = (GetNClasses()<= 1)?1:GetNClasses()+1;
446 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
ivar));
449 fGet.push_back(std::pair<Char_t,UInt_t>(
't',
itgt));
494 UInt_t nvars = GetNVariables();
496 if(var.size() != nvars)
497 Log() << kFATAL <<
"<BuildTransformationFromVarInfo> can't build transformation,"
498 <<
" since the number of variables disagree" <<
Endl;
500 UInt_t numC = (GetNClasses()<=1)?1:GetNClasses()+1;
501 fMin.clear();fMin.resize(
numC );
502 fMax.clear();fMax.resize(
numC );
506 fMin[
cls].resize(nvars+GetNTargets(),0);
507 fMax[
cls].resize(nvars+GetNTargets(),0);
509 for(std::vector<TMVA::VariableInfo>::const_iterator
v = var.begin();
v!=var.end(); ++
v, ++
vidx) {
512 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
vidx));
523 UInt_t nvars = GetNVariables();
526 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
ivar));
529 fGet.push_back(std::pair<Char_t,UInt_t>(
't',
itgt));
533 istr.getline(buf,512);
537 while (!(buf[0]==
'#'&& buf[1]==
'#')) {
539 while (*
p==
' ' || *
p==
'\t')
p++;
540 if (*
p==
'#' || *
p==
'\0') {
541 istr.getline(buf,512);
544 std::stringstream
sstr(buf);
556 istr.getline(buf,512);
571 Log() << kINFO <<
"Transformation for all classes based on these ranges:" <<
Endl;
573 Log() << kINFO <<
"Transformation for class " <<
icls <<
" based on these ranges:" <<
Endl;
576 UInt_t idx = (*itGet).second;
579 Log() <<
typeString.Data() << std::setw(20) << fMin[
icls][idx] << std::setw(20) << fMax[
icls][idx] <<
Endl;
602 fout <<
"//_______________________________________________________________________" << std::endl;
604 fout <<
"{" << std::endl;
607 fout <<
" // Normalization transformation, initialisation" << std::endl;
612 fout <<
" fMin_" <<
trCounter <<
"[" <<
icls <<
"][" <<
ivar <<
"] = " << std::setprecision(12) << min
614 fout <<
" fMax_" <<
trCounter <<
"[" <<
icls <<
"][" <<
ivar <<
"] = " << std::setprecision(12) << max
622 fout <<
"}" << std::endl;
624 fout <<
"//_______________________________________________________________________" << std::endl;
625 fout <<
"inline void " <<
fcncName <<
"::Transform_" <<
trCounter <<
"( std::vector<double>& iv, int cls) const"
627 fout <<
"{" << std::endl;
628 fout <<
" // Normalization transformation" << std::endl;
629 fout <<
" if (cls < 0 || cls > " << GetNClasses() <<
") {" << std::endl;
630 fout <<
" if (" << GetNClasses() <<
" > 1 ) cls = " << GetNClasses() <<
";" << std::endl;
631 fout <<
" else cls = " << (fMin.size() == 1 ? 0 : 2) <<
";" << std::endl;
632 fout <<
" }" << std::endl;
633 fout <<
" const int nVar = " <<
nVar <<
";" << std::endl << std::endl;
634 fout <<
" // get indices of used variables" << std::endl;
636 fout <<
" static std::vector<double> dv;"
638 fout <<
" dv.resize(nVar);" << std::endl;
639 fout <<
" for (int ivar=0; ivar<nVar; ivar++) dv[ivar] = iv[indicesGet.at(ivar)];" << std::endl;
641 fout <<
" for (int ivar=0;ivar<" <<
nVar <<
";ivar++) {" << std::endl;
642 fout <<
" double offset = fOff_" <<
trCounter <<
"[cls][ivar];" << std::endl;
643 fout <<
" double scale = fScal_" <<
trCounter <<
"[cls][ivar];" << std::endl;
644 fout <<
" iv[indicesPut.at(ivar)] = scale*dv[ivar]-offset;" << std::endl;
645 fout <<
" }" << std::endl;
646 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.