KSquare Utilities
KKMLL::SVMparam Class Reference

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_parameterParam () const
 
void ParseCmdLineParameter (const KKStr &parameter, const KKStr &value, bool &parameterUsed, bool &_validFormat, RunLog &log)
 
const VectorFloatProbClassPairs () 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
 

Detailed Description

This class encapsulates are the information necessary to build a SVMModel class.

See also
SVMModel
SVM233
BinaryClassParms

Definition at line 74 of file SVMparam.h.

Constructor & Destructor Documentation

SVMparam::SVMparam ( KKStr _cmdLineStr,
FeatureNumListConstPtr  _selectedFeatures,
bool &  _validFormat,
RunLog _log 
)
Parameters
_selectedFeaturesWill 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().

33  :
34 
35  binaryParmsList (NULL),
36  encodingMethod (SVM_EncodingMethod::NoEncoding),
37  fileName (),
38  param (),
39  probClassPairs (),
40  samplingRate (0.0f),
41  selectedFeatures (),
42  selectionMethod (SVM_SelectionMethod::Voting),
43  useProbabilityToBreakTies (false),
44  validParam (false)
45 {
46  if (_selectedFeatures)
47  selectedFeatures = new FeatureNumList (*_selectedFeatures);
48  ParseCmdLine (_cmdLineStr, _validFormat, _log);
49 }
Keeps track of selected features.
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().

55  :
56 
57  binaryParmsList (NULL),
58  encodingMethod (SVM_EncodingMethod::NoEncoding),
59  fileName (),
60  machineType (SVM_MachineType::OneVsOne),
61  param (),
62  probClassPairs (),
63  samplingRate (0.0f),
64  selectedFeatures (NULL),
65  selectionMethod (SVM_SelectionMethod::Voting),
66  useProbabilityToBreakTies (false),
67  validParam (false)
68 {
69 }
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().

75  :
76 
77  binaryParmsList (NULL),
78  encodingMethod (_svmParam.encodingMethod),
79  fileName (_svmParam.fileName),
80  machineType (_svmParam.machineType),
81  param (_svmParam.param),
82  probClassPairs (_svmParam.probClassPairs),
83  samplingRate (_svmParam.samplingRate),
84  selectedFeatures (_svmParam.selectedFeatures),
85  selectionMethod (_svmParam.selectionMethod),
86  useProbabilityToBreakTies (_svmParam.useProbabilityToBreakTies),
87  validParam (_svmParam.validParam)
88 {
89  if (_svmParam.selectedFeatures)
90  selectedFeatures = new FeatureNumList (*_svmParam.selectedFeatures);
91 
92  if (_svmParam.binaryParmsList)
93  {
94  binaryParmsList = _svmParam.binaryParmsList->DuplicateListAndContents ();
95 
96  // new BinaryClassParmsList (true, _svmParam.binaryParmsList->QueueSize ());
97  // binaryParmsList = new BinaryClassParmsList (*(_svmParam.binaryParmsList));
98  }
99  param = _svmParam.param;
100 }
Keeps track of selected features.
BinaryClassParmsList * DuplicateListAndContents() const
SVMparam::~SVMparam ( )

Definition at line 104 of file SVMparam.cpp.

105 {
106  delete binaryParmsList; binaryParmsList = NULL;
107  delete selectedFeatures; selectedFeatures = NULL;
108 }

Member Function Documentation

float KKMLL::SVMparam::A_Param ( ) const
inline

Definition at line 132 of file SVMparam.h.

References SVM233::svm_parameter::A.

Referenced by KKMLL::ModelParamOldSVM::A_Param(), and KKMLL::ModelParamOldSVM::ParseCmdLine().

132 {return param.A;}
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().

188 {
189  param.A = _A;
190 }
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().

476 {
477  if (!binaryParmsList)
478  binaryParmsList = new BinaryClassParmsList (true);
479 
480  binaryParmsList->PushOnBack (binaryClassParms);
481 } /* AddBinaryClassParms */
virtual void PushOnBack(BinaryClassParmsPtr binaryParms)
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.

Parameters
_class1First of two classes that is being added to this model.
_class2Second of two classes that is being added to this model.
_paramParameters that are to be used by two-class classifier.
_selectedFeaturesmakes own copy; caller will retain ownership status.
_weightYou 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().

762 {
763  AddBinaryClassParms (new BinaryClassParms (_class1, _class2, _param, _selectedFeatures, _weight));
764 } /* AddBinaryClassParms */
Similar to SVMparam except it is specialized for two classes.
void AddBinaryClassParms(BinaryClassParmsPtr binaryClassParms)
Definition: SVMparam.cpp:475
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().

486 {
487  float avgNumOfFeatures = 0.0f;
488 
489  if ((machineType == SVM_MachineType::BinaryCombos) && (binaryParmsList))
490  avgNumOfFeatures = binaryParmsList->FeatureCountNet (fileDesc);
491 
492  if (avgNumOfFeatures == 0.0f)
493  avgNumOfFeatures = (float)SelectedFeatures (fileDesc)->NumOfFeatures ();
494 
495  return avgNumOfFeatures;
496 } /* AvgMumOfFeatures */
FeatureNumListConstPtr SelectedFeatures() const
Definition: SVMparam.h:165
float FeatureCountNet(FileDescPtr fileDesc) const
Returns the Average number of selected features.
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.

Parameters
[in]trainExamplesList 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().

509 {
510  FileDescPtr fileDesc = trainExamples->FileDesc ();
511  if (!selectedFeatures)
512  {
513  // The method "SelectedFeatures" will set 'selectedFeatures' to a new instance using 'fileDesc'.
514  // This way we make sure that the variable exists.
515  SelectedFeatures (fileDesc);
516  }
517  if (machineType == SVM_MachineType::BinaryCombos)
518  {
519  kkint32 totalNumFeaturesUsed = 0;
520  kkint32 toatlNumExamples = 0;
521  ClassStatisticListPtr stats = trainExamples->GetClassStatistics ();
522  if (!stats)
523  {
524  return (float)selectedFeatures->NumOfFeatures ();
525  }
526 
527  kkuint32 idx1 = 0;
528  kkuint32 idx2 = 0;
529  for (idx1 = 0; idx1 < (stats->size() - 1); idx1++)
530  {
531  ClassStatisticPtr class1Stats = stats->IdxToPtr (idx1);
532  MLClassPtr class1 = class1Stats->MLClass ();
533  kkuint32 class1Qty = class1Stats->Count ();
534 
535  for (idx2 = idx1 + 1; idx2 < (stats->size()); idx2++)
536  {
537  ClassStatisticPtr class2Stats = stats->IdxToPtr (idx2);
538  MLClassPtr class2 = class2Stats->MLClass ();
539  kkuint32 class2Qty = class2Stats->Count ();
540 
541  kkint32 numFeaturesThisCombo = 0;
542  FeatureNumListConstPtr cpfn = GetFeatureNums (fileDesc, class1, class2);
543  if (cpfn)
544  numFeaturesThisCombo = cpfn->NumSelFeatures ();
545 
546  kkint32 numExamplesThisCombo = class1Qty + class2Qty;
547 
548  totalNumFeaturesUsed += numFeaturesThisCombo * numExamplesThisCombo;
549  toatlNumExamples += numExamplesThisCombo;
550  }
551  }
552  delete stats; stats = NULL;
553  return (float)totalNumFeaturesUsed / (float)toatlNumExamples;
554  }
555  else if (!selectedFeatures)
556  {
557  return 0.0f;
558  }
559  else
560  {
561  return (float)selectedFeatures->NumOfFeatures ();
562  }
563 } /* AvgMumOfFeatures */
Provides a detailed description of the attributes of a dataset.
Definition: FileDesc.h:72
__int32 kkint32
Definition: KKBaseTypes.h:88
FeatureNumListConstPtr SelectedFeatures() const
Definition: SVMparam.h:165
MLClassPtr MLClass() const
Represents a "Class" in the Machine Learning Sense.
Definition: MLClass.h:52
const FileDescPtr FileDesc() const
EntryPtr IdxToPtr(kkuint32 idx) const
Definition: KKQueue.h:732
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkuint32 Count() const
kkint32 NumOfFeatures() const
FeatureNumListConstPtr GetFeatureNums() const
Definition: SVMparam.cpp:436
ClassStatisticListPtr GetClassStatistics() const
Returns the number of FeatureVectors per class.
Used by routines that retrieve Class statistics from FeatureVectorList instances. ...
FeatureNumListConst * FeatureNumListConstPtr
const BinaryClassParmsListPtr KKMLL::SVMparam::BinaryParmsList ( ) const
inline

Definition at line 135 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::BinaryParmsList().

135 {return binaryParmsList;}
double KKMLL::SVMparam::C_Param ( ) const
inline
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().

666 {
667  if (!binaryParmsList)
668  {
669  cerr << endl << endl
670  << "SVMparam::C_Param ***ERROR*** 'binaryParmsList' is not defined." << endl
671  << endl;
672  return 0.0;
673  }
674 
675  BinaryClassParmsPtr binaryParms = binaryParmsList->LookUp (class1, class2);
676  if (!binaryParms)
677  {
678  cerr << endl << endl
679  << "SVMparam::C_Param ***ERROR*** No entry for Class[" << class1->Name () << ", " << class2->Name () << "]" << endl
680  << endl;
681  return 0.0;
682  }
683  else
684  {
685  return binaryParms->C ();
686  }
687 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
Similar to SVMparam except it is specialized for two classes.
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
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().

196 {
197  param.C = _CC;
198 }
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().

696 {
697  if (!binaryParmsList)
698  {
699  cerr << endl << endl
700  << "SVMparam::C_Param ***ERROR*** 'binaryParmsList' is not defined." << endl
701  << endl;
702  return;
703  }
704 
705  BinaryClassParmsPtr binaryParms = binaryParmsList->LookUp (class1, class2);
706  if (!binaryParms)
707  {
708  svm_parameter binaryParam = param;
709  binaryParam.C = C_Param ();
710  AddBinaryClassParms (class1, class2, binaryParam, SelectedFeatures (), 1.0f);
711  }
712  else
713  {
714  binaryParms->C (cParam);
715  }
716 } /* C_Param */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
FeatureNumListConstPtr SelectedFeatures() const
Definition: SVMparam.h:165
Similar to SVMparam except it is specialized for two classes.
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
void AddBinaryClassParms(BinaryClassParmsPtr binaryClassParms)
Definition: SVMparam.cpp:475
double C_Param() const
Definition: SVMparam.h:137
void KKMLL::SVMparam::EncodingMethod ( SVM_EncodingMethod  _encodingMethod)
inline

Definition at line 182 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::EncodingMethod().

182 {encodingMethod = _encodingMethod;}
float KKMLL::SVMparam::FeatureCountNet ( ) const
double KKMLL::SVMparam::Gamma ( ) const
inline

Definition at line 147 of file SVMparam.h.

References SVM233::svm_parameter::Gamma().

Referenced by KKMLL::ModelParamOldSVM::Gamma(), and KKMLL::ModelParamOldSVM::ParseCmdLine().

147 {return param.Gamma ();}
void Gamma(double _gamma)
Definition: svm.h:114
void KKMLL::SVMparam::Gamma ( double  _gamma)
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().

183 {param.Gamma (_gamma);}
void Gamma(double _gamma)
Definition: svm.h:114
void KKMLL::SVMparam::Gamma_Param ( double  _gamma)
inline

Definition at line 184 of file SVMparam.h.

References Gamma().

184 {Gamma (_gamma);}
double Gamma() const
Definition: SVMparam.h:147
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().

426 {
427  if (binaryParmsList == NULL)
428  return NULL;
429  else
430  return binaryParmsList->LookUp (class1, class2);
431 } /* GetBinaryClassParms */
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
FeatureNumListConstPtr SVMparam::GetFeatureNums ( ) const

Definition at line 436 of file SVMparam.cpp.

Referenced by KKMLL::SVMModel::GetFeatureNums().

437 {
438  return selectedFeatures;
439 }
FeatureNumListConstPtr SVMparam::GetFeatureNums ( FileDescPtr  fileDesc) const

Definition at line 443 of file SVMparam.cpp.

References SelectedFeatures().

Referenced by KKMLL::SVMModel::GetFeatureNums().

444 {
445  if (selectedFeatures == NULL)
446  return SelectedFeatures (fileDesc);
447  else
448  return selectedFeatures;
449 }
FeatureNumListConstPtr SelectedFeatures() const
Definition: SVMparam.h:165
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().

457 {
458  if (!binaryParmsList)
459  {
460  // This configuration file does not specify feature selection by binary classes,
461  // so return the general one specified for model.
462  return SelectedFeatures (fileDesc);
463  }
464 
465  BinaryClassParmsPtr twoClassComboParm = binaryParmsList->LookUp (class1, class2);
466  if (!twoClassComboParm)
467  return SelectedFeatures (fileDesc);
468  else
469  return twoClassComboParm->SelectedFeaturesFD (fileDesc);
470 } /* GetFeatureNums */
FeatureNumListConstPtr SelectedFeatures() const
Definition: SVMparam.h:165
Similar to SVMparam except it is specialized for two classes.
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
FeatureNumListConstPtr SelectedFeaturesFD(FileDescPtr fileDesc) const
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().

397 {
398  BinaryClassParmsPtr twoClassComboParms = NULL;
399 
400  if (binaryParmsList == NULL)
401  {
402  binaryParmsList = new BinaryClassParmsList (true);
403  twoClassComboParms = NULL;
404  }
405  else
406  {
407  twoClassComboParms = binaryParmsList->LookUp (class1, class2);
408  }
409 
410  if (!twoClassComboParms)
411  {
412  twoClassComboParms = new BinaryClassParms (class1, class2, param, selectedFeatures, 1.0f);
413  binaryParmsList->PushOnBack (twoClassComboParms);
414  }
415 
416  return twoClassComboParms;
417 } /* GetParamtersToUSeFor2ClassCombo */
Similar to SVMparam except it is specialized for two classes.
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
virtual void PushOnBack(BinaryClassParmsPtr binaryParms)
SVM_KernalType KKMLL::SVMparam::KernalType ( ) const
inline

Definition at line 149 of file SVMparam.h.

References SVM233::svm_parameter::KernalType().

Referenced by KKMLL::ModelParamOldSVM::KernalType(), and KKMLL::TrainingConfiguration2::KernalType().

149 {return (SVM_KernalType)param.KernalType ();}
SVM_KernalType
Definition: SVMparam.h:54
void KernalType(kkint32 _kernalType)
Definition: svm.h:115
void KKMLL::SVMparam::KernalType ( SVM_KernalType  _kernalType)
inline

Definition at line 185 of file SVMparam.h.

References SVM233::svm_parameter::KernalType().

Referenced by KKMLL::ModelParamOldSVM::KernalType(), and KKMLL::TrainingConfiguration2::KernalType().

185 {param.KernalType ((int)_kernalType);}
void KernalType(kkint32 _kernalType)
Definition: svm.h:115
void KKMLL::SVMparam::MachineType ( SVM_MachineType  _machineType)
inline

Definition at line 187 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::MachineType().

187 {machineType = _machineType;}
kkint32 SVMparam::MemoryConsumedEstimated ( ) const

Definition at line 124 of file SVMparam.cpp.

References KKMLL::BinaryClassParmsList::MemoryConsumedEstimated(), KKMLL::FeatureNumList::MemoryConsumedEstimated(), and KKB::KKStr::MemoryConsumedEstimated().

125 {
126  kkint32 memoryConsumedEstimated = sizeof (SVMparam) + fileName.MemoryConsumedEstimated ();
127  if (selectedFeatures)
128  memoryConsumedEstimated += selectedFeatures->MemoryConsumedEstimated ();
129 
130  if (binaryParmsList)
131  memoryConsumedEstimated += binaryParmsList->MemoryConsumedEstimated ();
132 
133  return memoryConsumedEstimated;
134 } /* MemoryConsumedEstimated */
kkint32 MemoryConsumedEstimated() const
Definition: KKStr.cpp:766
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 MemoryConsumedEstimated() const
kkint32 MemoryConsumedEstimated() const
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().

570 {
571  if (!selectedFeatures)
572  {
573  // The method "SelectedFeatures" will set 'selectedFeatures' to a new instance using 'fileDesc'.
574  // This way we make sure that the variable exists.
575  SelectedFeatures (fileDesc);
576  }
577 
578  if (!selectedFeatures)
579  return 0;
580 
581  kkint32 z;
582  kkint32 numFeaturesAfterEncoding = 0;
583  kkint32 numOfFeaturesSelected = selectedFeatures->NumOfFeatures ();
584 
585  switch (EncodingMethod ())
586  {
588  for (z = 0; z < numOfFeaturesSelected; z++)
589  {
590  kkint32 fieldNum = (*selectedFeatures)[z];
591  if ((fileDesc->Type (fieldNum) == AttributeType::Nominal) ||
592  (fileDesc->Type (fieldNum) == AttributeType::Symbolic)
593  )
594  numFeaturesAfterEncoding += fileDesc->Cardinality (fieldNum);
595  else
596  numFeaturesAfterEncoding ++;
597  }
598  break;
599 
602  default:
603  //numFeaturesAfterEncoding = fileDesc->NumOfFields ( );
604  numFeaturesAfterEncoding = selectedFeatures->NumOfFeatures ();
605  break;
606  }
607 
608  return numFeaturesAfterEncoding;
609 } /* NumOfFeaturesAfterEncoding */
__int32 kkint32
Definition: KKBaseTypes.h:88
FeatureNumListConstPtr SelectedFeatures() const
Definition: SVMparam.h:165
KKMLL::AttributeType Type(kkint32 fieldNum) const
Definition: FileDesc.cpp:370
SVM_EncodingMethod EncodingMethod() const
Definition: SVMparam.h:143
kkint32 NumOfFeatures() const
kkint32 Cardinality(kkint32 fieldNum) const
Definition: FileDesc.cpp:341
const svm_parameter& KKMLL::SVMparam::Param ( ) const
inline

Definition at line 159 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::Param(), and KKMLL::SvmPredictClass().

159 {return param;}
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().

208 {
209  parameterUsed = true;
210  _validFormat = true;
211 
212  KKStr field = parameter;
213  double valueNum = value.ToDouble ();
214 
215  field.Upper ();
216  KKStr valueUpper (value);
217  valueUpper.Upper ();
218 
219  param.ProcessSvmParameter (parameter,value, valueNum, parameterUsed);
220  if (parameterUsed)
221  return;
222 
223  parameterUsed = true;
224 
225  if ((field == "-ENCODE"))
226  {
227  encodingMethod = EncodingMethodFromStr (valueUpper);
228  }
229 
230  else if (field == "-MT")
231  {
232  machineType = MachineTypeFromStr (valueUpper);
233  if (machineType == SVM_MachineType::Null)
234  {
235  _validFormat = false;
236  log.Level (-1) << endl
237  << "SVMparam::ParseCmdLineParameter *** ERROR ***" << endl
238  << " Invalid -MT Parm[" << value << "]" << endl
239  << endl;
240  }
241  }
242 
243  else if ((field == "-SM") || (field == "-SELECTIONMETHOD"))
244  {
245  selectionMethod = SelectionMethodFromStr (valueUpper);
246  if (selectionMethod == SVM_SelectionMethod::Null)
247  {
248  log.Level (-1) << endl
249  << "SVMparam::ParseCmdLineParameter *** ERROR ***" << endl
250  << " Invalid SelectionMethod (-SM)[" << value << "]." << endl
251  << endl;
252  _validFormat = false;
253  }
254  }
255 
256  else if ((field == "-SR") || (field == "-SAMPLINGRATE"))
257  {
258  samplingRate = float (atof (value.Str ()));
259  }
260 
261 
262  else if ((field == "-UP") || (field == "-USEPROBABILITY"))
263  {
264  useProbabilityToBreakTies = true;
265  }
266 
267 
268  else
269  {
270  parameterUsed = false;
271  }
272 } /* ParseCmdLineParameter */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
SVM_EncodingMethod EncodingMethodFromStr(const KKStr &encodingMethodStr)
Definition: SVMparam.cpp:899
SVM_MachineType MachineTypeFromStr(const KKStr &machineTypeStr)
Definition: SVMparam.cpp:986
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
void Upper()
Converts all characters in string to their Upper case equivalents via &#39;toupper&#39;.
Definition: KKStr.cpp:2461
SVM_SelectionMethod SelectionMethodFromStr(const KKStr &selectionMethodStr)
Definition: SVMparam.cpp:1022
double ToDouble() const
Definition: KKStr.cpp:3541
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
void ProcessSvmParameter(KKStr cmd, KKStr value, double valueNum, bool &parmUsed)
Definition: svm.cpp:900
const VectorFloat& KKMLL::SVMparam::ProbClassPairs ( ) const
inline

Definition at line 161 of file SVMparam.h.

161 {return probClassPairs;}
void SVMparam::ProbClassPairsInitialize ( const ClassAssignments assignments)

Definition at line 153 of file SVMparam.cpp.

References KKMLL::ClassAssignments::GetMLClass(), and KKMLL::BinaryClassParmsList::LookUp().

154 {
155  kkuint32 numClasses = assignments.size ();
156  if (numClasses < 1)
157  return;
158 
159  kkuint32 numPairs = numClasses * (numClasses - 1) / 2;
160  probClassPairs.clear ();
161  if (binaryParmsList == NULL)
162  {
163  for (kkuint32 x = 0; x < numPairs; ++x)
164  probClassPairs.push_back (param.A);
165  }
166  else
167  {
168  for (kkuint32 class1IDX = 0; class1IDX < (numClasses - 1); ++class1IDX)
169  {
170  MLClassPtr class1 = assignments.GetMLClass ((kkint16)class1IDX);
171  for (kkuint32 class2IDX = class1IDX + 1; class2IDX < numClasses; ++class2IDX)
172  {
173  MLClassPtr class2 = assignments.GetMLClass ((kkint16)class2IDX);
174  BinaryClassParmsPtr bcp = binaryParmsList->LookUp (class1, class2);
175  if (bcp)
176  probClassPairs.push_back ((float)bcp->AParam ());
177  else
178  probClassPairs.push_back ((float)param.A);
179  }
180  }
181  }
182 } /* ProbClassPairsInitialize */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
Similar to SVMparam except it is specialized for two classes.
MLClassPtr GetMLClass(kkint16 num) const
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
Represents a "Class" in the Machine Learning Sense.
Definition: MLClass.h:52
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void KKMLL::SVMparam::ProcessSvmParameter ( svm_parameter _param,
KKStr  cmd,
KKStr  value,
double  valueNum,
bool &  parmUsed 
)
void SVMparam::ReadXML ( XmlStream s,
XmlTagConstPtr  tag,
VolConstBool cancelFlag,
RunLog log 
)
virtual

Definition at line 815 of file SVMparam.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::XmlStream::GetNextToken(), and KKB::XmlToken::VarName().

820 {
821  XmlTokenPtr t = s.GetNextToken (cancelFlag, log);
822  while (t && (!cancelFlag))
823  {
824  const KKStr& varName = t->VarName ();
825 
826  if (varName.EqualIgnoreCase ("HeaderFields") && (typeid (*t) == typeid (XmlElementKeyValuePairs)))
827  {
829  if (kvp && (kvp->Value() != NULL))
830  {
831  for (auto idx: *(kvp->Value ()))
832  {
833  if (idx.first.EqualIgnoreCase ("EncodingMethod"))
834  encodingMethod = EncodingMethodFromStr (idx.second);
835 
836  else if (idx.first.EqualIgnoreCase ("FileName"))
837  fileName = idx.second;
838 
839  else if (idx.first.EqualIgnoreCase ("MachineType"))
840  machineType = MachineTypeFromStr (idx.second);
841 
842  else if (idx.first.EqualIgnoreCase ("SelectedFeatures"))
843  {
844  bool successful = false;
845  selectedFeatures = new FeatureNumList (idx.second, successful);
846  }
847 
848  else if (idx.first.EqualIgnoreCase ("Param"))
849  param.ParseTabDelStr (idx.second);
850 
851  else if (idx.first.EqualIgnoreCase ("SamplingRate"))
852  samplingRate = idx.second.ToFloat ();
853 
854  else if (idx.first.EqualIgnoreCase ("SelectionMethod"))
855  selectionMethod = SelectionMethodFromStr (idx.second);
856 
857  else if (idx.first.EqualIgnoreCase ("UseProbabilityToBreakTies"))
858  useProbabilityToBreakTies = idx.second.ToBool ();
859 
860  else
861  {
862  log.Level (-1) << endl
863  << "SVMparam::ReadXML ***ERROR*** UnRecognozed Header Field: " << idx.first << ":" << idx.second << endl
864  << endl;
865  }
866  }
867  }
868  }
869  delete t;
870  t = s.GetNextToken (cancelFlag, log);
871  }
872  delete t;
873  t = NULL;
874 } /* ReadXML */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void ParseTabDelStr(const KKStr &_str)
Definition: svm.cpp:1176
Keeps track of selected features.
SVM_EncodingMethod EncodingMethodFromStr(const KKStr &encodingMethodStr)
Definition: SVMparam.cpp:899
SVM_MachineType MachineTypeFromStr(const KKStr &machineTypeStr)
Definition: SVMparam.cpp:986
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
std::vector< std::pair< KKStr, KKStr > > * Value() const
Definition: XmlStream.h:586
SVM_SelectionMethod SelectionMethodFromStr(const KKStr &selectionMethodStr)
Definition: SVMparam.cpp:1022
virtual XmlTokenPtr GetNextToken(VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:116
virtual const KKStr & VarName() const
Definition: XmlStream.h:269
float KKMLL::SVMparam::SamplingRate ( ) const
inline

Definition at line 163 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::SamplingRate().

163 {return samplingRate;}
void KKMLL::SVMparam::SamplingRate ( float  _samplingRate)
inline

Definition at line 188 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::SamplingRate().

188 {samplingRate = _samplingRate;}
FeatureNumListConstPtr KKMLL::SVMparam::SelectedFeatures ( ) const
inline

Definition at line 165 of file SVMparam.h.

Referenced by C_Param(), KKMLL::ModelParamOldSVM::SelectedFeatures(), and KKMLL::SVMModel::SVMModel().

165 {return selectedFeatures;}
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().

113 {
114  if (!selectedFeatures)
115  {
116  selectedFeatures = new FeatureNumList (fileDesc);
117  selectedFeatures->SetAllFeatures (fileDesc);
118  }
119  return selectedFeatures;
120 }
Keeps track of selected features.
void SetAllFeatures(FileDescPtr fileDesc)
Selects all features except those flagged as &#39;Ignore&#39; in the associated FileDesc. ...
void KKMLL::SVMparam::SelectedFeatures ( FeatureNumListConst _selectedFeatures)
void SVMparam::SelectedFeatures ( FeatureNumListConstPtr  _selectedFeatures)

Definition at line 145 of file SVMparam.cpp.

References KKMLL::FeatureNumList::FeatureNumList().

146 {
147  delete selectedFeatures;
148  selectedFeatures = new FeatureNumList (*_selectedFeatures);
149 }
Keeps track of selected features.
SVM_SelectionMethod KKMLL::SVMparam::SelectionMethod ( ) const
inline
void KKMLL::SVMparam::SelectionMethod ( SVM_SelectionMethod  _selectionMethod)
inline

Definition at line 218 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::SelectionMethod().

218 {selectionMethod = _selectionMethod;}
void SVMparam::SetBinaryClassFields ( MLClassPtr  _class1,
MLClassPtr  _class2,
const svm_parameter _param,
FeatureNumListConstPtr  _features,
float  _weight 
)
Parameters
_class1First of two classes that is being added to this model.
_class2Second of two classes that is being added to this model.
_paramParameters that are to be used by two-class classifier.
_featuresmakes own copy; caller will retain ownership status.
_weightYou 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().

727 {
728  if (!binaryParmsList)
729  {
730  AddBinaryClassParms (_class1, _class2, _param, _features, _weight);
731  }
732  else
733  {
734  BinaryClassParmsPtr binaryParms = binaryParmsList->LookUp (_class1, _class2);
735  if (binaryParms)
736  {
737  binaryParms->Param (_param);
738  binaryParms->SelectedFeatures (_features);
739  binaryParms->Weight (_weight);
740  }
741  else
742  {
743  AddBinaryClassParms (_class1, _class2, _param, _features, _weight);
744  }
745  }
746 } /* SetBinaryClassFields */
Similar to SVMparam except it is specialized for two classes.
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
void AddBinaryClassParms(BinaryClassParmsPtr binaryClassParms)
Definition: SVMparam.cpp:475
const svm_parameter & Param() const
FeatureNumListConstPtr SelectedFeatures() const
void SVMparam::SetFeatureNums ( FeatureNumListConstPtr  _features)

Definition at line 655 of file SVMparam.cpp.

References KKMLL::FeatureNumList::FeatureNumList().

656 {
657  delete selectedFeatures;
658  selectedFeatures = new FeatureNumList (*_features);
659 } /* SetFeatureNums */
Keeps track of selected 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.

Parameters
_class1First of two classes to set features for.
_class2Second of two classes to set features for.
_featuresMakes 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().

619 {
620  if (!binaryParmsList)
621  {
622  if (_weight < 0)
623  _weight = 1;
624  AddBinaryClassParms (_class1, _class2, param, _features, _weight);
625  }
626  else
627  {
628  BinaryClassParmsPtr binaryParms = binaryParmsList->LookUp (_class1, _class2);
629  if (binaryParms)
630  {
631  if (_weight < 0)
632  _weight = binaryParms->Weight ();
633  binaryParms->SelectedFeatures (_features);
634  }
635  else
636  {
637  if (_weight < 0)
638  _weight = 1.0f;
639  AddBinaryClassParms (_class1, _class2, param, _features, _weight);
640  }
641  }
642 } /* SetFeatureNums */
Similar to SVMparam except it is specialized for two classes.
BinaryClassParmsPtr LookUp(MLClassPtr _class1, MLClassPtr _class2) const
void AddBinaryClassParms(BinaryClassParmsPtr binaryClassParms)
Definition: SVMparam.cpp:475
FeatureNumListConstPtr SelectedFeatures() const
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().

354 {
355  KKStr cmdStr (300);
356 
357  cmdStr << _param.ToCmdLineStr ();
358 
359  return cmdStr;
360 } /* SvmParamToString */
KKStr ToCmdLineStr() const
Definition: svm.cpp:1069
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().

369 {
370  KKStr cmdStr (300);
371 
372  cmdStr = SvmParamToString (param);
373 
374  if (encodingMethod != SVM_EncodingMethod::NoEncoding)
375  cmdStr << " -Encode " + EncodingMethodToStr (encodingMethod);
376 
377  cmdStr << " -MT " << MachineTypeToStr (machineType);
378  cmdStr << " -SM " << SelectionMethodToStr (selectionMethod);
379 
380  if (machineType == SVM_MachineType::BoostSVM)
381  {
382  cmdStr << " -SamplingRate " << samplingRate;
383  }
384 
385  if (useProbabilityToBreakTies)
386  cmdStr << " -UseProbability";
387 
388  return cmdStr;
389 } /* ToString */
KKStr SvmParamToString(const svm_parameter &_param) const
Convert a svm_parameter struct to a cmdline str.
Definition: SVMparam.cpp:353
KKStr EncodingMethodToStr(SVM_EncodingMethod encodingMethod)
KKStr MachineTypeToStr(SVM_MachineType machineType)
Definition: SVMparam.cpp:965
KKStr SelectionMethodToStr(SVM_SelectionMethod selectionMethod)
Definition: SVMparam.cpp:1008
bool KKMLL::SVMparam::UseProbabilityToBreakTies ( ) const
inline

Definition at line 171 of file SVMparam.h.

Referenced by KKMLL::ModelParamOldSVM::UseProbabilityToBreakTies().

171 {return useProbabilityToBreakTies;}
void SVMparam::WriteXML ( const KKStr varName,
std::ostream &  o 
) const
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().

772 {
773  XmlTag startTag ("SVMparam", XmlTag::TagTypes::tagStart);
774  if (!varName.Empty ())
775  startTag.AddAtribute ("VarName", varName);
776  startTag.WriteXML (o);
777  o << endl;
778 
779  {
780  XmlElementKeyValuePairs* headerFields = new XmlElementKeyValuePairs ();
781 
782  headerFields->Add ("EncodingMethod", EncodingMethodToStr (encodingMethod));
783  headerFields->Add ("FileName", fileName);
784  headerFields->Add ("MachineType", MachineTypeToStr (machineType));
785  if (selectedFeatures)
786  headerFields->Add ("SelectedFeatures", selectedFeatures->ToString ());
787  headerFields->Add ("param", param.ToTabDelStr ());
788 
789  headerFields->Add ("samplingRate", samplingRate);
790  headerFields->Add ("selectionMethod", SelectionMethodToStr (selectionMethod));
791 
792 
793  headerFields->Add ("useProbabilityToBreakTies", useProbabilityToBreakTies);
794 
795 
796  headerFields->WriteXML ("HeaderFields", o);
797  delete headerFields;
798  headerFields = NULL;
799  }
800 
801  XmlElementVectorFloat::WriteXML (probClassPairs, "probClassPairs", o);
802 
803  if (binaryParmsList)
804  binaryParmsList->WriteXML ("binaryParmsList", o);
805 
806  XmlTag endTag ("SVMparam", XmlTag::TagTypes::tagEnd);
807  endTag.WriteXML (o);
808  o << endl;
809 } /* WriteXML */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr EncodingMethodToStr(SVM_EncodingMethod encodingMethod)
KKStr ToString() const
Returns comma delimited list of all features selected; will make use of range specification.
void Add(const KKStr &key, const KKStr &v)
Definition: XmlStream.cpp:1193
void WriteXML(std::ostream &o) const
bool Empty() const
Definition: KKStr.h:241
KKStr ToTabDelStr() const
Definition: svm.cpp:1104
KKStr MachineTypeToStr(SVM_MachineType machineType)
Definition: SVMparam.cpp:965
KKStr SelectionMethodToStr(SVM_SelectionMethod selectionMethod)
Definition: SVMparam.cpp:1008
void WriteXML(const KKStr &varName, std::ostream &o)
Definition: XmlStream.cpp:1252

The documentation for this class was generated from the following files: