# class TMVA::MethodLikelihood: public TMVA::MethodBase

```
```
Likelihood analysis ("non-parametric approach")

Also implemented is a "diagonalized likelihood approach", which improves over the uncorrelated likelihood ansatz by transforming linearly the input variables into a diagonal space, using the square-root of the covariance matrix

The method of maximum likelihood is the most straightforward, and certainly among the most elegant multivariate analyser approaches. We define the likelihood ratio, RL, for event i, by:

Here the signal and background likelihoods, LS, LB, are products of the corresponding probability densities, pS, pB, of the Nvar discriminating variables used in the MVA:
and accordingly for LB. In practise, TMVA uses polynomial splines to estimate the probability density functions (PDF) obtained from the distributions of the training variables.

Note that in TMVA the output of the likelihood ratio is transformed by

to avoid the occurrence of heavy peaks at RL=0,1. Decorrelated (or "diagonalized") Likelihood

The biggest drawback of the Likelihood approach is that it assumes that the discriminant variables are uncorrelated. If it were the case, it can be proven that the discrimination obtained by the above likelihood ratio is optimal, ie, no other method can beat it. However, in most practical applications of MVAs correlations are present.

Linear correlations, measured from the training sample, can be taken into account in a straightforward manner through the square-root of the covariance matrix. The square-root of a matrix C is the matrix C′ that multiplied with itself yields C: C=C′C′. We compute the square-root matrix (SQM) by means of diagonalising (D) the covariance matrix:

and the linear transformation of the linearly correlated into the uncorrelated variables space is then given by multiplying the measured variable tuple by the inverse of the SQM. Note that these transformations are performed for both signal and background separately, since the correlation pattern is not the same in the two samples.

The above diagonalisation is complete for linearly correlated, Gaussian distributed variables only. In real-world examples this is not often the case, so that only little additional information may be recovered by the diagonalisation procedure. In these cases, non-linear methods must be applied.

```

```

## Function Members (Methods)

public:
protected:
 virtual void DeclareCompatibilityOptions() virtual void TObject::DoError(int level, const char* location, const char* fmt, va_list va) const void TMVA::Configurable::EnableLooseOptions(Bool_t b = kTRUE) virtual void GetHelpMessage() const const TString& TMVA::MethodBase::GetInternalVarName(Int_t ivar) const const TString& TMVA::MethodBase::GetOriginalVarName(Int_t ivar) const const TString& TMVA::Configurable::GetReferenceFile() const static TMVA::MethodBase* TMVA::MethodBase::GetThisBase() Float_t TMVA::MethodBase::GetTWeight(const TMVA::Event* ev) const const TString& TMVA::MethodBase::GetWeightFileDir() const Bool_t TMVA::MethodBase::HasTrainingTree() const Bool_t TMVA::MethodBase::Help() const Bool_t TMVA::MethodBase::IgnoreEventsWithNegWeightsInTraining() const Bool_t TMVA::MethodBase::IsConstructedFromWeightFile() const Bool_t TMVA::MethodBase::IsNormalised() const TMVA::MsgLogger& TMVA::Configurable::Log() const Bool_t TMVA::Configurable::LooseOptionCheckingEnabled() const virtual void MakeClassSpecific(ostream&, const TString&) const virtual void MakeClassSpecificHeader(ostream&, const TString& = "") const void TObject::MakeZombie() void TMVA::Configurable::ResetSetFlag() void TMVA::MethodBase::SetNormalised(Bool_t norm) void TMVA::MethodBase::SetWeightFileDir(TString fileDir) void TMVA::MethodBase::SetWeightFileName(TString) void TMVA::MethodBase::Statistics(TMVA::Types::ETreeType treeType, const TString& theVarName, Double_t&, Double_t&, Double_t&, Double_t&, Double_t&, Double_t&) Bool_t TMVA::MethodBase::TxtWeightsOnly() const Bool_t TMVA::MethodBase::Verbose() const void TMVA::Configurable::WriteOptionsReferenceToFile()
private:
 virtual void DeclareOptions() virtual void Init() virtual void ProcessOptions() Double_t TransformLikelihoodOutput(Double_t ps, Double_t pb) const

## Data Members

public:
 enum TMVA::MethodBase::EWeightFileType { kROOT kTEXT }; enum TMVA::MethodBase::ECutOrientation { kNegative kPositive }; enum TObject::EStatusBits { kCanDelete kMustCleanup kObjInCanvas kIsReferenced kHasUUID kCannotPick kNoContextMenu kInvalidObject }; enum TObject::[unnamed] { kIsOnHeap kNotDeleted kZombie kBitMask kSingleKey kOverwrite kWriteDelete };
public:
 Bool_t TMVA::MethodBase::fSetupCompleted is method setup const TMVA::Event* TMVA::MethodBase::fTmpEvent ! temporary event when testing on a different DataSet than the own one
protected:
 TMVA::Types::EAnalysisType TMVA::MethodBase::fAnalysisType method-mode : true --> regression, false --> classification UInt_t TMVA::MethodBase::fBackgroundClass index of the Background-class vector* TMVA::MethodBase::fInputVars vector of input variables used in MVA Int_t TMVA::MethodBase::fNbins number of bins in representative histograms Int_t TMVA::MethodBase::fNbinsH number of bins in evaluation histograms TMVA::Ranking* TMVA::MethodBase::fRanking pointer to ranking object (created by derived classifiers) vector* TMVA::MethodBase::fRegressionReturnVal holds the return-value for the regression UInt_t TMVA::MethodBase::fSignalClass index of the Signal-class
private:
 Int_t fAverageEvtPerBin average events per bin; used to calculate fNbins Int_t* fAverageEvtPerBinVarB average events per bin; used to calculate fNbins Int_t* fAverageEvtPerBinVarS average events per bin; used to calculate fNbins TString fBorderMethodString the method to take care about "border" effects (string) TMVA::PDF* fDefaultPDFLik pdf that contains default definitions Int_t fDropVariable for ranking test Double_t fEpsilon minimum number of likelihood (to avoid zero) vector* fHistBgd background PDFs (histograms) vector* fHistBgd_smooth background PDFs (smoothed histograms) vector* fHistSig signal PDFs (histograms) vector* fHistSig_smooth signal PDFs (smoothed histograms) TString* fInterpolateString which interpolation method used for reference histograms (individual for each variable) Float_t fKDEfineFactor fine tuning factor for Adaptive KDE TString fKDEiterString Number of iterations (string) TString fKDEtypeString Kernel type to use for KDE (string) Int_t fNsmooth number of smooth passes Int_t* fNsmoothVarB number of smooth passes Int_t* fNsmoothVarS number of smooth passes vector* fPDFBgd list of PDFs (background) vector* fPDFSig list of PDFs (signal) Bool_t fTransformLikelihoodOutput likelihood output is sigmoid-transformed

## Function documentation

MethodLikelihood(const TString& jobName, const TString& methodTitle, TMVA::DataSetInfo& theData, const TString& theOption = "", TDirectory* theTargetDir = 0)
``` standard constructor
```
MethodLikelihood(TMVA::DataSetInfo& theData, const TString& theWeightFile, TDirectory* theTargetDir = NULL)
``` construct likelihood references from file
```
~MethodLikelihood( void )
``` destructor
```
Bool_t HasAnalysisType(TMVA::Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
``` FDA can handle classification with 2 classes
```
void Init( void )
``` default initialisation called by all constructors
```
void DeclareOptions()
``` define the options (their key words) that can be set in the option string
TransformOutput   <bool>   transform (often strongly peaked) likelihood output through sigmoid inversion
```

void ProcessOptions()
void Train( void )
``` create reference distributions (PDFs) from signal and background events:
fill histograms and smooth them; if decorrelation is required, compute
corresponding square-root matrices
the reference histograms require the correct boundaries. Since in Likelihood classification
the transformations are applied using both classes, also the corresponding boundaries
need to take this into account
```
Double_t GetMvaValue(Double_t* err = 0)
``` returns the likelihood estimator for signal
fill a new Likelihood branch into the testTree
```
Double_t TransformLikelihoodOutput(Double_t ps, Double_t pb) const
``` returns transformed or non-transformed output
```
void WriteOptionsToStream(ostream& o, const TString& prefix) const
``` write options to stream
```
``` write weights to XML
```
const TMVA::Ranking* CreateRanking()
``` computes ranking of input variables
```
void WriteWeightsToStream(TFile& rf) const
``` write reference PDFs to ROOT file
```
``` read weights from XML
```
void ReadWeightsFromStream( istream & istr )
``` read weight info from file
nothing to do for this method
```
``` read reference PDF from ROOT file
```
void WriteMonitoringHistosToFile( void )
``` write histograms and PDFs to file for monitoring purposes
```
void MakeClassSpecificHeader(ostream& , const TString& = "") const
``` write specific header of the classifier (mostly include files)
```
void MakeClassSpecific(ostream& , const TString& ) const
``` write specific classifier response
```
void GetHelpMessage() const
``` get help message text

typical length of text line:
"|--------------------------------------------------------------|"
```