File indexing completed on 2025-01-18 10:11:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef ROOT_TMVA_MethodPDEFoam
0036 #define ROOT_TMVA_MethodPDEFoam
0037
0038
0039
0040
0041
0042
0043
0044 #include "TMVA/MethodBase.h"
0045
0046 #include "TMVA/PDEFoam.h"
0047
0048 #include "TMVA/PDEFoamDecisionTree.h"
0049 #include "TMVA/PDEFoamEvent.h"
0050 #include "TMVA/PDEFoamDiscriminant.h"
0051 #include "TMVA/PDEFoamTarget.h"
0052 #include "TMVA/PDEFoamMultiTarget.h"
0053
0054 #include "TMVA/PDEFoamDensityBase.h"
0055 #include "TMVA/PDEFoamTargetDensity.h"
0056 #include "TMVA/PDEFoamEventDensity.h"
0057 #include "TMVA/PDEFoamDiscriminantDensity.h"
0058 #include "TMVA/PDEFoamDecisionTreeDensity.h"
0059
0060 #include "TMVA/PDEFoamKernelBase.h"
0061 #include "TMVA/PDEFoamKernelTrivial.h"
0062 #include "TMVA/PDEFoamKernelLinN.h"
0063 #include "TMVA/PDEFoamKernelGauss.h"
0064
0065 #include <vector>
0066
0067 namespace TMVA {
0068
0069 class MethodPDEFoam : public MethodBase {
0070
0071 public:
0072
0073
0074 typedef enum EKernel { kNone=0, kGaus=1, kLinN=2 } EKernel;
0075
0076 MethodPDEFoam( const TString& jobName,
0077 const TString& methodTitle,
0078 DataSetInfo& dsi,
0079 const TString& theOption = "PDEFoam");
0080
0081 MethodPDEFoam( DataSetInfo& dsi,
0082 const TString& theWeightFile);
0083
0084 virtual ~MethodPDEFoam( void );
0085
0086 virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
0087
0088
0089 void Train( void );
0090 void TrainMonoTargetRegression( void );
0091 void TrainMultiTargetRegression( void );
0092 void TrainSeparatedClassification( void );
0093 void TrainUnifiedClassification( void );
0094 void TrainMultiClassification();
0095
0096 using MethodBase::ReadWeightsFromStream;
0097
0098
0099 void AddWeightsXMLTo( void* parent ) const;
0100
0101
0102 void ReadWeightsFromStream( std::istream & i );
0103 void ReadWeightsFromXML ( void* wghtnode );
0104
0105
0106 void WriteFoamsToFile() const;
0107 void ReadFoamsFromFile();
0108 PDEFoam* ReadClonedFoamFromFile(TFile*, const TString&);
0109
0110
0111 Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0112
0113
0114 const std::vector<Float_t>& GetMulticlassValues();
0115
0116
0117 virtual const std::vector<Float_t>& GetRegressionValues();
0118
0119
0120 virtual void Reset();
0121
0122
0123 const Ranking* CreateRanking();
0124
0125
0126 void GetNCuts(PDEFoamCell *cell, std::vector<UInt_t> &nCuts);
0127
0128
0129 EKernel GetKernel( void ) { return fKernel; }
0130 UInt_t KernelToUInt(EKernel ker) const { return UInt_t(ker); }
0131 EKernel UIntToKernel(UInt_t iker);
0132 UInt_t TargetSelectionToUInt(ETargetSelection ts) const { return UInt_t(ts); }
0133 ETargetSelection UIntToTargetSelection(UInt_t its);
0134
0135 protected:
0136
0137
0138 void MakeClassSpecific( std::ostream&, const TString& ) const;
0139
0140
0141 void GetHelpMessage() const;
0142
0143
0144 Double_t CalculateMVAError();
0145
0146
0147 void CalcXminXmax();
0148
0149
0150 void SetXminXmax(TMVA::PDEFoam*);
0151
0152
0153 PDEFoam* InitFoam(TString, EFoamType, UInt_t cls=0);
0154
0155
0156 PDEFoamKernelBase* CreatePDEFoamKernel();
0157
0158
0159 void DeleteFoams();
0160
0161
0162 void FillVariableNamesToFoam() const;
0163
0164 private:
0165
0166
0167 void DeclareOptions();
0168 void DeclareCompatibilityOptions();
0169 void ProcessOptions();
0170
0171
0172 void PrintCoefficients( void );
0173
0174
0175 template<typename T> T Sqr(T x) const { return x*x; }
0176
0177
0178 Bool_t fSigBgSeparated;
0179 Float_t fFrac;
0180 Float_t fDiscrErrCut;
0181 Float_t fVolFrac;
0182 Int_t fnCells;
0183 Int_t fnActiveCells;
0184 Int_t fnSampl;
0185 Int_t fnBin;
0186 Int_t fEvPerBin;
0187
0188 Bool_t fCompress;
0189 Bool_t fMultiTargetRegression;
0190 UInt_t fNmin;
0191 Bool_t fCutNmin;
0192 UInt_t fMaxDepth;
0193
0194 TString fKernelStr;
0195 EKernel fKernel;
0196 PDEFoamKernelBase *fKernelEstimator;
0197 TString fTargetSelectionStr;
0198 ETargetSelection fTargetSelection;
0199 Bool_t fFillFoamWithOrigWeights;
0200 Bool_t fUseYesNoCell;
0201 TString fDTLogic;
0202 EDTSeparation fDTSeparation;
0203 Bool_t fPeekMax;
0204
0205 std::vector<Float_t> fXmin, fXmax;
0206
0207 std::vector<PDEFoam*> fFoam;
0208
0209
0210 void Init( void );
0211
0212 ClassDef(MethodPDEFoam,0);
0213 };
0214
0215 }
0216
0217 #endif