KSquare Utilities
KKMLL::ModelParamDual Class Reference

#include <ModelParamDual.h>

+ Inheritance diagram for KKMLL::ModelParamDual:

Public Types

typedef ModelParamDualModelParamDualPtr
 
enum  ProbFusionMethod { ProbFusionMethod::Null, ProbFusionMethod::Or, ProbFusionMethod::And }
 
- Public Types inherited from KKMLL::ModelParam
enum  EncodingMethodType { EncodingMethodType::Null, EncodingMethodType::NoEncoding, EncodingMethodType::Binary, EncodingMethodType::Scaled }
 
typedef ModelParamModelParamPtr
 
enum  ModelParamTypes {
  ModelParamTypes::Null, ModelParamTypes::Dual, ModelParamTypes::KNN, ModelParamTypes::OldSVM,
  ModelParamTypes::SvmBase, ModelParamTypes::UsfCasCor
}
 

Public Member Functions

 ModelParamDual ()
 
 ModelParamDual (const KKStr &_configFileName1, const KKStr &_configFileName2, bool _fullHierarchyMustMatch)
 
 ModelParamDual (const ModelParamDual &_param)
 
virtual ~ModelParamDual ()
 
const KKStrConfigFileName1 () const
 
const KKStrConfigFileName2 () const
 
virtual ModelParamDualPtr Duplicate () const
 
bool FullHierarchyMustMatch () const
 
virtual ModelParamTypes ModelParamType () const
 
MLClassPtr OtherClass () const
 
void OtherClass (MLClassPtr _otherClass)
 
virtual void ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
 
virtual KKStr ToCmdLineStr () const
 Creates a Command Line String that represents these parameters. More...
 
virtual void WriteXML (const KKStr &varName, ostream &o) const
 
- Public Member Functions inherited from KKMLL::ModelParam
 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 EncodingMethodType EncodingMethod () const
 
virtual void EncodingMethod (EncodingMethodType _encodingMethod)
 
virtual KKStr EncodingMethodStr () const
 
virtual kkint32 ExamplesPerClass () const
 
virtual void ExamplesPerClass (kkint32 _examplesPerClass)
 
virtual const KKStrFileName () const
 
virtual void FileName (const KKStr &_fileName)
 
virtual double Gamma () const
 
virtual void Gamma (double _gamma)
 
virtual kkint32 MemoryConsumedEstimated () const
 
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 float Prob () const
 
virtual void Prob (float _prob)
 
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 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 ProbFusionMethod ProbFusionMethodFromStr (const KKStr &s)
 
static KKStr ProbFusionMethodToStr (ProbFusionMethod pfm)
 
- Static Public Member Functions inherited from KKMLL::ModelParam
static EncodingMethodType EncodingMethodFromStr (const KKStr &encodingMethodStr)
 
static KKStr EncodingMethodToStr (EncodingMethodType encodingMethod)
 
static ModelParamTypes ModelParamTypeFromStr (const KKStr &_modelParamTypeStr)
 
static KKStr ModelParamTypeToStr (ModelParamTypes _modelParamType)
 

Detailed Description

Parameters used for the Dual Classifier. *

See also
Model

Definition at line 17 of file ModelParamDual.h.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
Null 
Or 
And 

Definition at line 22 of file ModelParamDual.h.

23  {
24  Null,
25  Or,
26  And
27  };

Constructor & Destructor Documentation

ModelParamDual::ModelParamDual ( )

Definition at line 31 of file ModelParamDual.cpp.

References KKB::KKStr::KKStr(), KKMLL::ModelParam::ModelParam(), and Or.

31  :
32  ModelParam (),
33  configFileName1 (),
34  configFileName2 (),
35  fullHierarchyMustMatch (false),
36  otherClass (NULL),
37  probFusionMethod (ProbFusionMethod::Or)
38 {
39 }
ModelParamDual::ModelParamDual ( const KKStr _configFileName1,
const KKStr _configFileName2,
bool  _fullHierarchyMustMatch 
)

Definition at line 44 of file ModelParamDual.cpp.

References KKB::KKStr::KKStr(), KKMLL::ModelParam::ModelParam(), and Or.

47  :
48 
49  ModelParam (),
50  configFileName1 (_configFileName1),
51  configFileName2 (_configFileName2),
52  fullHierarchyMustMatch (_fullHierarchyMustMatch),
53  otherClass (NULL),
54  probFusionMethod (ProbFusionMethod::Or)
55 {
56 }
ModelParamDual::ModelParamDual ( const ModelParamDual _param)

Definition at line 65 of file ModelParamDual.cpp.

References KKB::KKStr::KKStr(), and KKMLL::ModelParam::ModelParam().

Referenced by Duplicate().

65  :
66  ModelParam (_param),
67  configFileName1 (_param.configFileName1),
68  configFileName2 (_param.configFileName2),
69  fullHierarchyMustMatch (_param.fullHierarchyMustMatch),
70  otherClass (_param.otherClass),
71  probFusionMethod (_param.probFusionMethod)
72 {
73 }
ModelParamDual::~ModelParamDual ( )
virtual

Definition at line 77 of file ModelParamDual.cpp.

78 {
79 }

Member Function Documentation

const KKStr& KKMLL::ModelParamDual::ConfigFileName1 ( ) const
inline

Definition at line 49 of file ModelParamDual.h.

Referenced by KKMLL::ModelDual::TrainModel().

49 {return configFileName1;}
const KKStr& KKMLL::ModelParamDual::ConfigFileName2 ( ) const
inline

Definition at line 50 of file ModelParamDual.h.

Referenced by KKMLL::ModelDual::TrainModel().

50 {return configFileName2;}
ModelParamDualPtr ModelParamDual::Duplicate ( ) const
virtual

Implements KKMLL::ModelParam.

Definition at line 117 of file ModelParamDual.cpp.

References ModelParamDual().

118 {
119  return new ModelParamDual (*this);
120 } /* Duplicate */
bool KKMLL::ModelParamDual::FullHierarchyMustMatch ( ) const
inline

Definition at line 51 of file ModelParamDual.h.

Referenced by KKMLL::ModelDual::ReconcilePredictions().

51 {return fullHierarchyMustMatch;}
virtual ModelParamTypes KKMLL::ModelParamDual::ModelParamType ( ) const
inlinevirtual
MLClassPtr KKMLL::ModelParamDual::OtherClass ( ) const
inline

Definition at line 52 of file ModelParamDual.h.

Referenced by KKMLL::ModelDual::ReconcilePredictions().

52 {return otherClass;}
void KKMLL::ModelParamDual::OtherClass ( MLClassPtr  _otherClass)
inline

Definition at line 56 of file ModelParamDual.h.

56 {otherClass = _otherClass;}
ModelParamDual::ProbFusionMethod ModelParamDual::ProbFusionMethodFromStr ( const KKStr s)
static

Definition at line 82 of file ModelParamDual.cpp.

References And, KKB::KKStr::EqualIgnoreCase(), Null, and Or.

83 {
84  if (s.EqualIgnoreCase ("And"))
85  return ProbFusionMethod::And;
86 
87  else if (s.EqualIgnoreCase ("Or"))
88  return ProbFusionMethod::Or;
89 
90  else
92 }
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
KKStr ModelParamDual::ProbFusionMethodToStr ( ProbFusionMethod  pfm)
static

Definition at line 95 of file ModelParamDual.cpp.

References And, KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), Null, and Or.

Referenced by ToCmdLineStr(), and WriteXML().

96 {
97  if ((pfm < ProbFusionMethod::Null) || (pfm > ProbFusionMethod::And))
98  return KKStr::EmptyStr ();
99 
100  switch (pfm)
101  {
103  return "And";
104  break;
105 
107  return "Or";
108  break;
109  }
110 
111  return KKStr::EmptyStr ();
112 }
void ModelParamDual::ReadXML ( XmlStream s,
XmlTagConstPtr  tag,
VolConstBool cancelFlag,
RunLog log 
)
virtual

Implements KKMLL::ModelParam.

Definition at line 278 of file ModelParamDual.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::XmlStream::GetNextToken(), KKMLL::ModelParam::ReadXMLModelParamToken(), KKB::XmlElementBool::Value(), KKMLL::XmlElementMLClass::Value(), and KKB::XmlToken::VarName().

283 {
284  XmlTokenPtr t = s.GetNextToken (cancelFlag, log);
285  while (t && (!cancelFlag))
286  {
287  t = ReadXMLModelParamToken (t);
288  if (t)
289  {
290  const KKStr& varName = t->VarName ();
291 
292  if (varName.EqualIgnoreCase ("ConfigFileName1"))
293  configFileName1 = *(dynamic_cast<XmlElementKKStrPtr> (t)->Value ());
294 
295  else if (varName.EqualIgnoreCase ("ConfigFileName2"))
296  configFileName2 = *(dynamic_cast<XmlElementKKStrPtr> (t)->Value ());
297 
298  else if (varName.EqualIgnoreCase ("FullHierarchyMustMatch"))
299  fullHierarchyMustMatch = dynamic_cast<XmlElementBoolPtr> (t)->Value ();
300 
301  else if ((varName.EqualIgnoreCase ("OtherClass")) && (typeid (*t) == typeid (XmlElementMLClass)))
302  otherClass = dynamic_cast<XmlElementMLClassPtr> (t)->Value ();
303 
304  else if (varName.EqualIgnoreCase ("ProbFusionMethod"))
305  probFusionMethod = ProbFusionMethodFromStr (*(dynamic_cast<XmlElementKKStrPtr> (t)->Value ()));
306  }
307  delete t;
308  t = s.GetNextToken (cancelFlag, log);
309  }
310  delete t;
311  t = NULL;
312 } /* ReadXML */
static ProbFusionMethod ProbFusionMethodFromStr(const KKStr &s)
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
XmlTokenPtr ReadXMLModelParamToken(XmlTokenPtr t)
Will process any tokens that belong to &#39;ModelParam&#39; and return NULL ones that are not will be passed ...
Definition: ModelParam.cpp:487
virtual XmlTokenPtr GetNextToken(VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:116
virtual const KKStr & VarName() const
Definition: XmlStream.h:269
KKStr ModelParamDual::ToCmdLineStr ( ) const
virtual

Creates 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 from KKMLL::ModelParam.

Definition at line 222 of file ModelParamDual.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::Empty(), KKB::KKStr::KKStr(), KKMLL::MLClass::Name(), KKB::KKStr::operator=(), ProbFusionMethodToStr(), and KKMLL::ModelParam::ToCmdLineStr().

223 {
224  KKStr cmdStr (300);
225  cmdStr = ModelParam::ToCmdLineStr ();
226 
227  if (!configFileName1.Empty ())
228  cmdStr << " " << "-Classifier1" << " " << configFileName1;
229 
230  if (!configFileName2.Empty ())
231  cmdStr << " " << "-Classifier2" << " " << configFileName2;
232 
233  if (fullHierarchyMustMatch)
234  cmdStr << " " << "-FullHierarchyMustMatch" << " " << "Yes";
235 
236  if (otherClass)
237  cmdStr << " " << "-OtherClass" << " " << otherClass->Name ();
238 
239  cmdStr << " " << "-ProbFusionMethod" << " " << ProbFusionMethodToStr (this->probFusionMethod);
240 
241  return cmdStr;
242 } /* ToCmdLineStr */
virtual KKStr ToCmdLineStr() const
Creates a a Command Line String that represents these parameters.
Definition: ModelParam.cpp:367
static KKStr ProbFusionMethodToStr(ProbFusionMethod pfm)
bool Empty() const
Definition: KKStr.h:241
void ModelParamDual::WriteXML ( const KKStr varName,
ostream &  o 
) const
virtual

Definition at line 247 of file ModelParamDual.cpp.

References KKB::XmlTag::AddAtribute(), KKB::KKStr::Empty(), ProbFusionMethodToStr(), KKB::XmlTag::tagEnd, KKB::XmlTag::tagStart, KKMLL::MLClass::WriteXML(), KKB::XmlTag::WriteXML(), KKB::XmlElementBool::WriteXML(), KKB::KKStr::WriteXML(), KKMLL::ModelParam::WriteXMLFields(), and KKB::XmlTag::XmlTag().

250 {
251  XmlTag startTag ("ModelParamDual", XmlTag::TagTypes::tagStart);
252  if (!varName.Empty ())
253  startTag.AddAtribute ("VarName", varName);
254  startTag.WriteXML (o);
255  o << endl;
256 
257 
258  WriteXMLFields (o);
259 
260  configFileName1.WriteXML ("ConfigFileName1", o);
261  configFileName2.WriteXML ("ConfigFileName1", o);
262 
263  XmlElementBool::WriteXML (fullHierarchyMustMatch, "FullHierarchyMustMatch", o);
264  if (otherClass)
265  otherClass->WriteXML ("OtherClass", o);
266 
267  ProbFusionMethodToStr (probFusionMethod).WriteXML ("ProbFusionMethod", o);
268 
269  XmlTag endTag ("ModelParamDual", XmlTag::TagTypes::tagEnd);
270  endTag.WriteXML (o);
271  o << endl;
272 } /* WriteXML */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void WriteXMLFields(std::ostream &o) const
Definition: ModelParam.cpp:464
static KKStr ProbFusionMethodToStr(ProbFusionMethod pfm)
bool Empty() const
Definition: KKStr.h:241
void WriteXML(const KKStr &varName, std::ostream &o) const
Definition: KKStr.cpp:4420
void WriteXML(const KKStr &varName, std::ostream &o) const
Definition: MLClass.cpp:448

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