KSquare Utilities
KKMLL::ModelParamKnn Class Reference

#include <ModelParamKnn.h>

+ Inheritance diagram for KKMLL::ModelParamKnn:

Public Types

typedef ModelParamKnnModelParamKnnPtr
 
- 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

 ModelParamKnn ()
 
 ModelParamKnn (const ModelParamKnn &_param)
 
virtual ~ModelParamKnn ()
 
virtual ModelParamKnnPtr Duplicate () const
 
virtual ModelParamTypes ModelParamType () const
 
virtual void ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
 
virtual KKStr ToCmdLineStr (RunLog &log) 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 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)
 
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
 

Additional Inherited Members

- 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

Definition at line 8 of file ModelParamKnn.h.

Member Typedef Documentation

Constructor & Destructor Documentation

ModelParamKnn::ModelParamKnn ( )

Definition at line 28 of file ModelParamKnn.cpp.

References KKMLL::ModelParam::ModelParam().

28  :
29  ModelParam (),
30  k(1)
31 {
32 }
ModelParamKnn::ModelParamKnn ( const ModelParamKnn _param)

Definition at line 36 of file ModelParamKnn.cpp.

References KKMLL::ModelParam::ModelParam().

Referenced by Duplicate().

36  :
37  ModelParam (_param),
38  k (_param.k)
39 {
40 }
ModelParamKnn::~ModelParamKnn ( )
virtual

Definition at line 44 of file ModelParamKnn.cpp.

45 {
46 }

Member Function Documentation

ModelParamKnnPtr ModelParamKnn::Duplicate ( ) const
virtual

Implements KKMLL::ModelParam.

Definition at line 51 of file ModelParamKnn.cpp.

References ModelParamKnn().

52 {
53  return new ModelParamKnn (*this);
54 }
virtual ModelParamTypes KKMLL::ModelParamKnn::ModelParamType ( ) const
inlinevirtual
void ModelParamKnn::ReadXML ( XmlStream s,
XmlTagConstPtr  tag,
VolConstBool cancelFlag,
RunLog log 
)
virtual

Implements KKMLL::ModelParam.

Definition at line 119 of file ModelParamKnn.cpp.

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

124 {
125  XmlTokenPtr t = s.GetNextToken (cancelFlag, log);
126  while (t && (!cancelFlag))
127  {
128  t = ReadXMLModelParamToken (t);
129  if (t)
130  {
131  const KKStr& varName = t->VarName ();
132 
133  if (varName.EqualIgnoreCase ("k"))
134  k = dynamic_cast<XmlElementInt32Ptr> (t)->Value ();
135 
136  else if (varName.EqualIgnoreCase ("fileName"))
137  fileName = *(dynamic_cast<XmlElementKKStrPtr> (t)->Value ());
138  }
139 
140  delete t;
141  t = s.GetNextToken (cancelFlag, log);
142  }
143  delete t;
144  t = NULL;
145 } /* ReadXML */
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 ModelParamKnn::ToCmdLineStr ( RunLog log) const
virtual

Creates a Command Line String that represents these parameters.

Definition at line 59 of file ModelParamKnn.cpp.

References KKB::KKStr::operator+(), KKB::StrFormatInt(), and KKMLL::ModelParam::ToCmdLineStr().

60 {
61  return ModelParam::ToCmdLineStr () + " -K " + StrFormatInt (k, "###0");
62 }
virtual KKStr ToCmdLineStr() const
Creates a a Command Line String that represents these parameters.
Definition: ModelParam.cpp:367
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
void ModelParamKnn::WriteXML ( const KKStr varName,
ostream &  o 
) const
virtual

Definition at line 95 of file ModelParamKnn.cpp.

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

Referenced by KKMLL::ModelKnn::WriteXML().

98 {
99  XmlTag startTag ("ModelParamDual", XmlTag::TagTypes::tagStart);
100  if (!varName.Empty ())
101  startTag.AddAtribute ("VarName", varName);
102  startTag.WriteXML (o);
103  o << endl;
104 
105  WriteXMLFields (o);
106 
107 
108 
109 
110  XmlTag endTag ("ModelParamDual", XmlTag::TagTypes::tagEnd);
111  endTag.WriteXML (o);
112  o << endl;
113 } /* WriteXML */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void WriteXMLFields(std::ostream &o) const
Definition: ModelParam.cpp:464
bool Empty() const
Definition: KKStr.h:241

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