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 #ifndef ROOT_TMVA_MethodSVM
0034 #define ROOT_TMVA_MethodSVM
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #include "TMVA/MethodBase.h"
0045 #include "TMatrixDfwd.h"
0046 #include <string>
0047 #include <vector>
0048 #include <map>
0049
0050 #ifndef ROOT_TMVA_TVectorD
0051 #include "TVectorD.h"
0052 #include "TMVA/SVKernelFunction.h"
0053 #endif
0054
0055 namespace TMVA
0056 {
0057 class SVWorkingSet;
0058 class SVEvent;
0059 class SVKernelFunction;
0060
0061 class MethodSVM : public MethodBase {
0062
0063 public:
0064
0065 MethodSVM( const TString& jobName, const TString& methodTitle, DataSetInfo& theData,
0066 const TString& theOption = "" );
0067
0068 MethodSVM( DataSetInfo& theData, const TString& theWeightFile);
0069
0070 virtual ~MethodSVM( void );
0071
0072 virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
0073
0074
0075 virtual std::map<TString,Double_t> OptimizeTuningParameters(TString fomType="ROCIntegral", TString fitType="Minuit");
0076 virtual void SetTuneParameters(std::map<TString,Double_t> tuneParameters);
0077 std::vector<TMVA::SVKernelFunction::EKernelType> MakeKernelList(std::string multiKernels, TString kernel);
0078 std::map< TString,std::vector<Double_t> > GetTuningOptions();
0079
0080
0081 void Train( void );
0082
0083
0084 void Reset( void );
0085
0086 using MethodBase::ReadWeightsFromStream;
0087
0088
0089 void WriteWeightsToStream( TFile& fout ) const;
0090 void AddWeightsXMLTo ( void* parent ) const;
0091
0092
0093 void ReadWeightsFromStream( std::istream& istr );
0094 void ReadWeightsFromStream( TFile& fFin );
0095 void ReadWeightsFromXML ( void* wghtnode );
0096
0097
0098 Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0099 const std::vector<Float_t>& GetRegressionValues();
0100
0101 void Init( void );
0102
0103
0104 const Ranking* CreateRanking() { return nullptr; }
0105
0106
0107 void SetGamma(Double_t g){fGamma = g;}
0108 void SetCost(Double_t c){fCost = c;}
0109 void SetMGamma(std::string & mg);
0110 void SetOrder(Double_t o){fOrder = o;}
0111 void SetTheta(Double_t t){fTheta = t;}
0112 void SetKappa(Double_t k){fKappa = k;}
0113 void SetMult(Double_t m){fMult = m;}
0114
0115 void GetMGamma(const std::vector<float> & gammas);
0116
0117 protected:
0118
0119
0120 void MakeClassSpecific( std::ostream&, const TString& ) const;
0121
0122
0123 void GetHelpMessage() const;
0124
0125 private:
0126
0127
0128 void DeclareOptions();
0129 void DeclareCompatibilityOptions();
0130 void ProcessOptions();
0131 Double_t getLoss( TString lossFunction );
0132
0133 Float_t fCost;
0134 Float_t fTolerance;
0135 UInt_t fMaxIter;
0136 UShort_t fNSubSets;
0137 Float_t fBparm;
0138 Float_t fGamma;
0139 SVWorkingSet* fWgSet;
0140 std::vector<TMVA::SVEvent*>* fInputData;
0141 std::vector<TMVA::SVEvent*>* fSupportVectors;
0142 SVKernelFunction* fSVKernelFunction;
0143
0144 TVectorD* fMinVars;
0145 TVectorD* fMaxVars;
0146
0147
0148 TString fTheKernel;
0149 Float_t fDoubleSigmaSquared;
0150 Int_t fOrder;
0151 Float_t fTheta;
0152 Float_t fKappa;
0153 Float_t fMult;
0154 std::vector<Float_t> fmGamma;
0155 Float_t fNumVars;
0156 std::vector<TString> fVarNames;
0157 std::string fGammas;
0158 std::string fGammaList;
0159 std::string fTune;
0160 std::string fMultiKernels;
0161
0162 Int_t fDataSize;
0163 TString fLoss;
0164
0165 ClassDef(MethodSVM,0);
0166 };
0167
0168 }
0169
0170 #endif