ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MethodLD.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Krzysztof Danielowski, Kamil Kraszewski, Maciej Kruk, Jan Therhaag
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodLD *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Linear Discriminant - Simple Linear Regression and Classification *
12  * *
13  * Authors (alphabetical): *
14  * Krzysztof Danielowski <danielow@cern.ch> - IFJ PAN & AGH, Poland *
15  * Kamil Kraszewski <kalq@cern.ch> - IFJ PAN & UJ, Poland *
16  * Maciej Kruk <mkruk@cern.ch> - IFJ PAN & AGH, Poland *
17  * Jan Therhaag <therhaag@physik.uni-bonn.de> - Uni Bonn, Germany *
18  * *
19  * Copyright (c) 2005-2011: *
20  * CERN, Switzerland *
21  * PAN, Poland *
22  * U. of Bonn, Germany *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://tmva.sourceforge.net/LICENSE) *
27  * *
28  **********************************************************************************/
29 
30 #include "TMVA/MethodLD.h"
31 
32 #include <iomanip>
33 
34 #include "TMath.h"
35 #include "Riostream.h"
36 #include "TMatrix.h"
37 #include "TMatrixD.h"
38 
39 #include "TMVA/ClassifierFactory.h"
40 #include "TMVA/DataSet.h"
41 #include "TMVA/DataSetInfo.h"
42 #include "TMVA/MsgLogger.h"
43 #include "TMVA/PDF.h"
44 #include "TMVA/Ranking.h"
45 #include "TMVA/Tools.h"
47 #include "TMVA/Types.h"
49 
50 using std::vector;
51 
53 
54 ClassImp(TMVA::MethodLD)
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// standard constructor for the LD
58 
59 TMVA::MethodLD::MethodLD( const TString& jobName,
60  const TString& methodTitle,
61  DataSetInfo& dsi,
62  const TString& theOption,
63  TDirectory* theTargetDir ) :
64  MethodBase( jobName, Types::kLD, methodTitle, dsi, theOption, theTargetDir ),
65  fNRegOut ( 0 ),
66  fSumMatx ( 0 ),
67  fSumValMatx( 0 ),
68  fCoeffMatx ( 0 ),
69  fLDCoeff ( 0 )
70 {
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// constructor from weight file
75 
76 TMVA::MethodLD::MethodLD( DataSetInfo& theData, const TString& theWeightFile, TDirectory* theTargetDir )
77  : MethodBase( Types::kLD, theData, theWeightFile, theTargetDir ),
78  fNRegOut ( 0 ),
79  fSumMatx ( 0 ),
80  fSumValMatx( 0 ),
81  fCoeffMatx ( 0 ),
82  fLDCoeff ( 0 )
83 {
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// default initialization called by all constructors
88 
90 {
91  if(DataInfo().GetNTargets()!=0) fNRegOut = DataInfo().GetNTargets();
92  else fNRegOut = 1;
93 
94  fLDCoeff = new vector< vector< Double_t >* >(fNRegOut);
95  for (Int_t iout = 0; iout<fNRegOut; iout++){
96  (*fLDCoeff)[iout] = new std::vector<Double_t>( GetNvar()+1 );
97  }
98 
99  // the minimum requirement to declare an event signal-like
100  SetSignalReferenceCut( 0.0 );
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// destructor
105 
107 {
108  if (fSumMatx) { delete fSumMatx; fSumMatx = 0; }
109  if (fSumValMatx) { delete fSumValMatx; fSumValMatx = 0; }
110  if (fCoeffMatx) { delete fCoeffMatx; fCoeffMatx = 0; }
111  if (fLDCoeff) {
112  for (vector< vector< Double_t >* >::iterator vi=fLDCoeff->begin(); vi!=fLDCoeff->end(); vi++){
113  if (*vi) { delete *vi; *vi = 0; }
114  }
115  delete fLDCoeff; fLDCoeff = 0;
116  }
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// LD can handle classification with 2 classes and regression with one regression-target
121 
123 {
124  if (type == Types::kClassification && numberClasses == 2) return kTRUE;
125  else if (type == Types::kRegression && numberTargets == 1) {
126  Log() << "regression with " << numberTargets << " targets.";
127  return kTRUE;
128  }
129  else return kFALSE;
130 }
131 
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 /// compute fSumMatx
135 
137 {
138  GetSum();
139 
140  // compute fSumValMatx
141  GetSumVal();
142 
143  // compute fCoeffMatx and fLDCoeff
144  GetLDCoeff();
145 
146  // nice output
147  PrintCoefficients();
148 }
149 
150 ////////////////////////////////////////////////////////////////////////////////
151 ///Returns the MVA classification output
152 
154 {
155  const Event* ev = GetEvent();
156 
157  if (fRegressionReturnVal == NULL) fRegressionReturnVal = new vector< Float_t >();
158  fRegressionReturnVal->resize( fNRegOut );
159 
160  for (Int_t iout = 0; iout<fNRegOut; iout++) {
161  (*fRegressionReturnVal)[iout] = (*(*fLDCoeff)[iout])[0] ;
162 
163  int icoeff=0;
164  for (std::vector<Float_t>::const_iterator it = ev->GetValues().begin();it!=ev->GetValues().end();++it){
165  (*fRegressionReturnVal)[iout] += (*(*fLDCoeff)[iout])[++icoeff] * (*it);
166  }
167  }
168 
169  // cannot determine error
170  NoErrorCalc(err, errUpper);
171 
172  return (*fRegressionReturnVal)[0];
173 }
174 
175 ////////////////////////////////////////////////////////////////////////////////
176 ///Calculates the regression output
177 
178 const std::vector< Float_t >& TMVA::MethodLD::GetRegressionValues()
179 {
180  const Event* ev = GetEvent();
181 
182  if (fRegressionReturnVal == NULL) fRegressionReturnVal = new vector< Float_t >();
183  fRegressionReturnVal->resize( fNRegOut );
184 
185  for (Int_t iout = 0; iout<fNRegOut; iout++) {
186  (*fRegressionReturnVal)[iout] = (*(*fLDCoeff)[iout])[0] ;
187 
188  int icoeff = 0;
189  for (std::vector<Float_t>::const_iterator it = ev->GetValues().begin();it!=ev->GetValues().end();++it){
190  (*fRegressionReturnVal)[iout] += (*(*fLDCoeff)[iout])[++icoeff] * (*it);
191  }
192  }
193 
194  // perform inverse transformation
195  Event* evT = new Event(*ev);
196  for (Int_t iout = 0; iout<fNRegOut; iout++) evT->SetTarget(iout,(*fRegressionReturnVal)[iout]);
197 
198  const Event* evT2 = GetTransformationHandler().InverseTransform( evT );
199  fRegressionReturnVal->clear();
200  for (Int_t iout = 0; iout<fNRegOut; iout++) fRegressionReturnVal->push_back(evT2->GetTarget(iout));
201 
202  delete evT;
203  return (*fRegressionReturnVal);
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// Initializaton method; creates global matrices and vectors
208 
210 {
211  fSumMatx = new TMatrixD( GetNvar()+1, GetNvar()+1 );
212  fSumValMatx = new TMatrixD( GetNvar()+1, fNRegOut );
213  fCoeffMatx = new TMatrixD( GetNvar()+1, fNRegOut );
214 
215 }
216 
217 ////////////////////////////////////////////////////////////////////////////////
218 /// Calculates the matrix transposed(X)*W*X with W being the diagonal weight matrix
219 /// and X the coordinates values
220 
222 {
223  const UInt_t nvar = DataInfo().GetNVariables();
224 
225  for (UInt_t ivar = 0; ivar<=nvar; ivar++){
226  for (UInt_t jvar = 0; jvar<=nvar; jvar++) (*fSumMatx)( ivar, jvar ) = 0;
227  }
228 
229  // compute sample means
230  Long64_t nevts = Data()->GetNEvents();
231  for (Int_t ievt=0; ievt<nevts; ievt++) {
232  const Event * ev = GetEvent(ievt);
233  Double_t weight = ev->GetWeight();
234 
235  if (IgnoreEventsWithNegWeightsInTraining() && weight <= 0) continue;
236 
237  // Sum of weights
238  (*fSumMatx)( 0, 0 ) += weight;
239 
240  // Sum of coordinates
241  for (UInt_t ivar=0; ivar<nvar; ivar++) {
242  (*fSumMatx)( ivar+1, 0 ) += ev->GetValue( ivar ) * weight;
243  (*fSumMatx)( 0, ivar+1 ) += ev->GetValue( ivar ) * weight;
244  }
245 
246  // Sum of products of coordinates
247  for (UInt_t ivar=0; ivar<nvar; ivar++){
248  for (UInt_t jvar=0; jvar<nvar; jvar++){
249  (*fSumMatx)( ivar+1, jvar+1 ) += ev->GetValue( ivar ) * ev->GetValue( jvar ) * weight;
250  }
251  }
252  }
253 }
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 ///Calculates the vector transposed(X)*W*Y with Y being the target vector
257 
259 {
260  const UInt_t nvar = DataInfo().GetNVariables();
261 
262  for (Int_t ivar = 0; ivar<fNRegOut; ivar++){
263  for (UInt_t jvar = 0; jvar<=nvar; jvar++){
264  (*fSumValMatx)(jvar,ivar) = 0;
265  }
266  }
267 
268  // Sum of coordinates multiplied by values
269  for (Int_t ievt=0; ievt<Data()->GetNEvents(); ievt++) {
270 
271  // retrieve the event
272  const Event* ev = GetEvent(ievt);
273  Double_t weight = ev->GetWeight();
274 
275  // in case event with neg weights are to be ignored
276  if (IgnoreEventsWithNegWeightsInTraining() && weight <= 0) continue;
277 
278  for (Int_t ivar=0; ivar<fNRegOut; ivar++) {
279 
280  Double_t val = weight;
281 
282  if (!DoRegression()){
283  val *= DataInfo().IsSignal(ev); // yes it works.. but I'm still surprised (Helge).. would have not set y_B to zero though..
284  }else {//for regression
285  val *= ev->GetTarget( ivar );
286  }
287  (*fSumValMatx)( 0,ivar ) += val;
288  for (UInt_t jvar=0; jvar<nvar; jvar++) {
289  (*fSumValMatx)(jvar+1,ivar ) += ev->GetValue(jvar) * val;
290  }
291  }
292  }
293 }
294 
295 ////////////////////////////////////////////////////////////////////////////////
296 ///Calculates the coeffiecients used for classification/regression
297 
299 {
300  const UInt_t nvar = DataInfo().GetNVariables();
301 
302  for (Int_t ivar = 0; ivar<fNRegOut; ivar++){
303  TMatrixD invSum( *fSumMatx );
304  if ( TMath::Abs(invSum.Determinant()) < 10E-24 ) {
305  Log() << kWARNING << "<GetCoeff> matrix is almost singular with determinant="
306  << TMath::Abs(invSum.Determinant())
307  << " did you use the variables that are linear combinations or highly correlated?"
308  << Endl;
309  }
310  if ( TMath::Abs(invSum.Determinant()) < 10E-120 ) {
311  Log() << kFATAL << "<GetCoeff> matrix is singular with determinant="
312  << TMath::Abs(invSum.Determinant())
313  << " did you use the variables that are linear combinations?"
314  << Endl;
315  }
316  invSum.Invert();
317 
318  fCoeffMatx = new TMatrixD( invSum * (*fSumValMatx));
319  for (UInt_t jvar = 0; jvar<nvar+1; jvar++) {
320  (*(*fLDCoeff)[ivar])[jvar] = (*fCoeffMatx)(jvar, ivar );
321  }
322  if (!DoRegression()) {
323  (*(*fLDCoeff)[ivar])[0]=0.0;
324  for (UInt_t jvar = 1; jvar<nvar+1; jvar++){
325  (*(*fLDCoeff)[ivar])[0]+=(*fCoeffMatx)(jvar,ivar)*(*fSumMatx)(0,jvar)/(*fSumMatx)( 0, 0 );
326  }
327  (*(*fLDCoeff)[ivar])[0]/=-2.0;
328  }
329 
330  }
331 }
332 
333 ////////////////////////////////////////////////////////////////////////////////
334 /// read LD coefficients from weight file
335 
336 void TMVA::MethodLD::ReadWeightsFromStream( std::istream& istr )
337 {
338  for (Int_t iout=0; iout<fNRegOut; iout++){
339  for (UInt_t icoeff=0; icoeff<GetNvar()+1; icoeff++){
340  istr >> (*(*fLDCoeff)[iout])[icoeff];
341  }
342  }
343 }
344 
345 ////////////////////////////////////////////////////////////////////////////////
346 /// create XML description for LD classification and regression
347 /// (for arbitrary number of output classes/targets)
348 
349 void TMVA::MethodLD::AddWeightsXMLTo( void* parent ) const
350 {
351  void* wght = gTools().AddChild(parent, "Weights");
352  gTools().AddAttr( wght, "NOut", fNRegOut );
353  gTools().AddAttr( wght, "NCoeff", GetNvar()+1 );
354  for (Int_t iout=0; iout<fNRegOut; iout++) {
355  for (UInt_t icoeff=0; icoeff<GetNvar()+1; icoeff++) {
356  void* coeffxml = gTools().AddChild( wght, "Coefficient" );
357  gTools().AddAttr( coeffxml, "IndexOut", iout );
358  gTools().AddAttr( coeffxml, "IndexCoeff", icoeff );
359  gTools().AddAttr( coeffxml, "Value", (*(*fLDCoeff)[iout])[icoeff] );
360  }
361  }
362 }
363 
364 ////////////////////////////////////////////////////////////////////////////////
365 /// read coefficients from xml weight file
366 
367 void TMVA::MethodLD::ReadWeightsFromXML( void* wghtnode )
368 {
369  UInt_t ncoeff;
370  gTools().ReadAttr( wghtnode, "NOut", fNRegOut );
371  gTools().ReadAttr( wghtnode, "NCoeff", ncoeff );
372 
373  // sanity checks
374  if (ncoeff != GetNvar()+1) Log() << kFATAL << "Mismatch in number of output variables/coefficients: "
375  << ncoeff << " != " << GetNvar()+1 << Endl;
376 
377  // create vector with coefficients (double vector due to arbitrary output dimension)
378  if (fLDCoeff) {
379  for (vector< vector< Double_t >* >::iterator vi=fLDCoeff->begin(); vi!=fLDCoeff->end(); vi++){
380  if (*vi) { delete *vi; *vi = 0; }
381  }
382  delete fLDCoeff; fLDCoeff = 0;
383  }
384  fLDCoeff = new vector< vector< Double_t >* >(fNRegOut);
385  for (Int_t ivar = 0; ivar<fNRegOut; ivar++) (*fLDCoeff)[ivar] = new std::vector<Double_t>( ncoeff );
386 
387  void* ch = gTools().GetChild(wghtnode);
388  Double_t coeff;
389  Int_t iout, icoeff;
390  while (ch) {
391  gTools().ReadAttr( ch, "IndexOut", iout );
392  gTools().ReadAttr( ch, "IndexCoeff", icoeff );
393  gTools().ReadAttr( ch, "Value", coeff );
394 
395  (*(*fLDCoeff)[iout])[icoeff] = coeff;
396 
397  ch = gTools().GetNextChild(ch);
398  }
399 }
400 
401 ////////////////////////////////////////////////////////////////////////////////
402 /// write LD-specific classifier response
403 
404 void TMVA::MethodLD::MakeClassSpecific( std::ostream& fout, const TString& className ) const
405 {
406  fout << " std::vector<double> fLDCoefficients;" << std::endl;
407  fout << "};" << std::endl;
408  fout << "" << std::endl;
409  fout << "inline void " << className << "::Initialize() " << std::endl;
410  fout << "{" << std::endl;
411  for (UInt_t ivar=0; ivar<GetNvar()+1; ivar++) {
412  Int_t dp = fout.precision();
413  fout << " fLDCoefficients.push_back( "
414  << std::setprecision(12) << (*(*fLDCoeff)[0])[ivar]
415  << std::setprecision(dp) << " );" << std::endl;
416  }
417  fout << std::endl;
418  fout << " // sanity check" << std::endl;
419  fout << " if (fLDCoefficients.size() != fNvars+1) {" << std::endl;
420  fout << " std::cout << \"Problem in class \\\"\" << fClassName << \"\\\"::Initialize: mismatch in number of input values\"" << std::endl;
421  fout << " << fLDCoefficients.size() << \" != \" << fNvars+1 << std::endl;" << std::endl;
422  fout << " fStatusIsClean = false;" << std::endl;
423  fout << " } " << std::endl;
424  fout << "}" << std::endl;
425  fout << std::endl;
426  fout << "inline double " << className << "::GetMvaValue__( const std::vector<double>& inputValues ) const" << std::endl;
427  fout << "{" << std::endl;
428  fout << " double retval = fLDCoefficients[0];" << std::endl;
429  fout << " for (size_t ivar = 1; ivar < fNvars+1; ivar++) {" << std::endl;
430  fout << " retval += fLDCoefficients[ivar]*inputValues[ivar-1];" << std::endl;
431  fout << " }" << std::endl;
432  fout << std::endl;
433  fout << " return retval;" << std::endl;
434  fout << "}" << std::endl;
435  fout << std::endl;
436  fout << "// Clean up" << std::endl;
437  fout << "inline void " << className << "::Clear() " << std::endl;
438  fout << "{" << std::endl;
439  fout << " // clear coefficients" << std::endl;
440  fout << " fLDCoefficients.clear(); " << std::endl;
441  fout << "}" << std::endl;
442 }
443 ////////////////////////////////////////////////////////////////////////////////
444 /// computes ranking of input variables
445 
447 {
448  // create the ranking object
449  fRanking = new Ranking( GetName(), "Discr. power" );
450 
451  for (UInt_t ivar=0; ivar<GetNvar(); ivar++) {
452  fRanking->AddRank( Rank( GetInputLabel(ivar), TMath::Abs((* (*fLDCoeff)[0])[ivar+1] )) );
453  }
454 
455  return fRanking;
456 }
457 
458 ////////////////////////////////////////////////////////////////////////////////
459 ///MethodLD options
460 
462 {
463  AddPreDefVal(TString("LD"));
464 }
465 
466 ////////////////////////////////////////////////////////////////////////////////
467 /// this is the preparation for training
468 
470 {
471  if (HasTrainingTree()) InitMatrices();
472 }
473 
474 ////////////////////////////////////////////////////////////////////////////////
475 ///Display the classification/regression coefficients for each variable
476 
478 {
479  Log() << kINFO << "Results for LD coefficients:" << Endl;
480 
481  if (GetTransformationHandler().GetTransformationList().GetSize() != 0) {
482  Log() << kINFO << "NOTE: The coefficients must be applied to TRANFORMED variables" << Endl;
483  Log() << kINFO << " List of the transformation: " << Endl;
484  TListIter trIt(&GetTransformationHandler().GetTransformationList());
485  while (VariableTransformBase *trf = (VariableTransformBase*) trIt() ) {
486  Log() << kINFO << " -- " << trf->GetName() << Endl;
487  }
488  }
489  std::vector<TString> vars;
490  std::vector<Double_t> coeffs;
491  for (UInt_t ivar=0; ivar<GetNvar(); ivar++) {
492  vars .push_back( GetInputLabel(ivar) );
493  coeffs.push_back( (* (*fLDCoeff)[0])[ivar+1] );
494  }
495  vars .push_back( "(offset)" );
496  coeffs.push_back((* (*fLDCoeff)[0])[0] );
497  TMVA::gTools().FormattedOutput( coeffs, vars, "Variable" , "Coefficient", Log() );
498  if (IsNormalised()) {
499  Log() << kINFO << "NOTE: You have chosen to use the \"Normalise\" booking option. Hence, the" << Endl;
500  Log() << kINFO << " coefficients must be applied to NORMALISED (') variables as follows:" << Endl;
501  Int_t maxL = 0;
502  for (UInt_t ivar=0; ivar<GetNvar(); ivar++) if (GetInputLabel(ivar).Length() > maxL) maxL = GetInputLabel(ivar).Length();
503 
504  // Print normalisation expression (see Tools.cxx): "2*(x - xmin)/(xmax - xmin) - 1.0"
505  for (UInt_t ivar=0; ivar<GetNvar(); ivar++) {
506  Log() << kINFO
507  << std::setw(maxL+9) << TString("[") + GetInputLabel(ivar) + "]' = 2*("
508  << std::setw(maxL+2) << TString("[") + GetInputLabel(ivar) + "]"
509  << std::setw(3) << (GetXmin(ivar) > 0 ? " - " : " + ")
510  << std::setw(6) << TMath::Abs(GetXmin(ivar)) << std::setw(3) << ")/"
511  << std::setw(6) << (GetXmax(ivar) - GetXmin(ivar) )
512  << std::setw(3) << " - 1"
513  << Endl;
514  }
515  Log() << kINFO << "The TMVA Reader will properly account for this normalisation, but if the" << Endl;
516  Log() << kINFO << "LD classifier is applied outside the Reader, the transformation must be" << Endl;
517  Log() << kINFO << "implemented -- or the \"Normalise\" option is removed and LD retrained." << Endl;
518  Log() << kINFO << Endl;
519  }
520 }
521 
522 ////////////////////////////////////////////////////////////////////////////////
523 /// get help message text
524 ///
525 /// typical length of text line:
526 /// "|--------------------------------------------------------------|"
527 
529 {
530  Log() << Endl;
531  Log() << gTools().Color("bold") << "--- Short description:" << gTools().Color("reset") << Endl;
532  Log() << Endl;
533  Log() << "Linear discriminants select events by distinguishing the mean " << Endl;
534  Log() << "values of the signal and background distributions in a trans- " << Endl;
535  Log() << "formed variable space where linear correlations are removed." << Endl;
536  Log() << "The LD implementation here is equivalent to the \"Fisher\" discriminant" << Endl;
537  Log() << "for classification, but also provides linear regression." << Endl;
538  Log() << Endl;
539  Log() << " (More precisely: the \"linear discriminator\" determines" << Endl;
540  Log() << " an axis in the (correlated) hyperspace of the input " << Endl;
541  Log() << " variables such that, when projecting the output classes " << Endl;
542  Log() << " (signal and background) upon this axis, they are pushed " << Endl;
543  Log() << " as far as possible away from each other, while events" << Endl;
544  Log() << " of a same class are confined in a close vicinity. The " << Endl;
545  Log() << " linearity property of this classifier is reflected in the " << Endl;
546  Log() << " metric with which \"far apart\" and \"close vicinity\" are " << Endl;
547  Log() << " determined: the covariance matrix of the discriminating" << Endl;
548  Log() << " variable space.)" << Endl;
549  Log() << Endl;
550  Log() << gTools().Color("bold") << "--- Performance optimisation:" << gTools().Color("reset") << Endl;
551  Log() << Endl;
552  Log() << "Optimal performance for the linear discriminant is obtained for " << Endl;
553  Log() << "linearly correlated Gaussian-distributed variables. Any deviation" << Endl;
554  Log() << "from this ideal reduces the achievable separation power. In " << Endl;
555  Log() << "particular, no discrimination at all is achieved for a variable" << Endl;
556  Log() << "that has the same sample mean for signal and background, even if " << Endl;
557  Log() << "the shapes of the distributions are very different. Thus, the linear " << Endl;
558  Log() << "discriminant often benefits from a suitable transformation of the " << Endl;
559  Log() << "input variables. For example, if a variable x in [-1,1] has a " << Endl;
560  Log() << "a parabolic signal distributions, and a uniform background" << Endl;
561  Log() << "distributions, their mean value is zero in both cases, leading " << Endl;
562  Log() << "to no separation. The simple transformation x -> |x| renders this " << Endl;
563  Log() << "variable powerful for the use in a linear discriminant." << Endl;
564  Log() << Endl;
565  Log() << gTools().Color("bold") << "--- Performance tuning via configuration options:" << gTools().Color("reset") << Endl;
566  Log() << Endl;
567  Log() << "<None>" << Endl;
568 }
virtual const std::vector< Float_t > & GetRegressionValues()
Calculates the regression output.
Definition: MethodLD.cxx:178
const Ranking * CreateRanking()
computes ranking of input variables
Definition: MethodLD.cxx:446
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:162
long long Long64_t
Definition: RtypesCore.h:69
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
LD can handle classification with 2 classes and regression with one regression-target.
Definition: MethodLD.cxx:122
void GetSumVal(void)
Calculates the vector transposed(X)*W*Y with Y being the target vector.
Definition: MethodLD.cxx:258
EAnalysisType
Definition: Types.h:124
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void SetTarget(UInt_t itgt, Float_t value)
set the target value (dimension itgt) to value
Definition: Event.cxx:354
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not...
Definition: Event.cxx:376
virtual ~MethodLD(void)
destructor
Definition: MethodLD.cxx:106
void PrintCoefficients(void)
Display the classification/regression coefficients for each variable.
Definition: MethodLD.cxx:477
void AddAttr(void *node, const char *, const T &value, Int_t precision=16)
Definition: Tools.h:308
void * AddChild(void *parent, const char *childname, const char *content=0, bool isRootNode=false)
add child node
Definition: Tools.cxx:1134
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
Iterator of linked list.
Definition: TList.h:187
void ReadWeightsFromXML(void *wghtnode)
read coefficients from xml weight file
Definition: MethodLD.cxx:367
Tools & gTools()
Definition: Tools.cxx:79
ClassImp(TMVA::MethodLD) TMVA
standard constructor for the LD
Definition: MethodLD.cxx:54
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
Returns the MVA classification output.
Definition: MethodLD.cxx:153
void * GetChild(void *parent, const char *childname=0)
get child node
Definition: Tools.cxx:1158
std::vector< std::vector< double > > Data
MethodLD(const TString &jobName, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="LD", TDirectory *theTargetDir=0)
void MakeClassSpecific(std::ostream &, const TString &) const
write LD-specific classifier response
Definition: MethodLD.cxx:404
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
Definition: TMatrixT.cxx:1388
TMatrixT< Double_t > TMatrixD
Definition: TMatrixDfwd.h:24
void ReadWeightsFromStream(std::istream &i)
read LD coefficients from weight file
Definition: MethodLD.cxx:336
void AddWeightsXMLTo(void *parent) const
create XML description for LD classification and regression (for arbitrary number of output classes/t...
Definition: MethodLD.cxx:349
unsigned int UInt_t
Definition: RtypesCore.h:42
Double_t E()
Definition: TMath.h:54
void ReadAttr(void *node, const char *, T &value)
Definition: Tools.h:295
void DeclareOptions()
MethodLD options.
Definition: MethodLD.cxx:461
double Double_t
Definition: RtypesCore.h:55
Describe directory structure in memory.
Definition: TDirectory.h:44
int type
Definition: TGX11.cxx:120
void * GetNextChild(void *prevchild, const char *childname=0)
XML helpers.
Definition: Tools.cxx:1170
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Definition: Event.cxx:231
void FormattedOutput(const std::vector< Double_t > &, const std::vector< TString > &, const TString titleVars, const TString titleValues, MsgLogger &logger, TString format="%+1.3f")
formatted output of simple table
Definition: Tools.cxx:896
const TString & Color(const TString &)
human readable color strings
Definition: Tools.cxx:837
void GetSum(void)
Calculates the matrix transposed(X)*W*X with W being the diagonal weight matrix and X the coordinates...
Definition: MethodLD.cxx:221
Float_t GetTarget(UInt_t itgt) const
Definition: Event.h:101
#define REGISTER_METHOD(CLASS)
for example
std::vector< Float_t > & GetValues()
Definition: Event.h:93
void GetLDCoeff(void)
Calculates the coeffiecients used for classification/regression.
Definition: MethodLD.cxx:298
#define NULL
Definition: Rtypes.h:82
virtual Double_t Determinant() const
Return the matrix determinant.
Definition: TMatrixT.cxx:1353
void Train(void)
compute fSumMatx
Definition: MethodLD.cxx:136
void InitMatrices(void)
Initializaton method; creates global matrices and vectors.
Definition: MethodLD.cxx:209
void Init(void)
default initialization called by all constructors
Definition: MethodLD.cxx:89
const Bool_t kTRUE
Definition: Rtypes.h:91
void GetHelpMessage() const
get help message text
Definition: MethodLD.cxx:528
Definition: math.cpp:60
void ProcessOptions()
this is the preparation for training
Definition: MethodLD.cxx:469