KSquare Utilities
ModelParamSvmBase.h
Go to the documentation of this file.
1 #ifndef _MODELPARAMSVMBASE_
2 #define _MODELPARAMSVMBASE_
3 
4 
5 #include "ModelParam.h"
6 #include "svm2.h"
7 
8 using namespace SVM289_MFS;
9 
10 namespace KKMLL
11 {
12  /**
13  ************************************************************************************************
14  * This class encapsulates general parameters that are common to all Machine Learning Models. *
15  ************************************************************************************************
16  * @see Model
17  */
19  {
20  public:
22 
24 
25  ModelParamSvmBase (SVM_Type _svm_type,
26  Kernel_Type _kernelType,
27  double _cost,
28  double _gamma
29  );
30 
31  ModelParamSvmBase (const ModelParamSvmBase& _param);
32 
33  virtual
35 
36  virtual ModelParamSvmBasePtr Duplicate () const;
37 
39 
40 
41  const SVM289_MFS::svm_parameter& SvmParam () {return svmParam;}
42 
43  virtual void Cost (double _cost);
44  virtual void Gamma (double _gamma);
45  virtual void KernalType (Kernel_Type _kernalType) {svmParam.KernalType (_kernalType);}
46  virtual void SvmType (SVM_Type _svm_type) {svmParam.SvmType (_svm_type);}
47 
48  virtual double Cost () const;
49  virtual double Gamma () const;
50  virtual Kernel_Type KernalType () const {return svmParam.KernalType ();}
51  virtual SVM_Type SvmType () const {return svmParam.SvmType ();}
52 
53 
54  /**
55  *@brief Creates a Command Line String that represents these parameters.
56  *@details All derived classes should implement this method. They should first call this method and
57  * then append there own parameters that are specific to their implementation.
58  */
59  virtual KKStr ToCmdLineStr () const;
60 
61  virtual void ReadXML (XmlStream& s,
62  XmlTagConstPtr tag,
63  VolConstBool& cancelFlag,
64  RunLog& log
65  );
66 
67 
68  virtual void WriteXML (const KKStr& varName,
69  ostream& o
70  ) const;
71 
72  private:
73  virtual void ParseCmdLinePost (); // Will get called after the entire parameter string has been processed.
74 
75  virtual void ParseCmdLineParameter (const KKStr& parameter,
76  const KKStr& value,
77  bool& parameterUsed,
78  RunLog& log
79  );
80 
81  SVM289_MFS::svm_parameter svmParam;
82 
83  }; /* ModelParamSvmBase */
84 
85  typedef ModelParamSvmBase::ModelParamSvmBasePtr ModelParamSvmBasePtr;
86 
89 
90 } /* namespace KKMLL */
91 
92 
93 
94 #endif
ModelParam derived classes will implement their "XmlElement" helper class via this template...
Definition: ModelParam.h:260
virtual void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
virtual void SvmType(SVM_Type _svm_type)
SVM_Type
Definition: svm2.h:72
virtual KKStr ToCmdLineStr() const
Creates a Command Line String that represents these parameters.
virtual double Gamma() const
const SVM289_MFS::svm_parameter & SvmParam()
virtual Kernel_Type KernalType() const
XmlElementModelParamTemplate< ModelParamSvmBase > XmlElementModelParamSvmBase
virtual ModelParamTypes ModelParamType() const
virtual double Cost() const
ModelParamSvmBase * ModelParamSvmBasePtr
ModelParamSvmBase(const ModelParamSvmBase &_param)
Kernel_Type KernalType() const
Definition: svm2.h:116
XmlTag const * XmlTagConstPtr
Definition: KKStr.h:45
Manages the reading and writing of objects in a simple XML format. For a class to be supported by Xml...
Definition: XmlStream.h:46
XmlElementModelParamSvmBase * XmlElementModelParamSvmBasePtr
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
Used for logging messages.
Definition: RunLog.h:49
void EncodeProblem(const struct svm_paramater &param, struct svm_problem &prob_in, struct svm_problem &prob_out)
virtual void Gamma(double _gamma)
virtual void Cost(double _cost)
virtual void KernalType(Kernel_Type _kernalType)
virtual void WriteXML(const KKStr &varName, ostream &o) const
virtual SVM_Type SvmType() const
void KernalType(Kernel_Type _kernalType)
Definition: svm2.h:111
SVM_Type SvmType() const
Definition: svm2.h:117
Abstract Base class for Machine Learning parameters.
Definition: ModelParam.h:35
Kernel_Type
Definition: svm2.h:83
virtual ModelParamSvmBasePtr Duplicate() const
ModelParamSvmBase(SVM_Type _svm_type, Kernel_Type _kernelType, double _cost, double _gamma)
void SvmType(SVM_Type _svm_type)
Definition: svm2.h:112
volatile const bool VolConstBool
Definition: KKBaseTypes.h:163