00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef ROOT_TMVA_MethodPDERS
00039 #define ROOT_TMVA_MethodPDERS
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef ROOT_TMVA_MethodBase
00051 #include "TMVA/MethodBase.h"
00052 #endif
00053 #ifndef ROOT_TMVA_BinarySearchTree
00054 #include "TMVA/BinarySearchTree.h"
00055 #endif
00056 #ifndef ROOT_TMVA_TVector
00057 #ifndef ROOT_TVector
00058 #include "TVector.h"
00059 #endif
00060 #endif
00061
00062 namespace TMVA {
00063
00064 class Volume;
00065 class Event;
00066
00067 class MethodPDERS : public MethodBase {
00068
00069 public:
00070
00071 MethodPDERS( const TString& jobName,
00072 const TString& methodTitle,
00073 DataSetInfo& theData,
00074 const TString& theOption,
00075 TDirectory* theTargetDir = 0 );
00076
00077 MethodPDERS( DataSetInfo& theData,
00078 const TString& theWeightFile,
00079 TDirectory* theTargetDir = NULL );
00080
00081 virtual ~MethodPDERS( void );
00082
00083 virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
00084
00085
00086
00087 void Train( void );
00088
00089
00090 void WriteWeightsToStream( TFile& rf ) const;
00091 void AddWeightsXMLTo( void* parent ) const;
00092
00093
00094 void ReadWeightsFromStream( istream& istr );
00095 void ReadWeightsFromStream( TFile& istr );
00096 void ReadWeightsFromXML( void* wghtnode );
00097
00098
00099 Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
00100
00101
00102 const std::vector<Float_t>& GetRegressionValues();
00103 public:
00104
00105
00106 static Double_t IGetVolumeContentForRoot( Double_t );
00107 Double_t GetVolumeContentForRoot( Double_t );
00108
00109
00110 static MethodPDERS* ThisPDERS( void );
00111
00112 protected:
00113
00114
00115 void MakeClassSpecific( std::ostream&, const TString& ) const;
00116
00117
00118 void GetHelpMessage() const;
00119
00120 Volume* fHelpVolume;
00121 Int_t fFcnCall;
00122
00123
00124 BinarySearchTree* GetBinaryTree( void ) const { return fBinaryTree; }
00125
00126 Double_t CKernelEstimate( const Event&, std::vector<const BinarySearchTreeNode*>&, Volume& );
00127 void RKernelEstimate( const Event&, std::vector<const BinarySearchTreeNode*>&, Volume&, std::vector<Float_t> *pdfSum );
00128
00129 Double_t ApplyKernelFunction( Double_t normalized_distance );
00130 Double_t KernelNormalization( Double_t pdf );
00131 Double_t GetNormalizedDistance( const TMVA::Event &base_event,
00132 const BinarySearchTreeNode &sample_event,
00133 Double_t *dim_normalization);
00134 Double_t NormSinc( Double_t x );
00135 Double_t LanczosFilter( Int_t level, Double_t x );
00136
00137
00138 const Ranking* CreateRanking() { return 0; }
00139
00140 private:
00141
00142
00143 void DeclareOptions();
00144 void ProcessOptions();
00145
00146
00147 void CalcAverages();
00148
00149
00150 void CreateBinarySearchTree( Types::ETreeType type );
00151
00152
00153 void GetSample( const Event &e, std::vector<const BinarySearchTreeNode*>& events, Volume *volume);
00154
00155
00156 TString fVolumeRange;
00157 TString fKernelString;
00158
00159 enum EVolumeRangeMode {
00160 kUnsupported = 0,
00161 kMinMax,
00162 kRMS,
00163 kAdaptive,
00164 kUnscaled,
00165 kkNN
00166 } fVRangeMode;
00167
00168 enum EKernelEstimator {
00169 kBox = 0,
00170 kSphere,
00171 kTeepee,
00172 kGauss,
00173 kSinc3,
00174 kSinc5,
00175 kSinc7,
00176 kSinc9,
00177 kSinc11,
00178 kLanczos2,
00179 kLanczos3,
00180 kLanczos5,
00181 kLanczos8,
00182 kTrim
00183 } fKernelEstimator;
00184
00185 BinarySearchTree* fBinaryTree;
00186
00187 std::vector<Float_t>* fDelta;
00188 std::vector<Float_t>* fShift;
00189 std::vector<Float_t> fAverageRMS;
00190
00191 Float_t fScaleS;
00192 Float_t fScaleB;
00193 Float_t fDeltaFrac;
00194 Double_t fGaussSigma;
00195 Double_t fGaussSigmaNorm;
00196
00197 Double_t fNRegOut;
00198
00199
00200 Float_t fNEventsMin;
00201 Float_t fNEventsMax;
00202 Float_t fMaxVIterations;
00203 Float_t fInitialScale;
00204
00205 Bool_t fInitializedVolumeEle;
00206
00207 Int_t fkNNMin;
00208 Int_t fkNNMax;
00209
00210 Double_t fMax_distance;
00211 Bool_t fPrinted;
00212 Bool_t fNormTree;
00213
00214 void SetVolumeElement ( void );
00215
00216 Double_t CRScalc ( const Event& );
00217 void RRScalc ( const Event&, std::vector<Float_t>* count );
00218
00219 Float_t GetError ( Float_t countS, Float_t countB,
00220 Float_t sumW2S, Float_t sumW2B ) const;
00221
00222
00223 static MethodPDERS* fgThisPDERS;
00224 void UpdateThis();
00225
00226 void Init( void );
00227
00228 ClassDef(MethodPDERS,0)
00229 };
00230
00231 }
00232
00233 #endif // MethodPDERS_H