KSquare Utilities
SVM289_BFS::svm_model Struct Reference

#include <svm289_BFS.h>

Public Member Functions

 svm_model (const svm_model &_model, FileDescPtr _fileDesc, RunLog &_log)
 
 svm_model (FileDescPtr _fileDesc, RunLog &_log)
 
 svm_model (const svm_parameter &_param, const FeatureNumList &_selFeatures, FileDescPtr _fileDesc, RunLog &_log)
 
 svm_model (istream &_fileName, FileDescPtr _fileDesc, RunLog &_log)
 
 ~svm_model ()
 
double * DecValues ()
 
void NormalizeProbability ()
 Derining multiclass probability as done in "Recognizing Plankton Images From the SIPPER". More...
 
double ** PairwiseProb ()
 
double * ProbEstimates ()
 
void Read (istream &i, FileDescPtr fileDesc, RunLog &log)
 
void Write (ostream &o)
 

Public Attributes

double * dec_values
 
kkint32 l
 
kkint32label
 
kkint32 nr_class
 
kkint32nSV
 
double ** pairwise_prob
 
svm_parameter param
 
double * prob_estimates
 
double * probA
 
double * probB
 
double * rho
 
FeatureNumList selFeatures
 
FeatureVectorList SV
 
double ** sv_coef
 
bool weOwnSupportVectors
 

Detailed Description

Definition at line 146 of file svm289_BFS.h.

Constructor & Destructor Documentation

SVM289_BFS::svm_model::svm_model ( const svm_model _model,
FileDescPtr  _fileDesc,
RunLog _log 
)

Definition at line 4105 of file svm289_BFS.cpp.

References dec_values, KKMLL::FeatureNumList::FeatureNumList(), l, label, nr_class, nSV, pairwise_prob, param, prob_estimates, probA, probB, rho, selFeatures, sv_coef, svm_model(), SVM289_BFS::svm_parameter::svm_parameter(), and weOwnSupportVectors.

Referenced by svm_model().

4108  :
4109  param (_model.param),
4110  nr_class (_model.nr_class),
4111  l (_model.l),
4112  SV (_fileDesc, false),
4113  sv_coef (NULL),
4114  rho (NULL),
4115  probA (NULL),
4116  probB (NULL),
4117  label (NULL),
4118  nSV (NULL), // number of SVs for each class (nSV[k])
4120  selFeatures (_model.selFeatures),
4121  dec_values (NULL),
4122  pairwise_prob (NULL),
4123  prob_estimates (NULL)
4124 
4125 {
4126  kkint32 m = nr_class - 1;
4127  kkint32 numBinaryCombos = nr_class * (nr_class - 1) / 2;
4128 
4129  {
4130  // Copy over support vectors.
4131  FeatureVectorList::const_iterator idx;
4133  for (idx = _model.SV.begin (); idx != _model.SV.end (); idx++)
4134  {
4135  FeatureVectorPtr fv = *idx;
4136  if (weOwnSupportVectors)
4137  SV.push_back (new FeatureVector (*fv));
4138  else
4139  SV.push_back (fv);
4140  }
4141  }
4142 
4143  if (_model.sv_coef)
4144  {
4145  sv_coef = new double*[m];
4146  for (kkint32 j = 0; j < m; j++)
4147  {
4148  sv_coef[j] = new double[l];
4149  for (kkint32 i = 0; i < l; i++)
4150  sv_coef[j][i] = _model.sv_coef[j][i];
4151  }
4152  }
4153 
4154  if (_model.rho)
4155  {
4156  // Copy over RHO
4157  rho = new double[numBinaryCombos];
4158  for (kkint32 i = 0; i < numBinaryCombos; i++)
4159  rho[i] = _model.rho[i];
4160  }
4161 
4162  if (_model.probA)
4163  {
4164  probA = new double[numBinaryCombos];
4165  for (kkint32 i = 0; i < numBinaryCombos; i++)
4166  probA[i] = _model.probA[i];
4167  }
4168 
4169  if (_model.probB)
4170  {
4171  probB = new double[numBinaryCombos];
4172  for (kkint32 i = 0; i < numBinaryCombos; i++)
4173  probB[i] = _model.probB[i];
4174  }
4175 
4176  if (_model.label)
4177  {
4178  label = new kkint32[nr_class];
4179  for (kkint32 i = 0; i < nr_class; i++)
4180  label[i] = _model.label[i];
4181  }
4182 
4183  if (_model.nSV)
4184  {
4185  nSV = new kkint32[nr_class];
4186  for (kkint32 i = 0; i < nr_class; i++)
4187  nSV[i] = _model.nSV[i];
4188  }
4189 }
FeatureVectorList SV
Definition: svm289_BFS.h:187
__int32 kkint32
Definition: KKBaseTypes.h:88
FeatureNumList selFeatures
Definition: svm289_BFS.h:192
double ** pairwise_prob
Definition: svm289_BFS.h:206
bool Owner() const
Definition: KKQueue.h:305
Represents a Feature Vector of a single example, labeled or unlabeled.
Definition: FeatureVector.h:59
svm_parameter param
Definition: svm289_BFS.h:184
SVM289_BFS::svm_model::svm_model ( FileDescPtr  _fileDesc,
RunLog _log 
)

Definition at line 4193 of file svm289_BFS.cpp.

References dec_values, KKMLL::FeatureNumList::FeatureNumList(), l, label, nr_class, nSV, pairwise_prob, param, prob_estimates, probA, probB, rho, selFeatures, sv_coef, svm_model(), SVM289_BFS::svm_parameter::svm_parameter(), and weOwnSupportVectors.

Referenced by svm_model().

4195  :
4196  param (),
4197  nr_class (0),
4198  l (0),
4199  SV (_fileDesc, true),
4200  sv_coef (NULL),
4201  rho (NULL),
4202  probA (NULL),
4203  probB (NULL),
4204  label (NULL),
4205  nSV (NULL), // number of SVs for each class (nSV[k])
4206  weOwnSupportVectors (false),
4207  selFeatures (_fileDesc),
4208  dec_values (NULL),
4209  pairwise_prob (NULL),
4210  prob_estimates (NULL)
4211 {
4212 }
FeatureVectorList SV
Definition: svm289_BFS.h:187
FeatureNumList selFeatures
Definition: svm289_BFS.h:192
double ** pairwise_prob
Definition: svm289_BFS.h:206
svm_parameter param
Definition: svm289_BFS.h:184
SVM289_BFS::svm_model::svm_model ( const svm_parameter _param,
const FeatureNumList _selFeatures,
FileDescPtr  _fileDesc,
RunLog _log 
)

Definition at line 4215 of file svm289_BFS.cpp.

References dec_values, KKMLL::FeatureNumList::FeatureNumList(), l, label, nr_class, nSV, pairwise_prob, param, prob_estimates, probA, probB, rho, selFeatures, sv_coef, svm_model(), SVM289_BFS::svm_parameter::svm_parameter(), and weOwnSupportVectors.

Referenced by svm_model(), and SVM289_BFS::svm_train().

4219  :
4220  param (_param),
4221  nr_class (0),
4222  l (0),
4223  SV (_fileDesc, true),
4224  sv_coef (NULL),
4225  rho (NULL),
4226  probA (NULL),
4227  probB (NULL),
4228  label (NULL),
4229  nSV (NULL), // number of SVs for each class (nSV[k])
4230  weOwnSupportVectors (false),
4231  selFeatures (_selFeatures),
4232  dec_values (NULL),
4233  pairwise_prob (NULL),
4234  prob_estimates (NULL)
4235 
4236 {
4237 }
FeatureVectorList SV
Definition: svm289_BFS.h:187
FeatureNumList selFeatures
Definition: svm289_BFS.h:192
double ** pairwise_prob
Definition: svm289_BFS.h:206
svm_parameter param
Definition: svm289_BFS.h:184
SVM289_BFS::svm_model::svm_model ( istream &  _fileName,
FileDescPtr  _fileDesc,
RunLog _log 
)

Definition at line 4240 of file svm289_BFS.cpp.

References dec_values, KKMLL::FeatureNumList::FeatureNumList(), l, label, nr_class, nSV, pairwise_prob, param, prob_estimates, probA, probB, Read(), rho, selFeatures, sv_coef, svm_model(), SVM289_BFS::svm_parameter::svm_parameter(), and weOwnSupportVectors.

Referenced by svm_model().

4243  :
4244  param (),
4245  nr_class (0),
4246  l (0),
4247  SV (_fileDesc, true),
4248  sv_coef (NULL),
4249  rho (NULL),
4250  probA (NULL),
4251  probB (NULL),
4252  label (NULL),
4253  nSV (NULL), // number of SVs for each class (nSV[k])
4254  weOwnSupportVectors (false),
4255  selFeatures (_fileDesc),
4256  dec_values (NULL),
4257  pairwise_prob (NULL),
4258  prob_estimates (NULL)
4259 {
4260  Read (_in, _fileDesc, _log);
4261 }
FeatureVectorList SV
Definition: svm289_BFS.h:187
FeatureNumList selFeatures
Definition: svm289_BFS.h:192
double ** pairwise_prob
Definition: svm289_BFS.h:206
void Read(istream &i, FileDescPtr fileDesc, RunLog &log)
svm_parameter param
Definition: svm289_BFS.h:184
SVM289_BFS::svm_model::~svm_model ( )

Definition at line 4266 of file svm289_BFS.cpp.

References dec_values, label, nr_class, nSV, pairwise_prob, prob_estimates, probA, probB, rho, and sv_coef.

4267 {
4268  if (weOwnSupportVectors)
4269  SV.Owner (true);
4270  else
4271  SV.Owner (false);
4272 
4273  kkint32 i;
4274 
4275  if (sv_coef)
4276  {
4277  for (i = 0; i < (nr_class - 1); i++)
4278  delete sv_coef[i];
4279  delete sv_coef;
4280  sv_coef = NULL;
4281  }
4282 
4283  delete rho; rho = NULL;
4284  delete probA; probA = NULL;
4285  delete probB; probB = NULL;
4286  delete label; label = NULL;
4287  delete nSV; nSV = NULL;
4288 
4289  if (pairwise_prob)
4290  {
4291  for (i = 0; i < (nr_class - 1); i++)
4292  {
4293  delete pairwise_prob[i];
4294  pairwise_prob[i] = NULL;
4295  }
4296  delete pairwise_prob;
4297  pairwise_prob = NULL;
4298  }
4299 
4300  delete dec_values;
4301  dec_values = NULL;
4302  delete prob_estimates;
4303  prob_estimates = NULL;
4304 }
FeatureVectorList SV
Definition: svm289_BFS.h:187
__int32 kkint32
Definition: KKBaseTypes.h:88
double ** pairwise_prob
Definition: svm289_BFS.h:206
bool Owner() const
Definition: KKQueue.h:305

Member Function Documentation

double * SVM289_BFS::svm_model::DecValues ( )

Definition at line 4307 of file svm289_BFS.cpp.

References dec_values, and nr_class.

Referenced by SVM289_BFS::svm_predict_probability().

4308 {
4309  if (!dec_values)
4310  dec_values = new double[nr_class * (nr_class - 1) / 2];
4311  return dec_values;
4312 }
void SVM289_BFS::svm_model::NormalizeProbability ( )

Derining multiclass probability as done in "Recognizing Plankton Images From the SIPPER".

Definition at line 4619 of file svm289_BFS.cpp.

References nr_class, pairwise_prob, prob_estimates, and ProbEstimates().

Referenced by SVM289_BFS::svm_predict_probability().

4620 {
4621  // Make sure that the ProbEstimates array exists.
4622  ProbEstimates ();
4623 
4624  if (pairwise_prob == NULL)
4625  return;
4626 
4627  kkint32 x = 0;
4628  kkint32 y = 0;
4629  double totalProb = 0.0;
4630 
4631  for (x = 0; x < nr_class; x++)
4632  {
4633  prob_estimates[x] = 1.0;
4634  for (y = 0; y < nr_class; y++)
4635  {
4636  if (x != y)
4637  prob_estimates[x] *= pairwise_prob[x][y];
4638  }
4639 
4640  totalProb += prob_estimates[x];
4641  }
4642 
4643  for (x = 0; x < nr_class; x++)
4644  prob_estimates[x] /= totalProb;
4645 } /* NormalizeProbability */
__int32 kkint32
Definition: KKBaseTypes.h:88
double ** pairwise_prob
Definition: svm289_BFS.h:206
double ** SVM289_BFS::svm_model::PairwiseProb ( )

Definition at line 4323 of file svm289_BFS.cpp.

References nr_class, and pairwise_prob.

Referenced by SVM289_BFS::svm_predict_probability().

4324 {
4325  if (!pairwise_prob)
4326  {
4327  pairwise_prob = new double*[nr_class];
4328  for (kkint32 x = 0; x < nr_class; x++)
4329  pairwise_prob[x] = new double[nr_class];
4330  }
4331  return pairwise_prob;
4332 }
__int32 kkint32
Definition: KKBaseTypes.h:88
double ** pairwise_prob
Definition: svm289_BFS.h:206
double * SVM289_BFS::svm_model::ProbEstimates ( )

Definition at line 4315 of file svm289_BFS.cpp.

References nr_class, and prob_estimates.

Referenced by NormalizeProbability(), and SVM289_BFS::svm_predict_probability().

4316 {
4317  if (!prob_estimates)
4318  prob_estimates = new double[nr_class];
4319  return prob_estimates;
4320 }
void SVM289_BFS::svm_model::Read ( istream &  i,
FileDescPtr  fileDesc,
RunLog log 
)

Definition at line 4430 of file svm289_BFS.cpp.

References label, nSV, probA, probB, rho, and weOwnSupportVectors.

Referenced by svm_model().

4434 {
4435  // read parameters
4436  delete rho; rho = NULL;
4437  delete probA; probA = NULL;
4438  delete probB; probB = NULL;
4439  delete label; label = NULL;
4440  delete nSV; nSV = NULL;
4441 
4442  SV.DeleteContents ();
4443 
4444  kkint32 buffLen = 80 * 1024;
4445  char* buff = new char[buffLen];
4446 
4447  bool eof = false;
4448  bool eol = false;
4449 
4450  kkint32 numBinaryCombos = 0;
4451 
4452  while (!in.eof ())
4453  {
4454  in.getline (buff, sizeof (buffLen));
4455 
4456  KKStr line = buff;
4457 
4458  if (line.SubStrPart (0, 1) == "//")
4459  continue;
4460 
4461  KKStr fieldName = line.ExtractToken2 ("\t\n\r");
4462  if (fieldName.EqualIgnoreCase ("</Svm_Model>"))
4463  break;
4464 
4465  if (fieldName.EqualIgnoreCase ("svm_type"))
4466  {
4467  param.svm_type = SVM_Type_FromStr (line);
4469  {
4470  KKStr errorMsg = "SVM289_BFS::svm_model::Read ***ERROR*** Invalid SVM_Type[" + line + "].";
4471  log.Level (-1) << endl << errorMsg << endl << endl;
4472  delete buff;
4473  buff = NULL;
4474  throw errorMsg;
4475  }
4476  }
4477 
4478  else if (fieldName.EqualIgnoreCase ("kernel_type") == 0)
4479  {
4481  if (param.kernel_type == Kernel_NULL)
4482  {
4483  KKStr errorMsg = "SVM289_BFS::svm_model::Read ***ERROR*** Invalid kernel_type[" + line + "].";
4484  log.Level (-1) << endl << errorMsg << endl << endl;
4485  delete[] buff; buff = NULL;
4486  throw errorMsg;
4487  }
4488  }
4489 
4490  else if (fieldName.EqualIgnoreCase ("degree"))
4491  param.degree = line.ExtractTokenInt ("\t\n\r");
4492 
4493  else if (fieldName.EqualIgnoreCase ("gamma"))
4494  param.gamma = line.ExtractTokenDouble ("\t\n\r");
4495 
4496  else if (fieldName.EqualIgnoreCase ("coef0"))
4497  param.coef0 = line.ExtractTokenDouble ("\t\n\r");
4498 
4499  else if (fieldName.EqualIgnoreCase ("nr_class"))
4500  {
4501  nr_class = line.ExtractTokenInt ("\t\n\r");
4502  numBinaryCombos = nr_class * (nr_class - 1) / 2;
4503  }
4504 
4505  else if (fieldName.EqualIgnoreCase ("total_sv"))
4506  l = line.ExtractTokenInt ("\t\n\r");
4507 
4508  else if (fieldName.EqualIgnoreCase ("rho"))
4509  {
4510  rho = new double[numBinaryCombos];
4511  for (kkint32 i = 0; i < numBinaryCombos; i++)
4512  rho[i] = line.ExtractTokenDouble ("\t\n\r");
4513  }
4514 
4515  else if (fieldName.EqualIgnoreCase ("label"))
4516  {
4517  label = new kkint32[nr_class];
4518  for (kkint32 i=0; i < nr_class; i++)
4519  label[i] = line.ExtractTokenInt ("\t\n\r");
4520  }
4521 
4522  else if (fieldName.EqualIgnoreCase ("probA"))
4523  {
4524  probA = new double[numBinaryCombos];
4525  for (kkint32 i = 0; i < numBinaryCombos; i++)
4526  probA[i] = line.ExtractTokenDouble ("\t\n\r");
4527  }
4528 
4529  else if (fieldName.EqualIgnoreCase ("probB"))
4530  {
4531  probB = new double[numBinaryCombos];
4532  for (kkint32 i = 0; i < numBinaryCombos; i++)
4533  probB[i] = line.ExtractTokenDouble ("\t\n\r");
4534  }
4535 
4536  else if (fieldName.EqualIgnoreCase ("nr_sv"))
4537  {
4538  nSV = new kkint32[nr_class];
4539  for (kkint32 i = 0; i < nr_class; i++)
4540  nSV[i] = line.ExtractTokenInt ("\t\n\r");
4541  }
4542 
4543  else if (fieldName.EqualIgnoreCase ("SelFeatures"))
4544  {
4545  bool valid = false;
4546  selFeatures = FeatureNumList (line, valid);
4547  }
4548 
4549 
4550  else if (fieldName.EqualIgnoreCase ("SupportVector"))
4551  {
4552  // read sv_coef and SV
4553 
4554  kkint32 m = nr_class - 1;
4555  kkint32 i, j;
4556 
4557  if (!sv_coef)
4558  {
4559  sv_coef = new double*[m];
4560  for (i = 0; i < m; i++)
4561  {
4562  sv_coef[i] = new double[l];
4563  for (j = 0; j < l; j++)
4564  sv_coef[i][j] = 0.0;
4565  }
4566  }
4567 
4568  if (SV.QueueSize () >= l)
4569  {
4570  KKStr errorMsg = "SVM289_BFS::svm_model::Read ***ERROR*** To many Support Vector's Defined.";
4571  log.Level (-1) << endl << errorMsg << endl << endl;
4572  delete[] buff;
4573  throw errorMsg;
4574  }
4575 
4576  // We are now going to process one line per SV.
4577  j = 0;
4578  eof = false;
4579 
4580  KKStr imageFileName = line.ExtractToken2 ("\t");
4581  //model->SV[i] = &x_space[j];
4582  FeatureVectorPtr fv = new FeatureVector (fileDesc->NumOfFields ());
4583  fv->ExampleFileName (imageFileName);
4584 
4585  for (j = 0; (j < (nr_class - 1)) && (!eol); j++)
4586  sv_coef[j][i] = line.ExtractTokenDouble ("\t");
4587 
4588  if (param.kernel_type == PRECOMPUTED)
4589  {
4590  log.Level (-1) << endl << endl
4591  << "SVM289_BFS::svm_model::Read ***ERROR*** PRECOMPUTED Can not Handle." << endl
4592  << endl;
4593  }
4594  else
4595  {
4596  for (kkuint32 zed = 0; (zed < fileDesc->NumOfFields ()) && (!eol); zed++)
4597  {
4598  KKStr featureField = line.ExtractToken2 ("\t");
4599  kkint32 featureNum = featureField.ExtractTokenInt (":");
4600  float featureValue = (float)featureField.ExtractTokenDouble ("\t\n\r");
4601  fv->FeatureData (featureNum, featureValue);
4602  }
4603  }
4604  SV.PushOnBack (fv);
4605  }
4606  }
4607 
4608  delete[] buff;
4609  buff = NULL;
4610  weOwnSupportVectors = true; // XXX
4611  SV.Owner (true);
4612 } /* Read */
FeatureVectorList SV
Definition: svm289_BFS.h:187
void ExampleFileName(const KKStr &_exampleFileName)
Name of source of feature vector, ex: file name of image that the feature vector was computed from...
Definition: FeatureVector.h:75
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void PushOnBack(FeatureVectorPtr image)
Overloading the PushOnBack function in KKQueue so we can monitor the Version and Sort Order...
__int32 kkint32
Definition: KKBaseTypes.h:88
kkuint32 NumOfFields() const
Definition: FileDesc.h:197
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
Keeps track of selected features.
FeatureNumList selFeatures
Definition: svm289_BFS.h:192
Kernel_Type Kernel_Type_FromStr(KKStr s)
Definition: svm289_BFS.cpp:575
void DeleteContents()
Definition: KKQueue.h:321
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
bool Owner() const
Definition: KKQueue.h:305
double ExtractTokenDouble(const char *delStr)
Definition: KKStr.cpp:3180
void FeatureData(kkint32 _featureNum, float _featureValue)
Assign a value to a specific feature number for the feature vector.
kkint32 ExtractTokenInt(const char *delStr)
Definition: KKStr.cpp:3129
SVM_Type SVM_Type_FromStr(KKStr s)
Definition: svm289_BFS.cpp:536
kkint32 QueueSize() const
Definition: KKQueue.h:313
Represents a Feature Vector of a single example, labeled or unlabeled.
Definition: FeatureVector.h:59
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
svm_parameter param
Definition: svm289_BFS.h:184
void SVM289_BFS::svm_model::Write ( ostream &  o)

Definition at line 4335 of file svm289_BFS.cpp.

References KKMLL::FeatureVector::ExampleFileName(), SVM289_BFS::svm_parameter::kernel_type, l, label, nr_class, nSV, KKB::operator<<(), param, SVM289_BFS::PRECOMPUTED, probA, and probB.

4336 {
4337  o << "<Svm_Model>" << endl;
4338  o << "svm_type" << "\t" << SVM_Type_ToStr (param.svm_type) << endl;
4339  o << "kernel_type" << "\t" << Kernel_Type_ToStr (param.kernel_type) << endl;
4340 
4341  if (param.kernel_type == POLY)
4342  o << "degree" << "\t" << param.degree << endl;
4343 
4345  o << "gamma" << "\t" << param.gamma << endl;
4346 
4348  o << "coef0" << "\t" << param.coef0 << endl;
4349 
4350  o << "SelFeatures" << "\t" << selFeatures.ToCommaDelStr () << endl;
4351 
4352  o << "nr_class" << "\t" << nr_class << endl;
4353  kkint32 numBinaryCombos = nr_class * (nr_class - 1) / 2;
4354 
4355  o << "total_sv" << "\t" << l << endl;
4356 
4357  {
4358  o << "rho";
4359  for (kkint32 i = 0; numBinaryCombos; i++)
4360  o << "\t" << rho[i];
4361  o << endl;
4362  }
4363 
4364  if (label)
4365  {
4366  o << "label";
4367  for (kkint32 i = 0; i < nr_class; i++)
4368  o << "\t" << label[i];
4369  o << endl;
4370  }
4371 
4372  if (probA) // regression has probA only
4373  {
4374  o << "probA";
4375  for (kkint32 i = 0; i < numBinaryCombos; i++)
4376  o << "\t" << probA[i];
4377  o << endl;
4378  }
4379 
4380  if (probB)
4381  {
4382  o << "probB";
4383  for (kkint32 i = 0; i < numBinaryCombos; i++)
4384  o << "\t" << probB[i];
4385  o << endl;
4386  }
4387 
4388  if (nSV)
4389  {
4390  o << "nr_sv";
4391  for (kkint32 i = 0; i < nr_class; i++)
4392  o << "\t" << nSV[i];
4393  o << endl;
4394  }
4395 
4396  for (kkint32 i = 0; i < l; i++)
4397  {
4398  const FeatureVector& p = SV[i];
4399  o << "SupportVector" << "\t" << p.ExampleFileName ();
4400 
4401  kkint32 origPrec = (kkint32)o.precision ();
4402  o.precision (16);
4403  for (kkint32 j = 0; j < nr_class - 1; j++)
4404  {
4405  //fprintf (fp, "%.16g ", sv_coef[j][i]);
4406  o << "\t" << sv_coef[j][i];
4407  }
4408 
4409  //const svm_node *p = SV[i];
4410  o.precision (8);
4411 
4412  if (param.kernel_type == PRECOMPUTED)
4413  {
4414  //fprintf(fp,"0:%d ",(kkint32)(p->value));
4415  o << "\t" << p.FeatureData (0);
4416  }
4417  else
4418  {
4419  for (kkint32 zed = 0; zed < p.NumOfFeatures (); zed++)
4420  o << "\t" << zed << ":" << p.FeatureData (zed);
4421  }
4422  o << endl;
4423  }
4424 
4425  o << "</Svm_Model>" << endl;
4426 } /* Write */
FeatureVectorList SV
Definition: svm289_BFS.h:187
void ExampleFileName(const KKStr &_exampleFileName)
Name of source of feature vector, ex: file name of image that the feature vector was computed from...
Definition: FeatureVector.h:75
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__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
kkint32 NumOfFeatures() const
Number of features in this FeatureVector.
FeatureNumList selFeatures
Definition: svm289_BFS.h:192
void FeatureData(kkint32 _featureNum, float _featureValue)
Assign a value to a specific feature number for the feature vector.
Represents a Feature Vector of a single example, labeled or unlabeled.
Definition: FeatureVector.h:59
svm_parameter param
Definition: svm289_BFS.h:184
KKStr ToCommaDelStr() const

Member Data Documentation

double* SVM289_BFS::svm_model::dec_values

Definition at line 205 of file svm289_BFS.h.

Referenced by DecValues(), svm_model(), and ~svm_model().

kkint32 SVM289_BFS::svm_model::l

total SV

Definition at line 186 of file svm289_BFS.h.

Referenced by svm_model(), SVM289_BFS::svm_predict_values(), SVM289_BFS::svm_train(), and Write().

kkint32* SVM289_BFS::svm_model::label
kkint32* SVM289_BFS::svm_model::nSV

number of SVs for each class (nSV[k])

Definition at line 197 of file svm289_BFS.h.

Referenced by Read(), svm_model(), SVM289_BFS::svm_predict_values(), SVM289_BFS::svm_train(), Write(), and ~svm_model().

double** SVM289_BFS::svm_model::pairwise_prob

Definition at line 206 of file svm289_BFS.h.

Referenced by NormalizeProbability(), PairwiseProb(), svm_model(), and ~svm_model().

double* SVM289_BFS::svm_model::prob_estimates

Definition at line 207 of file svm289_BFS.h.

Referenced by NormalizeProbability(), ProbEstimates(), svm_model(), and ~svm_model().

double* SVM289_BFS::svm_model::probA
double* SVM289_BFS::svm_model::probB
double* SVM289_BFS::svm_model::rho

constants in decision functions (rho[k*(k-1)/2])

Definition at line 189 of file svm289_BFS.h.

Referenced by Read(), svm_model(), SVM289_BFS::svm_predict_values(), SVM289_BFS::svm_train(), and ~svm_model().

FeatureNumList SVM289_BFS::svm_model::selFeatures

Definition at line 192 of file svm289_BFS.h.

Referenced by svm_model().

FeatureVectorList SVM289_BFS::svm_model::SV

SVs (SV[l])

Definition at line 187 of file svm289_BFS.h.

double** SVM289_BFS::svm_model::sv_coef

Coefficients for SVs in decision functions (sv_coef[k-1][l])

Definition at line 188 of file svm289_BFS.h.

Referenced by svm_model(), SVM289_BFS::svm_predict_values(), SVM289_BFS::svm_train(), and ~svm_model().

bool SVM289_BFS::svm_model::weOwnSupportVectors

Definition at line 200 of file svm289_BFS.h.

Referenced by Read(), svm_model(), and SVM289_BFS::svm_train().


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