KSquare Utilities
SVM289_BFS::svm_parameter Struct Reference

#include <svm289_BFS.h>

Public Member Functions

 svm_parameter ()
 
 svm_parameter (const svm_parameter &_param)
 
 svm_parameter (KKStr &paramStr)
 
 ~svm_parameter ()
 
void Cost (double _cost)
 
double Cost () const
 
void Gamma (double _gamma)
 
double Gamma () const
 
void KernalType (Kernel_Type _kernalType)
 
Kernel_Type KernalType () const
 
svm_parameteroperator= (const svm_parameter &right)
 
void ParseTabDelStr (const KKStr &_str)
 
void ProcessSvmParameter (const KKStr &cmd, const KKStr &value, bool &parmUsed)
 
void SvmType (SVM_Type _svm_type)
 
SVM_Type SvmType () const
 
KKStr ToCmdLineStr () const
 
KKStr ToTabDelStr () const
 

Public Attributes

double C
 
double cache_size
 
double coef0
 
kkint32 degree
 
double eps
 
double gamma
 
Kernel_Type kernel_type
 
kkint32 nr_weight
 
double nu
 
double p
 
kkint32 probability
 
double probParam
 
kkint32 shrinking
 
SVM_Type svm_type
 
double * weight
 
kkint32weight_label
 

Static Public Attributes

static const char * kernel_type_table []
 
static const char * svm_type_table []
 

Detailed Description

Definition at line 87 of file svm289_BFS.h.

Constructor & Destructor Documentation

SVM289_BFS::svm_parameter::svm_parameter ( )

Definition at line 179 of file svm289_BFS.cpp.

References C, SVM289_BFS::C_SVC, cache_size, coef0, degree, eps, gamma, kernel_type, nr_weight, nu, p, probability, probParam, SVM289_BFS::RBF, shrinking, svm_type, weight, and weight_label.

Referenced by SVM289_BFS::svm_model::svm_model().

179  :
181  kernel_type (RBF),
182  degree (3),
183  gamma (0.0),
184  coef0 (0.0),
185  cache_size (40.0),
186  eps (1e-3),
187  C (1),
188  nr_weight (0),
189  weight_label (NULL),
190  weight (NULL),
191  nu (0.5),
192  p (0.1),
193  shrinking (1),
194  probability (0),
195  probParam (0.0)
196 {
197 }
SVM289_BFS::svm_parameter::svm_parameter ( const svm_parameter _param)

Definition at line 200 of file svm289_BFS.cpp.

References C, cache_size, coef0, degree, eps, gamma, kernel_type, nr_weight, nu, p, probability, probParam, shrinking, svm_type, weight, and weight_label.

Referenced by SVM289_BFS::svm_model::svm_model().

200  :
201  svm_type (_param.svm_type),
202  kernel_type (_param.kernel_type),
203  degree (_param.degree),
204  gamma (_param.gamma),
205  coef0 (_param.coef0),
206  cache_size (_param.cache_size),
207  eps (_param.eps),
208  C (_param.C),
209  nr_weight (_param.nr_weight),
210  weight_label (NULL),
211  weight (NULL),
212  nu (_param.nu),
213  p (_param.p),
214  shrinking (_param.shrinking),
215  probability (_param.probability),
216  probParam (_param.probParam)
217 {
218  if (_param.weight_label)
219  {
221  for (kkint32 x = 0; x < nr_weight; x++)
222  weight_label[x] = _param.weight_label[x];
223  }
224 
225  if (_param.weight)
226  {
227  weight = new double[nr_weight];
228  for (kkint32 x = 0; x < nr_weight; x++)
229  weight[x] = _param.weight[x];
230  }
231 }
__int32 kkint32
Definition: KKBaseTypes.h:88
SVM289_BFS::svm_parameter::svm_parameter ( KKStr paramStr)

Definition at line 235 of file svm289_BFS.cpp.

References C, SVM289_BFS::C_SVC, cache_size, coef0, degree, eps, gamma, kernel_type, nr_weight, nu, p, probability, probParam, SVM289_BFS::RBF, shrinking, svm_type, weight, and weight_label.

235  :
237  kernel_type (RBF),
238  degree (3),
239  gamma (0.0),
240  coef0 (0.0),
241  cache_size (40.0),
242  eps (1e-3),
243  C (1),
244  nr_weight (0),
245  weight_label (NULL),
246  weight (NULL),
247  nu (0.5),
248  p (0.1),
249  shrinking (1),
250  probability (0),
251  probParam (0.0)
252 {
253  cerr << endl << "SVM289_BFS::svm_parameter::svm_parameter Not Doing anything with 'paramStr'" << endl << endl;
254 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
SVM289_BFS::svm_parameter::~svm_parameter ( )

Definition at line 258 of file svm289_BFS.cpp.

References weight, and weight_label.

259 {
260  delete weight_label; weight_label = NULL;
261  delete weight; weight = NULL;
262 }

Member Function Documentation

void SVM289_BFS::svm_parameter::Cost ( double  _cost)
inline

Definition at line 95 of file svm289_BFS.h.

References C.

95 {C = _cost;}
double SVM289_BFS::svm_parameter::Cost ( ) const
inline

Definition at line 100 of file svm289_BFS.h.

References C.

100 {return C;}
void SVM289_BFS::svm_parameter::Gamma ( double  _gamma)
inline

Definition at line 96 of file svm289_BFS.h.

References gamma.

96 {gamma = _gamma;}
double SVM289_BFS::svm_parameter::Gamma ( ) const
inline

Definition at line 101 of file svm289_BFS.h.

References gamma.

101 {return gamma;}
void SVM289_BFS::svm_parameter::KernalType ( Kernel_Type  _kernalType)
inline

Definition at line 97 of file svm289_BFS.h.

References kernel_type.

97 {kernel_type = _kernalType;}
Kernel_Type SVM289_BFS::svm_parameter::KernalType ( ) const
inline

Definition at line 102 of file svm289_BFS.h.

References kernel_type.

102 {return kernel_type;}
svm_parameter & SVM289_BFS::svm_parameter::operator= ( const svm_parameter right)

Definition at line 266 of file svm289_BFS.cpp.

References C, cache_size, coef0, degree, eps, gamma, kernel_type, nr_weight, nu, p, probability, probParam, shrinking, svm_type, weight, and weight_label.

267 {
268  svm_type = right.svm_type;
269  kernel_type = right.kernel_type;
270  degree = right.degree;
271  gamma = right.gamma;
272  coef0 = right.coef0;
273  cache_size = right.cache_size;
274  eps = right.eps;
275  C = right.C;
276  nr_weight = right.nr_weight;
277  weight_label = NULL;
278  weight = NULL;
279  nu = right.nu;
280  p = right.p;
281  shrinking = right.shrinking;
282  probability = right.probability;
283  probParam = right.probParam;
284 
285  if (right.weight_label)
286  {
288  for (kkint32 x = 0; x < nr_weight; x++)
289  weight_label[x] = right.weight_label[x];
290  }
291 
292  if (right.weight)
293  {
294  weight = new double[nr_weight];
295  for (kkint32 x = 0; x < nr_weight; x++)
296  weight[x] = right.weight[x];
297  }
298 
299  return *this;
300 }
__int32 kkint32
Definition: KKBaseTypes.h:88
void SVM289_BFS::svm_parameter::ParseTabDelStr ( const KKStr _str)

Definition at line 454 of file svm289_BFS.cpp.

References C, cache_size, coef0, KKB::KKStr::Concat(), degree, KKB::KKStr::Empty(), eps, KKB::KKStr::EqualIgnoreCase(), KKB::KKStr::ExtractToken2(), KKB::KKStr::ExtractTokenDouble(), KKB::KKStr::ExtractTokenInt(), gamma, kernel_type, SVM289_BFS::Kernel_Type_FromStr(), nr_weight, nu, KKB::KKStr::operator==(), p, probability, probParam, shrinking, svm_type, SVM289_BFS::SVM_Type_FromStr(), KKB::KKStr::ToDouble(), KKB::KKStr::ToFloat(), KKB::KKStr::ToInt(), weight, and weight_label.

455 {
456  KKStr str = _str;
457  kkint32 x;
458 
459  while (!str.Empty ())
460  {
461  KKStr field = str.ExtractToken2 ("\t");
462  KKStr value = str.ExtractToken2 ("\t");
463  kkint32 valueI = value.ToInt ();
464  double valueD = value.ToDouble ();
465  float valueF = value.ToFloat ();
466 
467  if (field == "svm_type")
468  svm_type = SVM_Type_FromStr (value);
469 
470  else if (field == "kernel_type")
472 
473  else if (field == "degree")
474  degree = valueI;
475 
476  else if (field == "gamma")
477  gamma = valueD;
478 
479  else if (field == "coef0")
480  coef0 = valueD;
481  else if (field == "cache_size")
482  cache_size = valueD;
483 
484  else if (field == "eps")
485  eps = valueD;
486 
487  else if (field == "C")
488  C = valueD;
489 
490  else if (field == "nr_weight")
491  {
492  nr_weight = valueI;
493  if (nr_weight > 0)
494  {
495  delete[] weight_label;
497 
498  // value = weight label.
499  for (x = 0; x < nr_weight; x++)
500  {
501  weight_label[x] = value.ExtractTokenInt (",");
502  }
503 
504  delete[] weight;
505  weight = new double [nr_weight];
506  KKStr weightStr = str.ExtractToken2 ("\t");
507  for (x = 0; x < nr_weight; x++)
508  {
509  weight[x] = weightStr.ExtractTokenDouble (",");
510  }
511  }
512  }
513 
514  else if (field == "nu")
515  nu = valueD;
516 
517  else if (field == "p")
518  p = valueD;
519 
520  else if (field == "shrinking")
521  shrinking = valueI;
522 
523  else if (field == "probability")
524  probability = valueI;
525 
526  else if (field.EqualIgnoreCase ("probparam") || field.EqualIgnoreCase ("pp"))
527  probParam = valueD;
528  }
529 } /* ParseTabDelStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
kkint32 ToInt() const
Definition: KKStr.cpp:3565
Kernel_Type Kernel_Type_FromStr(KKStr s)
Definition: svm289_BFS.cpp:575
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
double ExtractTokenDouble(const char *delStr)
Definition: KKStr.cpp:3180
bool Empty() const
Definition: KKStr.h:241
double ToDouble() const
Definition: KKStr.cpp:3541
kkint32 ExtractTokenInt(const char *delStr)
Definition: KKStr.cpp:3129
SVM_Type SVM_Type_FromStr(KKStr s)
Definition: svm289_BFS.cpp:536
float ToFloat() const
Definition: KKStr.cpp:3553
void SVM289_BFS::svm_parameter::ProcessSvmParameter ( const KKStr cmd,
const KKStr value,
bool &  parmUsed 
)

Definition at line 332 of file svm289_BFS.cpp.

References C, cache_size, coef0, degree, eps, KKB::KKStr::EqualIgnoreCase(), gamma, kernel_type, SVM289_BFS::Kernel_Type_FromStr(), nr_weight, nu, p, probability, probParam, shrinking, svm_type, SVM289_BFS::SVM_Type_FromStr(), KKB::KKStr::ToBool(), KKB::KKStr::ToDouble(), and weight.

336 {
337  parmUsed = true;
338 
339  double valueNum = value.ToDouble ();
340 
341  if (cmd.EqualIgnoreCase ("-B") ||
342  cmd.EqualIgnoreCase ("-CP") ||
343  cmd.EqualIgnoreCase ("-CalcProb") ||
344  cmd.EqualIgnoreCase ("-CalcProbability")
345  )
346  {
347  if (value.ToBool ())
348  probability = 1;
349  else
350  probability = 0;
351  }
352 
353  else if (cmd.EqualIgnoreCase ("-C") || cmd.EqualIgnoreCase ("-Cost"))
354  C = valueNum;
355 
356  else if (cmd.EqualIgnoreCase ("-D"))
357  degree = (kkint32)valueNum;
358 
359  else if (cmd.EqualIgnoreCase ("-E"))
360  eps = valueNum;
361 
362  else if (cmd.EqualIgnoreCase ("-G") || cmd.EqualIgnoreCase ("-GAMMA"))
363  gamma = valueNum;
364 
365  else if (cmd.EqualIgnoreCase ("-H"))
366  shrinking = (kkint32)valueNum;
367 
368  else if (cmd.EqualIgnoreCase ("-M"))
369  cache_size = valueNum;
370 
371  else if (cmd.EqualIgnoreCase ("-N"))
372  nu = valueNum;
373 
374  else if (cmd.EqualIgnoreCase ("-P"))
375  p = valueNum;
376 
377  else if (cmd.EqualIgnoreCase ("-R"))
378  coef0 = valueNum;
379 
380  else if (cmd.EqualIgnoreCase ("-S"))
381  svm_type = SVM_Type_FromStr (value);
382 
383  else if (cmd.EqualIgnoreCase ("-T"))
385 
386  else if (cmd.EqualIgnoreCase ("-ProbParam") || cmd.EqualIgnoreCase ("-PP"))
387  probParam = valueNum;
388 
389  else if (cmd.EqualIgnoreCase ("-W"))
390  {
391  ++nr_weight;
392  weight_label = (kkint32 *) realloc (weight_label, sizeof (kkint32) * nr_weight);
393  weight = (double *) realloc (weight, sizeof (double) * nr_weight);
394  weight_label[nr_weight - 1] = atoi (cmd.SubStrPart (2).Str ());
395  weight[nr_weight - 1] = valueNum;
396  }
397  else
398  {
399  parmUsed = false;
400  }
401 } /* ProcessSvmParameter */
__int32 kkint32
Definition: KKBaseTypes.h:88
Kernel_Type Kernel_Type_FromStr(KKStr s)
Definition: svm289_BFS.cpp:575
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
double ToDouble() const
Definition: KKStr.cpp:3541
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
SVM_Type SVM_Type_FromStr(KKStr s)
Definition: svm289_BFS.cpp:536
bool ToBool() const
Returns the bool equivalent of the string, ex &#39;Yes&#39; = true, &#39;No&#39; = false, &#39;True&#39; = true...
Definition: KKStr.cpp:3523
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
void SVM289_BFS::svm_parameter::SvmType ( SVM_Type  _svm_type)
inline

Definition at line 98 of file svm289_BFS.h.

References svm_type.

98 {svm_type = _svm_type;}
SVM_Type SVM289_BFS::svm_parameter::SvmType ( ) const
inline

Definition at line 103 of file svm289_BFS.h.

References svm_type.

103 {return svm_type;}
KKStr SVM289_BFS::svm_parameter::ToCmdLineStr ( ) const

Definition at line 304 of file svm289_BFS.cpp.

References C, cache_size, coef0, KKB::KKStr::Concat(), degree, eps, gamma, kernel_type, KKB::KKStr::KKStr(), nu, p, probability, probParam, shrinking, and svm_type.

305 {
306  KKStr cmdStr (200); // Initialized char* allocation to 200
307 
308  cmdStr << "-CalcProb " << ((probability == 1) ? "Yes" : "No") << " "
309  << "-c " << C << " "
310  << "-d " << degree << " "
311  << "-e " << eps << " "
312  << "-g " << gamma << " "
313  << "-h " << shrinking << " "
314  << "-m " << cache_size << " "
315  << "-n " << nu << " "
316  << "-p " << p << " ";
317 
318  if (probParam > 0.0)
319  cmdStr << "-ProbParam " << probParam << " ";
320 
321  cmdStr << "-r " << coef0 << " "
322  << "-s " << (kkint32)svm_type << " "
323  << "-t " << (kkint32)kernel_type << " ";
324 
325  return cmdStr;
326 }
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr SVM289_BFS::svm_parameter::ToTabDelStr ( ) const

Definition at line 408 of file svm289_BFS.cpp.

References C, cache_size, coef0, KKB::KKStr::Concat(), degree, eps, gamma, kernel_type, SVM289_BFS::Kernel_Type_ToStr(), KKB::KKStr::KKStr(), nr_weight, nu, p, probability, probParam, shrinking, svm_type, SVM289_BFS::SVM_Type_ToStr(), weight, and weight_label.

409 {
410  KKStr result (256);
411 
412  kkint32 x = 0;
413 
414  result << "svm_type" << "\t" << SVM_Type_ToStr (svm_type) << "\t"
415  << "kernel_type" << "\t" << Kernel_Type_ToStr (kernel_type) << "\t"
416  << "degree" << "\t" << degree << "\t"
417  << "gamma" << "\t" << gamma << "\t"
418  << "coef0" << "\t" << coef0 << "\t"
419  << "cache_size" << "\t" << cache_size << "\t"
420  << "eps" << "\t" << eps << "\t"
421  << "C" << "\t" << C << "\t"
422  << "nr_weight" << "\t" << nr_weight << "\t";
423 
424  if (nr_weight > 0)
425  {
426  for (x = 0; x < nr_weight; x++)
427  {
428  if (x > 0) result << ",";
429  result << weight_label[x];
430  }
431  result << "\t";
432 
433  for (x = 0; x < nr_weight; x++)
434  {
435  if (x > 0) result << ",";
436  result << weight[x];
437  }
438  result << "\t";
439  }
440 
441  result << "nu" << "\t" << nu << "\t"
442  << "p" << "\t" << p << "\t"
443  << "shrinking" << "\t" << shrinking << "\t"
444  << "probability" << "\t" << probability;
445 
446  if (probParam > 0.0)
447  result << "\t" << "ProbParam" << "\t" << probParam;
448 
449  return result;
450 } /* ToTabDelStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr SVM_Type_ToStr(SVM_Type svmType)
Definition: svm289_BFS.cpp:560
KKStr Kernel_Type_ToStr(Kernel_Type kernelType)
Definition: svm289_BFS.cpp:600

Member Data Documentation

const char* SVM289_BFS::svm_parameter::kernel_type_table[]
static

Definition at line 139 of file svm289_BFS.h.

kkint32 SVM289_BFS::svm_parameter::nr_weight
double SVM289_BFS::svm_parameter::probParam
const char* SVM289_BFS::svm_parameter::svm_type_table[]
static

Definition at line 137 of file svm289_BFS.h.

double* SVM289_BFS::svm_parameter::weight
kkint32* SVM289_BFS::svm_parameter::weight_label

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