![]() |
KSquare Utilities
|
This class encapsulates are the information necessary to build a SVMModel class. More...
#include <SVMparam.h>
Public Member Functions | |
| SVMparam (KKStr &_cmdLineStr, FeatureNumListConstPtr _selectedFeatures, bool &_validFormat, RunLog &_log) | |
| SVMparam () | |
| SVMparam (const SVMparam &_svmParam) | |
| ~SVMparam () | |
| float | A_Param () const |
| void | A_Param (float _A) |
| void | AddBinaryClassParms (BinaryClassParmsPtr binaryClassParms) |
| void | AddBinaryClassParms (MLClassPtr _class1, MLClassPtr _class2, const svm_parameter &_param, FeatureNumListConstPtr _selectedFeatures, float _weight) |
| Adding parameters that are specific to a class pair; this is used when using the BFS version of SVM. More... | |
| float | AvgMumOfFeatures (FileDescPtr fileDesc) const |
| float | AvgNumOfFeatures (FeatureVectorListPtr trainExamples) const |
| Returns back the class weighted average number of features per training example. More... | |
| const BinaryClassParmsListPtr | BinaryParmsList () const |
| double | C_Param () const |
| double | C_Param (MLClassPtr class1, MLClassPtr class2) const |
| void | C_Param (double _CC) |
| void | C_Param (MLClassPtr class1, MLClassPtr class2, double cParam) |
| SVM_EncodingMethod | EncodingMethod () const |
| void | EncodingMethod (SVM_EncodingMethod _encodingMethod) |
| float | FeatureCountNet () const |
| double | Gamma () const |
| void | Gamma (double _gamma) |
| void | Gamma_Param (double _gamma) |
| BinaryClassParmsPtr | GetBinaryClassParms (MLClassPtr class1, MLClassPtr class2) |
| FeatureNumListConstPtr | GetFeatureNums () const |
| FeatureNumListConstPtr | GetFeatureNums (FileDescPtr fileDesc) const |
| FeatureNumListConstPtr | GetFeatureNums (FileDescPtr fileDesc, MLClassPtr class1, MLClassPtr class2) const |
| BinaryClassParmsPtr | GetParamtersToUseFor2ClassCombo (MLClassPtr class1, MLClassPtr class2) |
| SVM_KernalType | KernalType () const |
| void | KernalType (SVM_KernalType _kernalType) |
| SVM_MachineType | MachineType () const |
| void | MachineType (SVM_MachineType _machineType) |
| kkint32 | MemoryConsumedEstimated () const |
| kkint32 | NumOfFeaturesAfterEncoding (FileDescPtr fileDesc, RunLog &log) const |
| const svm_parameter & | Param () const |
| void | ParseCmdLineParameter (const KKStr ¶meter, const KKStr &value, bool ¶meterUsed, bool &_validFormat, RunLog &log) |
| const VectorFloat & | ProbClassPairs () const |
| void | ProbClassPairsInitialize (const ClassAssignments &assignments) |
| void | ProcessSvmParameter (svm_parameter &_param, KKStr cmd, KKStr value, double valueNum, bool &parmUsed) |
| virtual void | ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log) |
| float | SamplingRate () const |
| void | SamplingRate (float _samplingRate) |
| FeatureNumListConstPtr | SelectedFeatures () const |
| FeatureNumListConstPtr | SelectedFeatures (FileDescPtr fileDesc) const |
| void | SelectedFeatures (FeatureNumListConst &_selectedFeatures) |
| void | SelectedFeatures (FeatureNumListConstPtr _selectedFeatures) |
| SVM_SelectionMethod | SelectionMethod () const |
| void | SelectionMethod (SVM_SelectionMethod _selectionMethod) |
| void | SetBinaryClassFields (MLClassPtr _class1, MLClassPtr _class2, const svm_parameter &_param, FeatureNumListConstPtr _features, float _weight) |
| void | SetFeatureNums (FeatureNumListConstPtr _features) |
| void | SetFeatureNums (FeatureNumListConst &_features) |
| void | SetFeatureNums (MLClassPtr _class1, MLClassPtr _class2, FeatureNumListConstPtr _features, float _weight=-1) |
| Sets the selected Features and Weight for the binary class SVM specified by _class1 and _class2. More... | |
| KKStr | SvmParamToString (const svm_parameter &_param) const |
| Convert a svm_parameter struct to a cmdline str. More... | |
| KKStr | ToString () const |
| Convert all parameters to a command line string. More... | |
| bool | UseProbabilityToBreakTies () const |
| virtual void | WriteXML (const KKStr &varName, std::ostream &o) const |
This class encapsulates are the information necessary to build a SVMModel class.
Definition at line 74 of file SVMparam.h.
| SVMparam::SVMparam | ( | KKStr & | _cmdLineStr, |
| FeatureNumListConstPtr | _selectedFeatures, | ||
| bool & | _validFormat, | ||
| RunLog & | _log | ||
| ) |
| _selectedFeatures | Will make own instance; caller maintains ownership status. |
Definition at line 29 of file SVMparam.cpp.
References KKMLL::FeatureNumList::FeatureNumList(), KKB::KKStr::KKStr(), KKMLL::NoEncoding, SVM233::svm_parameter::svm_parameter(), and KKMLL::Voting.
Referenced by KKMLL::ModelParamOldSVM::ReadXML().
| SVMparam::SVMparam | ( | ) |
Definition at line 55 of file SVMparam.cpp.
References KKB::KKStr::KKStr(), KKMLL::NoEncoding, KKMLL::OneVsOne, SVM233::svm_parameter::svm_parameter(), and KKMLL::Voting.
Referenced by KKMLL::ModelParamOldSVM::ModelParamOldSVM(), and KKMLL::SVMModel::SVMModel().
| SVMparam::SVMparam | ( | const SVMparam & | _svmParam | ) |
Definition at line 75 of file SVMparam.cpp.
References KKMLL::BinaryClassParmsList::DuplicateListAndContents(), KKMLL::FeatureNumList::FeatureNumList(), KKB::KKStr::KKStr(), SVM233::svm_parameter::operator=(), and SVM233::svm_parameter::svm_parameter().
Referenced by KKMLL::ModelParamOldSVM::ModelParamOldSVM(), and KKMLL::SVMModel::SVMModel().
| SVMparam::~SVMparam | ( | ) |
Definition at line 104 of file SVMparam.cpp.
|
inline |
Definition at line 132 of file SVMparam.h.
References SVM233::svm_parameter::A.
Referenced by KKMLL::ModelParamOldSVM::A_Param(), and KKMLL::ModelParamOldSVM::ParseCmdLine().
| void SVMparam::A_Param | ( | float | _A | ) |
Definition at line 187 of file SVMparam.cpp.
References SVM233::svm_parameter::A.
Referenced by KKMLL::ModelParamOldSVM::A_Param().
| void SVMparam::AddBinaryClassParms | ( | BinaryClassParmsPtr | binaryClassParms | ) |
Definition at line 475 of file SVMparam.cpp.
References KKMLL::BinaryClassParmsList::BinaryClassParmsList(), and KKMLL::BinaryClassParmsList::PushOnBack().
Referenced by KKMLL::ModelParamOldSVM::AddBinaryClassParms(), and AddBinaryClassParms().
| void SVMparam::AddBinaryClassParms | ( | MLClassPtr | _class1, |
| MLClassPtr | _class2, | ||
| const svm_parameter & | _param, | ||
| FeatureNumListConstPtr | _selectedFeatures, | ||
| float | _weight | ||
| ) |
Adding parameters that are specific to a class pair; this is used when using the BFS version of SVM.
Add a Binary parameters using svm_parametr cmd line str. Typically used by TrainingConfiguration.
| _class1 | First of two classes that is being added to this model. |
| _class2 | Second of two classes that is being added to this model. |
| _param | Parameters that are to be used by two-class classifier. |
| _selectedFeatures | makes own copy; caller will retain ownership status. |
| _weight | You can specify the weight that you want to give to this binary-class SVM when voting or computing probability. |
Definition at line 756 of file SVMparam.cpp.
References AddBinaryClassParms(), and KKMLL::BinaryClassParms::BinaryClassParms().
Referenced by KKMLL::ModelParamOldSVM::AddBinaryClassParms(), C_Param(), SetBinaryClassFields(), and SetFeatureNums().
| float SVMparam::AvgMumOfFeatures | ( | FileDescPtr | fileDesc | ) | const |
Definition at line 485 of file SVMparam.cpp.
References KKMLL::BinaryCombos, KKMLL::BinaryClassParmsList::FeatureCountNet(), KKMLL::FeatureNumList::NumOfFeatures(), and SelectedFeatures().
Referenced by KKMLL::ModelParamOldSVM::AvgMumOfFeatures().
| float SVMparam::AvgNumOfFeatures | ( | FeatureVectorListPtr | trainExamples | ) | const |
Returns back the class weighted average number of features per training example.
Will calculate the average number of features per training example. For each binary class combination, multiplies the number of training examples for that pair by the number of features for that pair. the sum of all class pairs are then divided by the total number of examples.
| [in] | trainExamples | List of training examples that were or are to be used to train with. |
Definition at line 508 of file SVMparam.cpp.
References KKMLL::BinaryCombos, KKMLL::ClassStatistic::Count(), KKMLL::FeatureVectorList::FileDesc(), KKMLL::FeatureVectorList::GetClassStatistics(), GetFeatureNums(), KKMLL::ClassStatistic::MLClass(), KKMLL::FeatureNumList::NumOfFeatures(), KKMLL::FeatureNumList::NumSelFeatures(), and SelectedFeatures().
Referenced by KKMLL::TrainingConfiguration2::AvgNumOfFeatures().
|
inline |
Definition at line 135 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::BinaryParmsList().
|
inline |
Definition at line 137 of file SVMparam.h.
References SVM233::svm_parameter::C.
Referenced by KKMLL::ModelParamOldSVM::C_Param(), C_Param(), KKMLL::ModelParamOldSVM::ParseCmdLine(), and KKMLL::SVMModel::ReadXML().
| double SVMparam::C_Param | ( | MLClassPtr | class1, |
| MLClassPtr | class2 | ||
| ) | const |
Definition at line 663 of file SVMparam.cpp.
References KKMLL::BinaryClassParms::C(), and KKMLL::BinaryClassParmsList::LookUp().
| void SVMparam::C_Param | ( | double | _CC | ) |
Definition at line 195 of file SVMparam.cpp.
References SVM233::svm_parameter::C.
Referenced by KKMLL::ModelParamOldSVM::C_Param().
| void SVMparam::C_Param | ( | MLClassPtr | class1, |
| MLClassPtr | class2, | ||
| double | cParam | ||
| ) |
Definition at line 692 of file SVMparam.cpp.
References AddBinaryClassParms(), SVM233::svm_parameter::C, KKMLL::BinaryClassParms::C(), C_Param(), KKMLL::BinaryClassParmsList::LookUp(), and SelectedFeatures().
|
inline |
Definition at line 143 of file SVMparam.h.
Referenced by KKMLL::TrainingConfiguration2::EncodingMethod(), KKMLL::SVMModel::NormalizeNominalAttributes(), NumOfFeaturesAfterEncoding(), KKMLL::ModelParamOldSVM::ParseCmdLine(), and KKMLL::SVMModel::ReadXML().
|
inline |
Definition at line 182 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::EncodingMethod().
| float KKMLL::SVMparam::FeatureCountNet | ( | ) | const |
|
inline |
Definition at line 147 of file SVMparam.h.
References SVM233::svm_parameter::Gamma().
Referenced by KKMLL::ModelParamOldSVM::Gamma(), and KKMLL::ModelParamOldSVM::ParseCmdLine().
|
inline |
Definition at line 183 of file SVMparam.h.
References SVM233::svm_parameter::Gamma().
Referenced by KKMLL::ModelParamOldSVM::Gamma(), KKMLL::ModelParamOldSVM::Gamma_Param(), and Gamma_Param().
|
inline |
| BinaryClassParmsPtr SVMparam::GetBinaryClassParms | ( | MLClassPtr | class1, |
| MLClassPtr | class2 | ||
| ) |
If binary class parms don't exist will return NULL.
Definition at line 423 of file SVMparam.cpp.
References KKMLL::BinaryClassParmsList::LookUp().
Referenced by KKMLL::ModelParamOldSVM::GetBinaryClassParms(), and KKMLL::TrainingConfiguration2::GetBinaryClassParms().
| FeatureNumListConstPtr SVMparam::GetFeatureNums | ( | ) | const |
Definition at line 436 of file SVMparam.cpp.
Referenced by KKMLL::SVMModel::GetFeatureNums().
| FeatureNumListConstPtr SVMparam::GetFeatureNums | ( | FileDescPtr | fileDesc | ) | const |
Definition at line 443 of file SVMparam.cpp.
References SelectedFeatures().
Referenced by KKMLL::SVMModel::GetFeatureNums().
| FeatureNumListConstPtr SVMparam::GetFeatureNums | ( | FileDescPtr | fileDesc, |
| MLClassPtr | class1, | ||
| MLClassPtr | class2 | ||
| ) | const |
Definition at line 453 of file SVMparam.cpp.
References KKMLL::BinaryClassParmsList::LookUp(), SelectedFeatures(), and KKMLL::BinaryClassParms::SelectedFeaturesFD().
Referenced by AvgNumOfFeatures(), KKMLL::ModelParamOldSVM::GetFeatureNums(), and KKMLL::SVMModel::GetFeatureNums().
| BinaryClassParmsPtr SVMparam::GetParamtersToUseFor2ClassCombo | ( | MLClassPtr | class1, |
| MLClassPtr | class2 | ||
| ) |
Definition at line 394 of file SVMparam.cpp.
References KKMLL::BinaryClassParms::BinaryClassParms(), KKMLL::BinaryClassParmsList::BinaryClassParmsList(), KKMLL::BinaryClassParmsList::LookUp(), and KKMLL::BinaryClassParmsList::PushOnBack().
Referenced by KKMLL::ModelParamOldSVM::GetParamtersToUseFor2ClassCombo(), and KKMLL::TrainingConfiguration2::GetParamtersToUseFor2ClassCombo().
|
inline |
Definition at line 149 of file SVMparam.h.
References SVM233::svm_parameter::KernalType().
Referenced by KKMLL::ModelParamOldSVM::KernalType(), and KKMLL::TrainingConfiguration2::KernalType().
|
inline |
Definition at line 185 of file SVMparam.h.
References SVM233::svm_parameter::KernalType().
Referenced by KKMLL::ModelParamOldSVM::KernalType(), and KKMLL::TrainingConfiguration2::KernalType().
|
inline |
Definition at line 151 of file SVMparam.h.
Referenced by KKMLL::ModelOldSVM::Description(), KKMLL::SVMModel::DistanceFromDecisionBoundary(), KKMLL::ModelParamOldSVM::MachineType(), KKMLL::SVMModel::NumOfSupportVectors(), KKMLL::SVMModel::Predict(), KKMLL::SVMModel::ProbabilitiesByClass(), KKMLL::SVMModel::ReadXML(), KKMLL::SVMModel::SupportVectorStatistics(), KKMLL::SVMModel::SVMModel(), and KKMLL::SVMModel::WriteXML().
|
inline |
Definition at line 187 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::MachineType().
| kkint32 SVMparam::MemoryConsumedEstimated | ( | ) | const |
Definition at line 124 of file SVMparam.cpp.
References KKMLL::BinaryClassParmsList::MemoryConsumedEstimated(), KKMLL::FeatureNumList::MemoryConsumedEstimated(), and KKB::KKStr::MemoryConsumedEstimated().
| kkint32 SVMparam::NumOfFeaturesAfterEncoding | ( | FileDescPtr | fileDesc, |
| RunLog & | log | ||
| ) | const |
Definition at line 567 of file SVMparam.cpp.
References KKMLL::Binary, KKMLL::FileDesc::Cardinality(), EncodingMethod(), KKMLL::NoEncoding, KKMLL::Nominal, KKMLL::FeatureNumList::NumOfFeatures(), KKMLL::FeatureNumList::operator[](), KKMLL::Scaled, SelectedFeatures(), KKMLL::Symbolic, and KKMLL::FileDesc::Type().
Referenced by KKMLL::ModelParamOldSVM::NumOfFeaturesAfterEncoding().
|
inline |
Definition at line 159 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::Param(), and KKMLL::SvmPredictClass().
| void SVMparam::ParseCmdLineParameter | ( | const KKStr & | parameter, |
| const KKStr & | value, | ||
| bool & | parameterUsed, | ||
| bool & | _validFormat, | ||
| RunLog & | log | ||
| ) |
Definition at line 202 of file SVMparam.cpp.
References KKB::KKStr::Concat(), KKMLL::EncodingMethodFromStr(), KKB::KKStr::KKStr(), KKMLL::MachineTypeFromStr(), KKMLL::Null, KKB::KKStr::operator==(), SVM233::svm_parameter::ProcessSvmParameter(), KKMLL::SelectionMethodFromStr(), KKB::KKStr::ToDouble(), and KKB::KKStr::Upper().
|
inline |
Definition at line 161 of file SVMparam.h.
| void SVMparam::ProbClassPairsInitialize | ( | const ClassAssignments & | assignments | ) |
Definition at line 153 of file SVMparam.cpp.
References KKMLL::ClassAssignments::GetMLClass(), and KKMLL::BinaryClassParmsList::LookUp().
| void KKMLL::SVMparam::ProcessSvmParameter | ( | svm_parameter & | _param, |
| KKStr | cmd, | ||
| KKStr | value, | ||
| double | valueNum, | ||
| bool & | parmUsed | ||
| ) |
|
virtual |
Definition at line 815 of file SVMparam.cpp.
References KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::XmlStream::GetNextToken(), and KKB::XmlToken::VarName().
|
inline |
Definition at line 163 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::SamplingRate().
|
inline |
Definition at line 188 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::SamplingRate().
|
inline |
Definition at line 165 of file SVMparam.h.
Referenced by C_Param(), KKMLL::ModelParamOldSVM::SelectedFeatures(), and KKMLL::SVMModel::SVMModel().
| FeatureNumListConstPtr SVMparam::SelectedFeatures | ( | FileDescPtr | fileDesc | ) | const |
Definition at line 112 of file SVMparam.cpp.
References KKMLL::FeatureNumList::FeatureNumList(), and KKMLL::FeatureNumList::SetAllFeatures().
Referenced by AvgMumOfFeatures(), AvgNumOfFeatures(), GetFeatureNums(), and NumOfFeaturesAfterEncoding().
| void KKMLL::SVMparam::SelectedFeatures | ( | FeatureNumListConst & | _selectedFeatures | ) |
Referenced by KKMLL::ModelParamOldSVM::SelectedFeatures().
| void SVMparam::SelectedFeatures | ( | FeatureNumListConstPtr | _selectedFeatures | ) |
|
inline |
Definition at line 169 of file SVMparam.h.
Referenced by KKMLL::ModelOldSVM::Description(), KKMLL::ModelOldSVM::ProbabilitiesByClass(), KKMLL::ModelParamOldSVM::SelectionMethod(), KKMLL::SVMModel::SelectionMethod(), and KKMLL::SvmPredictClass().
|
inline |
Definition at line 218 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::SelectionMethod().
| void SVMparam::SetBinaryClassFields | ( | MLClassPtr | _class1, |
| MLClassPtr | _class2, | ||
| const svm_parameter & | _param, | ||
| FeatureNumListConstPtr | _features, | ||
| float | _weight | ||
| ) |
| _class1 | First of two classes that is being added to this model. |
| _class2 | Second of two classes that is being added to this model. |
| _param | Parameters that are to be used by two-class classifier. |
| _features | makes own copy; caller will retain ownership status. |
| _weight | You can specify the weight that you want to give to this binary-class SVM when voting or computing probability. |
Definition at line 721 of file SVMparam.cpp.
References AddBinaryClassParms(), KKMLL::BinaryClassParmsList::LookUp(), KKMLL::BinaryClassParms::Param(), KKMLL::BinaryClassParms::SelectedFeatures(), and KKMLL::BinaryClassParms::Weight().
Referenced by KKMLL::ModelParamOldSVM::SetBinaryClassFields().
| void SVMparam::SetFeatureNums | ( | FeatureNumListConstPtr | _features | ) |
| void KKMLL::SVMparam::SetFeatureNums | ( | FeatureNumListConst & | _features | ) |
| void SVMparam::SetFeatureNums | ( | MLClassPtr | _class1, |
| MLClassPtr | _class2, | ||
| FeatureNumListConstPtr | _features, | ||
| float | _weight = -1 |
||
| ) |
Sets the selected Features and Weight for the binary class SVM specified by _class1 and _class2.
If this pair has not been defined yet will create a new entry and add to list of Binary-Class-Pair's.
| _class1 | First of two classes to set features for. |
| _class2 | Second of two classes to set features for. |
| _features | Makes own copy; caller will retain ownership status. |
| _weight | -1 Indicates use existing value. |
Definition at line 614 of file SVMparam.cpp.
References AddBinaryClassParms(), KKMLL::BinaryClassParmsList::LookUp(), KKMLL::BinaryClassParms::SelectedFeatures(), and KKMLL::BinaryClassParms::Weight().
Referenced by KKMLL::ModelParamOldSVM::SetFeatureNums().
| KKStr SVMparam::SvmParamToString | ( | const svm_parameter & | _param | ) | const |
Convert a svm_parameter struct to a cmdline str.
Definition at line 353 of file SVMparam.cpp.
References KKB::KKStr::Concat(), KKB::KKStr::KKStr(), and SVM233::svm_parameter::ToCmdLineStr().
Referenced by ToString().
| KKStr SVMparam::ToString | ( | ) | const |
Convert all parameters to a command line string.
Definition at line 368 of file SVMparam.cpp.
References KKMLL::BoostSVM, KKB::KKStr::Concat(), KKMLL::EncodingMethodToStr(), KKB::KKStr::KKStr(), KKMLL::MachineTypeToStr(), KKMLL::NoEncoding, KKB::operator+(), KKB::KKStr::operator=(), KKMLL::SelectionMethodToStr(), and SvmParamToString().
Referenced by KKMLL::ModelParamOldSVM::ToCmdLineStr(), and KKMLL::ModelParamOldSVM::WriteXML().
|
inline |
Definition at line 171 of file SVMparam.h.
Referenced by KKMLL::ModelParamOldSVM::UseProbabilityToBreakTies().
|
virtual |
Definition at line 769 of file SVMparam.cpp.
References KKB::XmlElementKeyValuePairs::Add(), KKB::XmlTag::AddAtribute(), KKB::KKStr::Empty(), KKMLL::EncodingMethodToStr(), KKMLL::MachineTypeToStr(), KKMLL::SelectionMethodToStr(), KKB::XmlTag::tagEnd, KKB::XmlTag::tagStart, KKMLL::FeatureNumList::ToString(), SVM233::svm_parameter::ToTabDelStr(), KKMLL::BinaryClassParmsList::WriteXML(), KKB::XmlTag::WriteXML(), KKB::XmlElementKeyValuePairs::WriteXML(), KKB::XmlElementKeyValuePairs::XmlElementKeyValuePairs(), and KKB::XmlTag::XmlTag().
Referenced by KKMLL::SVMModel::WriteXML().