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
0036
0037
0038 #ifndef ROOT_TMVA_MethodPDERS
0039 #define ROOT_TMVA_MethodPDERS
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 #include "TMVA/MethodBase.h"
0051 #include "TMVA/BinarySearchTree.h"
0052 #include "TVector.h"
0053 #include "ThreadLocalStorage.h"
0054 #include <vector>
0055
0056 namespace TMVA {
0057
0058 class Volume;
0059 class Event;
0060
0061 class MethodPDERS : public MethodBase {
0062
0063 public:
0064
0065 MethodPDERS( const TString& jobName,
0066 const TString& methodTitle,
0067 DataSetInfo& theData,
0068 const TString& theOption);
0069
0070 MethodPDERS( DataSetInfo& theData,
0071 const TString& theWeightFile);
0072
0073 virtual ~MethodPDERS( void );
0074
0075 virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
0076
0077
0078
0079 void Train( void );
0080
0081
0082 void WriteWeightsToStream( TFile& rf ) const;
0083 void AddWeightsXMLTo( void* parent ) const;
0084
0085
0086 void ReadWeightsFromStream( std::istream& istr );
0087 void ReadWeightsFromStream( TFile& istr );
0088 void ReadWeightsFromXML( void* wghtnode );
0089
0090
0091 Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0092
0093
0094 const std::vector<Float_t>& GetRegressionValues();
0095 public:
0096
0097
0098 static Double_t IGetVolumeContentForRoot( Double_t );
0099 Double_t GetVolumeContentForRoot( Double_t );
0100
0101
0102 static MethodPDERS* ThisPDERS( void );
0103
0104 protected:
0105
0106
0107 void MakeClassSpecific( std::ostream&, const TString& ) const;
0108
0109
0110 void GetHelpMessage() const;
0111
0112 Volume* fHelpVolume;
0113 Int_t fFcnCall;
0114
0115
0116 BinarySearchTree* GetBinaryTree( void ) const { return fBinaryTree; }
0117
0118 Double_t CKernelEstimate( const Event&, std::vector<const BinarySearchTreeNode*>&, Volume& );
0119 void RKernelEstimate( const Event&, std::vector<const BinarySearchTreeNode*>&, Volume&, std::vector<Float_t> *pdfSum );
0120
0121 Double_t ApplyKernelFunction( Double_t normalized_distance );
0122 Double_t KernelNormalization( Double_t pdf );
0123 Double_t GetNormalizedDistance( const TMVA::Event &base_event,
0124 const BinarySearchTreeNode &sample_event,
0125 Double_t *dim_normalization);
0126 Double_t NormSinc( Double_t x );
0127 Double_t LanczosFilter( Int_t level, Double_t x );
0128
0129
0130 const Ranking* CreateRanking() { return nullptr; }
0131
0132 private:
0133
0134
0135 void DeclareOptions();
0136 void ProcessOptions();
0137
0138
0139 void CalcAverages();
0140
0141
0142 void CreateBinarySearchTree( Types::ETreeType type );
0143
0144
0145 void GetSample( const Event &e, std::vector<const BinarySearchTreeNode*>& events, Volume *volume);
0146
0147
0148 TString fVolumeRange;
0149 TString fKernelString;
0150
0151 enum EVolumeRangeMode {
0152 kUnsupported = 0,
0153 kMinMax,
0154 kRMS,
0155 kAdaptive,
0156 kUnscaled,
0157 kkNN
0158 } fVRangeMode;
0159
0160 enum EKernelEstimator {
0161 kBox = 0,
0162 kSphere,
0163 kTeepee,
0164 kGauss,
0165 kSinc3,
0166 kSinc5,
0167 kSinc7,
0168 kSinc9,
0169 kSinc11,
0170 kLanczos2,
0171 kLanczos3,
0172 kLanczos5,
0173 kLanczos8,
0174 kTrim
0175 } fKernelEstimator;
0176
0177 BinarySearchTree* fBinaryTree;
0178
0179 std::vector<Float_t>* fDelta;
0180 std::vector<Float_t>* fShift;
0181 std::vector<Float_t> fAverageRMS;
0182
0183 Float_t fScaleS;
0184 Float_t fScaleB;
0185 Float_t fDeltaFrac;
0186 Double_t fGaussSigma;
0187 Double_t fGaussSigmaNorm;
0188
0189 Double_t fNRegOut;
0190
0191
0192 Float_t fNEventsMin;
0193 Float_t fNEventsMax;
0194 Float_t fMaxVIterations;
0195 Float_t fInitialScale;
0196
0197 Bool_t fInitializedVolumeEle;
0198
0199 Int_t fkNNMin;
0200 Int_t fkNNMax;
0201
0202 Double_t fMax_distance;
0203 Bool_t fPrinted;
0204 Bool_t fNormTree;
0205
0206 void SetVolumeElement ( void );
0207
0208 Double_t CRScalc ( const Event& );
0209 void RRScalc ( const Event&, std::vector<Float_t>* count );
0210
0211 Float_t GetError ( Float_t countS, Float_t countB,
0212 Float_t sumW2S, Float_t sumW2B ) const;
0213
0214
0215
0216 static MethodPDERS*& GetMethodPDERSThreadLocal() {TTHREAD_TLS(MethodPDERS*) fgThisPDERS(nullptr); return fgThisPDERS;};
0217 void UpdateThis();
0218
0219 void Init( void );
0220
0221 ClassDef(MethodPDERS,0);
0222 };
0223
0224 }
0225
0226 #endif