![]() |
KSquare Utilities
|
Abstract Base class for Machine Learning parameters. More...
#include <ModelParam.h>
Inheritance diagram for KKMLL::ModelParam:Public Member Functions | |
| ModelParam () | |
| ModelParam (const ModelParam &_param) | |
| virtual | ~ModelParam () |
| virtual float | A_Param () const |
| virtual void | A_Param (float _prob) |
| virtual float | AvgMumOfFeatures () const |
| virtual double | C_Param () const |
| virtual void | C_Param (double _cost) |
| virtual double | Cost () const |
| virtual void | Cost (double _cost) |
| virtual ModelParamPtr | Duplicate () const =0 |
| virtual EncodingMethodType | EncodingMethod () const |
| virtual void | EncodingMethod (EncodingMethodType _encodingMethod) |
| virtual KKStr | EncodingMethodStr () const |
| virtual kkint32 | ExamplesPerClass () const |
| virtual void | ExamplesPerClass (kkint32 _examplesPerClass) |
| virtual const KKStr & | FileName () const |
| virtual void | FileName (const KKStr &_fileName) |
| virtual double | Gamma () const |
| virtual void | Gamma (double _gamma) |
| virtual kkint32 | MemoryConsumedEstimated () const |
| virtual ModelParamTypes | ModelParamType () const =0 |
| virtual KKStr | ModelParamTypeStr () const |
| virtual bool | NormalizeNominalFeatures () const |
| virtual kkint32 | NumOfFeaturesAfterEncoding (FileDescPtr fileDesc, RunLog &log) const |
| virtual void | ParseCmdLine (KKStr _cmdLineStr, bool &_validFormat, RunLog &_log) |
| virtual void | ParseCmdLinePost (RunLog &log) |
| Called after 'ParseCmdLine' is completed. Classed derived from 'ModelParam' can implement this method to do any processing that they want after the entire command line has been processed. More... | |
| virtual float | Prob () const |
| virtual void | Prob (float _prob) |
| virtual void | ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)=0 |
| XmlTokenPtr | ReadXMLModelParamToken (XmlTokenPtr t) |
| Will process any tokens that belong to 'ModelParam' and return NULL ones that are not will be passed back. More... | |
| virtual FeatureNumListConstPtr | SelectedFeatures () const |
| virtual void | SelectedFeatures (FeatureNumListConst &_selectedFeatures) |
| virtual KKStr | ToCmdLineStr () const |
| Creates a a Command Line String that represents these parameters. More... | |
| virtual bool | ValidParam () const |
| virtual void | ValidParam (bool _validParam) |
| virtual void | WriteXML (const KKStr &varName, std::ostream &o) const =0 |
| void | WriteXMLFields (std::ostream &o) const |
Static Public Member Functions | |
| static EncodingMethodType | EncodingMethodFromStr (const KKStr &encodingMethodStr) |
| static KKStr | EncodingMethodToStr (EncodingMethodType encodingMethod) |
| static ModelParamTypes | ModelParamTypeFromStr (const KKStr &_modelParamTypeStr) |
| static KKStr | ModelParamTypeToStr (ModelParamTypes _modelParamType) |
Abstract Base class for Machine Learning parameters.
For each Machine Learning algorithm implemented you would create a specialization of this class to manage the parameters required by the algorithm. Specifically for each new class that you create that is derived from 'Model' you will create a class derived from 'ModelParam'. This class encapsulates general parameters that are common to all Machine Learning Models.
Definition at line 35 of file ModelParam.h.
Definition at line 38 of file ModelParam.h.
|
strong |
Needs to be synchronized with SVMparam::SVM_EncodingMethod
| Enumerator | |
|---|---|
| Null | |
| NoEncoding | |
| Binary | |
| Scaled | |
Definition at line 56 of file ModelParam.h.
|
strong |
| Enumerator | |
|---|---|
| Null | |
| Dual | |
| KNN | |
| OldSVM | |
| SvmBase | |
| UsfCasCor | |
Definition at line 40 of file ModelParam.h.
| ModelParam::ModelParam | ( | ) |
Definition at line 31 of file ModelParam.cpp.
References KKB::KKStr::KKStr(), and NoEncoding.
Referenced by KKMLL::ModelParamDual::ModelParamDual(), KKMLL::ModelParamKnn::ModelParamKnn(), KKMLL::ModelParamOldSVM::ModelParamOldSVM(), KKMLL::ModelParamSvmBase::ModelParamSvmBase(), and KKMLL::ModelParamUsfCasCor::ModelParamUsfCasCor().
| ModelParam::ModelParam | ( | const ModelParam & | _param | ) |
Definition at line 61 of file ModelParam.cpp.
References KKMLL::FeatureNumList::FeatureNumList(), and KKB::KKStr::KKStr().
Referenced by KKMLL::ModelParamDual::ModelParamDual(), KKMLL::ModelParamKnn::ModelParamKnn(), KKMLL::ModelParamOldSVM::ModelParamOldSVM(), and KKMLL::ModelParamSvmBase::ModelParamSvmBase().
|
virtual |
Definition at line 80 of file ModelParam.cpp.
|
virtual |
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 172 of file ModelParam.cpp.
Referenced by KKMLL::TrainingConfiguration2::A_Param().
|
virtual |
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 201 of file ModelParam.cpp.
Referenced by KKMLL::ModelParamOldSVM::A_Param(), KKMLL::TrainingConfiguration2::A_Param(), and KKMLL::ModelParamOldSVM::ParseCmdLine().
|
virtual |
Definition at line 99 of file ModelParam.cpp.
References KKMLL::FeatureNumList::NumOfFeatures().
Referenced by KKMLL::TrainingConfiguration2::AvgNumOfFeatures().
|
virtual |
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 177 of file ModelParam.cpp.
Referenced by KKMLL::TrainingConfiguration2::C_Param().
|
virtual |
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 207 of file ModelParam.cpp.
Referenced by KKMLL::TrainingConfiguration2::C_Param(), and KKMLL::ModelParamOldSVM::ParseCmdLine().
|
virtual |
Reimplemented in KKMLL::ModelParamSvmBase.
Definition at line 182 of file ModelParam.cpp.
|
virtual |
Reimplemented in KKMLL::ModelParamSvmBase.
Definition at line 213 of file ModelParam.cpp.
Referenced by KKMLL::ModelParamOldSVM::C_Param(), KKMLL::ModelParamSvmBase::Cost(), and ParseCmdLine().
|
pure virtual |
Implemented in KKMLL::ModelParamDual, KKMLL::ModelParamOldSVM, KKMLL::ModelParamSvmBase, KKMLL::ModelParamUsfCasCor, and KKMLL::ModelParamKnn.
Referenced by KKMLL::Model::Model(), KKMLL::TrainingConfiguration2::ModelParameters(), KKMLL::TrainingConfiguration2::SetModelParameters(), and KKMLL::TrainingConfiguration2::TrainingConfiguration2().
|
inlinevirtual |
Definition at line 111 of file ModelParam.h.
Referenced by KKMLL::FeatureEncoder2::FeatureEncoder2(), KKMLL::Model::NormalizeNominalAttributes(), NumOfFeaturesAfterEncoding(), and KKMLL::Model::TrainModel().
|
inlinevirtual |
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 128 of file ModelParam.h.
Referenced by KKMLL::ModelParamOldSVM::EncodingMethod(), KKMLL::TrainingConfiguration2::EncodingMethod(), and KKMLL::ModelParamOldSVM::ParseCmdLine().
|
static |
Definition at line 444 of file ModelParam.cpp.
References Binary, KKB::KKStr::Concat(), NoEncoding, Null, KKB::KKStr::operator==(), Scaled, and KKB::KKStr::ToUpper().
Referenced by ParseCmdLine(), and ReadXMLModelParamToken().
|
inlinevirtual |
Definition at line 112 of file ModelParam.h.
References EncodingMethodToStr().
|
static |
Definition at line 428 of file ModelParam.cpp.
References Binary, and Scaled.
Referenced by EncodingMethodStr(), ToCmdLineStr(), and WriteXMLFields().
|
inlinevirtual |
Definition at line 113 of file ModelParam.h.
Referenced by KKMLL::Model::ReduceTrainExamples(), and KKMLL::Model::TrainModel().
|
inlinevirtual |
Definition at line 129 of file ModelParam.h.
|
inlinevirtual |
Definition at line 114 of file ModelParam.h.
|
inlinevirtual |
Definition at line 130 of file ModelParam.h.
References KKB::KKStr::operator=().
|
virtual |
Reimplemented in KKMLL::ModelParamOldSVM, and KKMLL::ModelParamSvmBase.
Definition at line 187 of file ModelParam.cpp.
Referenced by KKMLL::TrainingConfiguration2::Gamma().
|
virtual |
Reimplemented in KKMLL::ModelParamOldSVM, and KKMLL::ModelParamSvmBase.
Definition at line 219 of file ModelParam.cpp.
Referenced by KKMLL::ModelParamSvmBase::Gamma(), KKMLL::ModelParamOldSVM::Gamma(), KKMLL::TrainingConfiguration2::Gamma(), KKMLL::ModelParamOldSVM::Gamma_Param(), ParseCmdLine(), and KKMLL::ModelParamOldSVM::ParseCmdLine().
|
virtual |
Definition at line 87 of file ModelParam.cpp.
References KKMLL::FeatureNumList::MemoryConsumedEstimated(), and KKB::KKStr::MemoryConsumedEstimated().
Referenced by KKMLL::Model::MemoryConsumedEstimated().
|
pure virtual |
Implemented in KKMLL::ModelParamDual, KKMLL::ModelParamOldSVM, KKMLL::ModelParamSvmBase, KKMLL::ModelParamUsfCasCor, and KKMLL::ModelParamKnn.
Referenced by ModelParamTypeStr(), KKMLL::TrainingConfiguration2::Number_of_rounds(), KKMLL::ModelOldSVM::Param(), and KKMLL::TrainingConfiguration2::TrainingConfiguration2().
|
static |
Definition at line 148 of file ModelParam.cpp.
References Dual, KKB::KKStr::EqualIgnoreCase(), KNN, Null, OldSVM, SvmBase, and UsfCasCor.
|
inlinevirtual |
Definition at line 108 of file ModelParam.h.
References ModelParamType(), and ModelParamTypeToStr().
Referenced by KKMLL::ModelKnn::ReadXML(), KKMLL::ModelUsfCasCor::ReadXML(), KKMLL::ModelSvmBase::ReadXML(), KKMLL::ModelDual::ReadXML(), and KKMLL::ModelOldSVM::ReadXML().
|
static |
Definition at line 122 of file ModelParam.cpp.
References Dual, KNN, Null, OldSVM, SvmBase, and UsfCasCor.
Referenced by ModelParamTypeStr().
|
inlinevirtual |
Definition at line 115 of file ModelParam.h.
Referenced by KKMLL::NormalizationParms::NormalizationParms(), and KKMLL::TrainingConfiguration2::NormalizeNominalFeatures().
|
virtual |
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 387 of file ModelParam.cpp.
References Binary, KKMLL::FileDesc::Cardinality(), EncodingMethod(), KKMLL::FeatureNumList::FeatureNumList(), NoEncoding, KKMLL::Nominal, KKMLL::FeatureNumList::NumOfFeatures(), KKMLL::FeatureNumList::operator[](), Scaled, KKMLL::Symbolic, and KKMLL::FileDesc::Type().
Referenced by KKMLL::TrainingConfiguration2::NumOfFeaturesAfterEncoding().
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 234 of file ModelParam.cpp.
References KKB::KKStr::Concat(), Cost(), KKB::KKStr::Empty(), EncodingMethodFromStr(), KKB::KKStr::EqualIgnoreCase(), KKB::KKStr::ExtractToken(), KKB::KKStr::ExtractTokenBool(), KKMLL::FeatureNumList::FeatureNumList(), KKB::KKStr::FirstChar(), Gamma(), KKB::KKStr::KKStr(), KKB::KKStr::Len(), KKB::KKStr::operator=(), KKB::KKStr::operator==(), ParseCmdLinePost(), KKB::KKStr::ToInt(), KKB::KKStr::TrimLeft(), and KKB::KKStr::Upper().
|
virtual |
Called after 'ParseCmdLine' is completed. Classed derived from 'ModelParam' can implement this method to do any processing that they want after the entire command line has been processed.
An example use of this is in 'ModelParamSvmBase' where the local 'ParseCmdLineParameter' routine processes parameters that 'Model' needs to be aware of.
Definition at line 358 of file ModelParam.cpp.
Referenced by ParseCmdLine().
|
virtual |
Definition at line 192 of file ModelParam.cpp.
|
virtual |
Definition at line 225 of file ModelParam.cpp.
|
pure virtual |
| XmlTokenPtr ModelParam::ReadXMLModelParamToken | ( | XmlTokenPtr | t | ) |
Will process any tokens that belong to 'ModelParam' and return NULL ones that are not will be passed back.
Definition at line 487 of file ModelParam.cpp.
References KKB::KKStr::Concat(), EncodingMethodFromStr(), KKB::KKStr::EqualIgnoreCase(), KKB::KKStr::operator=(), KKB::XmlElement::ToBool(), KKB::XmlElement::ToInt32(), KKB::XmlToken::tokElement, KKB::XmlToken::TokenType(), KKB::XmlElement::ToKKStr(), and KKB::XmlToken::VarName().
Referenced by KKMLL::ModelParamKnn::ReadXML(), KKMLL::ModelParamSvmBase::ReadXML(), KKMLL::ModelParamUsfCasCor::ReadXML(), KKMLL::ModelParamDual::ReadXML(), and KKMLL::ModelParamOldSVM::ReadXML().
|
inlinevirtual |
Reimplemented in KKMLL::ModelParamOldSVM.
Definition at line 116 of file ModelParam.h.
Referenced by KKMLL::FeatureEncoder2::FeatureEncoder2(), KKMLL::Model::GetFeatureNums(), KKMLL::TrainingConfiguration2::GetFeatureNums(), KKMLL::ModelParamOldSVM::ReadXML(), KKMLL::Model::SelectedFeatures(), and KKMLL::ModelSvmBase::TrainModel().
|
virtual |
Definition at line 109 of file ModelParam.cpp.
References KKMLL::FeatureNumList::FeatureNumList().
Referenced by KKMLL::ModelParamOldSVM::SelectedFeatures(), and KKMLL::TrainingConfiguration2::SetFeatureNums().
|
virtual |
Creates a a Command Line String that represents these parameters.
Convert all parameters to a command line string.
All derived classes should implement this method. They should first call this method and then append there own parameters that are specific to their implementation.
Reimplemented in KKMLL::ModelParamOldSVM, KKMLL::ModelParamDual, KKMLL::ModelParamUsfCasCor, and KKMLL::ModelParamSvmBase.
Definition at line 367 of file ModelParam.cpp.
References KKB::KKStr::Concat(), EncodingMethodToStr(), KKB::KKStr::KKStr(), NoEncoding, KKB::operator+(), and KKMLL::FeatureNumList::ToCommaDelStr().
Referenced by KKMLL::TrainingConfiguration2::ModelParameterCmdLine(), KKMLL::ModelParamKnn::ToCmdLineStr(), KKMLL::ModelParamSvmBase::ToCmdLineStr(), and KKMLL::ModelParamDual::ToCmdLineStr().
|
inlinevirtual |
Definition at line 117 of file ModelParam.h.
Referenced by KKMLL::Model::ReadXMLModelPost(), and KKMLL::TrainingConfiguration2::TrainingConfiguration2().
|
inlinevirtual |
Definition at line 132 of file ModelParam.h.
Referenced by KKMLL::ModelParamOldSVM::ParseCmdLine().
|
pure virtual |
Implemented in KKMLL::ModelParamOldSVM.
Referenced by KKMLL::Model::WriteModelXMLFields(), and KKMLL::TrainingConfiguration2::WriteXMLFields().
| void ModelParam::WriteXMLFields | ( | std::ostream & | o | ) | const |
Definition at line 464 of file ModelParam.cpp.
References EncodingMethodToStr(), KKMLL::FeatureNumList::WriteXML(), KKB::XmlElementBool::WriteXML(), and KKB::KKStr::WriteXML().
Referenced by KKMLL::ModelParamKnn::WriteXML(), KKMLL::ModelParamSvmBase::WriteXML(), KKMLL::ModelParamUsfCasCor::WriteXML(), KKMLL::ModelParamDual::WriteXML(), and KKMLL::ModelParamOldSVM::WriteXML().