KSquare Utilities
svm289_BFS.cpp File Reference
#include "FirstIncludes.h"
#include <ctype.h>
#include <float.h>
#include <fstream>
#include <iostream>
#include <istream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <stdarg.h>
#include <vector>
#include <string.h>
#include "MemoryDebug.h"
#include "KKException.h"
#include "KKStr.h"
#include "OSservices.h"
#include "FeatureVector.h"
#include "svm289_BFS.h"

Go to the source code of this file.

Classes

class  SVM289_BFS::Cache
 
struct  SVM289_BFS::decision_function
 
class  SVM289_BFS::Kernel
 
class  SVM289_BFS::ONE_CLASS_Q
 
class  SVM289_BFS::QMatrix
 
class  SVM289_BFS::Solver
 
struct  SVM289_BFS::Solver::SolutionInfo
 
class  SVM289_BFS::Solver_NU
 
class  SVM289_BFS::SVC_Q
 
class  SVM289_BFS::SVR_Q
 

Namespaces

 SVM289_BFS
 Namespace used to wrap implementation of libSVM version 2.89 to be used as a pair-wise SVM.
 

Macros

#define INF   HUGE_VAL
 
#define TAU   1e-12
 

Functions

template<class T >
T * SVM289_BFS::GrowAllocation (T *src, kkint32 origSize, kkint32 newSize)
 
static void info (const char *fmt,...)
 
void SVM289_BFS::multiclass_probability (kkint32 k, double **r, double *p)
 
double SVM289_BFS::powi (double base, kkint32 times)
 
static void print_string_stdout (const char *s)
 
double SVM289_BFS::sigmoid_predict (double decision_value, double A, double B)
 
void SVM289_BFS::sigmoid_train (kkint32 l, const double *dec_values, const double *labels, double &A, double &B)
 
void SVM289_BFS::solve_c_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, double Cp, double Cn, RunLog &_log)
 
void SVM289_BFS::solve_epsilon_svr (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, RunLog &_log)
 
void SVM289_BFS::solve_nu_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, RunLog &_log)
 
static void solve_nu_svr (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, RunLog &_log)
 
void SVM289_BFS::solve_one_class (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, RunLog &_log)
 
void svm_binary_svc_probability (const svm_problem *prob, const svm_parameter *param, double Cp, double Cn, double &probA, double &probB, RunLog &log)
 
const char * svm_check_parameter (const svm_problem *prob, const svm_parameter *param)
 
kkint32 svm_check_probability_model (const svm_model *model)
 
void SVM289_BFS::svm_cross_validation (const svm_problem &prob, const svm_parameter &param, kkint32 nr_fold, double *target, RunLog &log)
 
void svm_destroy_param (svm_parameter *&param)
 
void svm_get_labels (const svm_model *model, kkint32 *label)
 
SVM_Type svm_get_svm_type (const svm_model *model)
 
double svm_get_svr_probability (const svm_model *model)
 
void svm_group_classes (const svm_problem *prob, kkint32 *nr_class_ret, kkint32 **label_ret, kkint32 **start_ret, kkint32 **count_ret, kkint32 *perm)
 
double svm_svr_probability (const svm_problem &prob, const svm_parameter &param, RunLog &log)
 
decision_function SVM289_BFS::svm_train_one (const svm_problem &prob, const svm_parameter &param, double Cp, double Cn, RunLog &_log)
 

Macro Definition Documentation

#define INF   HUGE_VAL

Definition at line 109 of file svm289_BFS.cpp.

#define TAU   1e-12

Definition at line 110 of file svm289_BFS.cpp.

Function Documentation

static void info ( const char *  fmt,
  ... 
)
static

Definition at line 626 of file svm289_BFS.cpp.

Referenced by SVM289_BFS::Solver::do_shrinking(), SVM289_BFS::multiclass_probability(), SVM289_BFS::Solver::reconstruct_gradient(), SVM289_BFS::sigmoid_train(), SVM289_BFS::Solver::Solve(), SVM289_BFS::solve_epsilon_svr(), SVM289_BFS::solve_nu_svc(), solve_nu_svr(), svm_svr_probability(), and SVM289_BFS::svm_train().

627 {
628  char buf[BUFSIZ];
629  va_list ap;
630  va_start(ap,fmt);
631 
632 #if defined(USE_SECURE_FUNCS)
633  vsprintf_s(buf, BUFSIZ, fmt, ap);
634 #else
635  vsprintf(buf,fmt,ap);
636 #endif
637 
638  va_end(ap);
639  (*SVM289_BFS::svm_print_string)(buf);
640 }
static void print_string_stdout ( const char *  s)
static

Definition at line 617 of file svm289_BFS.cpp.

618 {
619  fputs(s,stdout);
620  fflush(stdout);
621 }
static void solve_nu_svr ( const svm_problem prob,
const svm_parameter param,
double *  alpha,
Solver::SolutionInfo si,
RunLog _log 
)
static

Definition at line 2709 of file svm289_BFS.cpp.

References SVM289_BFS::svm_parameter::C, SVM289_BFS::svm_parameter::eps, info(), SVM289_BFS::svm_problem::l, SVM289_BFS::svm_parameter::nu, SVM289_BFS::Solver::SolutionInfo::r, SVM289_BFS::svm_parameter::shrinking, SVM289_BFS::Solver_NU::Solve(), SVM289_BFS::SVR_Q::SVR_Q(), and SVM289_BFS::svm_problem::y.

Referenced by SVM289_BFS::svm_train_one().

2715 {
2716  kkint32 l = prob->l;
2717  double C = param->C;
2718 
2719  double* alpha2 = new double [2 * l];
2720  double* linear_term = new double [2 * l];
2721  schar* y = new schar [2 * l];
2722  kkint32 i;
2723 
2724  double sum = C * param->nu * l / 2;
2725 
2726  for (i = 0; i < l; i++)
2727  {
2728  alpha2[i] = alpha2[i + l] = Min (sum, C);
2729  sum -= alpha2[i];
2730 
2731  linear_term[i] = - prob->y[i];
2732  y [i] = 1;
2733 
2734  linear_term[i + l] = prob->y[i];
2735  y [i + l] = -1;
2736  }
2737 
2738 
2739  SVR_Q* jester = new SVR_Q (*prob, *param, _log);
2740  Solver_NU s;
2741  s.Solve (2 * l,
2742  *jester,
2743  linear_term,
2744  y,
2745  alpha2,
2746  C,
2747  C,
2748  param->eps,
2749  si,
2750  param->shrinking
2751  );
2752  delete jester;
2753  jester = NULL;
2754 
2755  info ("epsilon = %f\n", -si->r);
2756 
2757  for (i = 0; i < l; i++)
2758  alpha[i] = alpha2[i] - alpha2[i + l];
2759 
2760  delete[] alpha2;
2761  delete[] linear_term;
2762  delete[] y;
2763 } /* solve_nu_svr */
__int32 kkint32
Definition: KKBaseTypes.h:88
static void info(const char *fmt,...)
Definition: svm289_BFS.cpp:626
void Solve(kkint32 l, QMatrix &Q, const double *p, const schar *y, double *alpha, double Cp, double Cn, double eps, SolutionInfo *si, kkint32 shrinking)
signed char schar
Definition: svm289_BFS.h:271
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
void svm_binary_svc_probability ( const svm_problem prob,
const svm_parameter param,
double  Cp,
double  Cn,
double &  probA,
double &  probB,
RunLog log 
)

Definition at line 3131 of file svm289_BFS.cpp.

References SVM289_BFS::svm_parameter::C, SVM289_BFS::svm_problem::l, SVM289_BFS::svm_model::label, SVM289_BFS::svm_parameter::nr_weight, SVM289_BFS::svm_parameter::probability, KKMLL::FeatureVectorList::PushOnBack(), SVM289_BFS::svm_problem::selFeatures, SVM289_BFS::sigmoid_train(), SVM289_BFS::svm_problem::svm_problem(), SVM289_BFS::svm_train(), SVM289_BFS::svm_parameter::weight, SVM289_BFS::svm_parameter::weight_label, and SVM289_BFS::svm_problem::y.

Referenced by SVM289_BFS::svm_train().

3139 {
3140  kkint32 i;
3141  kkint32 nr_fold = 5;
3142  kkint32 *perm = new kkint32[prob->l];
3143 
3144  FeatureVectorPtr* subX = NULL;
3145  svm_problem* subProb = NULL;
3146 
3147  double *dec_values = new double[prob->l];
3148 
3149  // random shuffle
3150  for (i = 0; i < prob->l; i++)
3151  perm[i]=i;
3152 
3153  for (i = 0; i < prob->l; i++)
3154  {
3155  kkint32 j = i + rand() % (prob->l-i);
3156  SVM289_BFS::swap (perm[i], perm[j]);
3157  }
3158 
3159  for (i = 0; i < nr_fold; i++)
3160  {
3161  kkint32 begin = i * prob->l / nr_fold;
3162  kkint32 end = (i + 1) * prob->l / nr_fold;
3163  kkint32 j, k;
3164 
3165  kkint32 subL = prob->l - (end - begin);
3166  subX = new FeatureVectorPtr[subL];
3167  for (j = 0; j < subL; j++)
3168  subX[j] = NULL;
3169  float* subY = new float[subL];
3170 
3171  k = 0;
3172  for (j = 0; j < begin; j++)
3173  {
3174  subX[k] = prob->x.IdxToPtr (perm[j]);
3175  subY[k] = (float)prob->y[perm[j]];
3176  ++k;
3177  }
3178 
3179  for (j = end; j < prob->l; j++)
3180  {
3181  subX[k] = prob->x.IdxToPtr (perm[j]);
3182  subY[k] = (float)prob->y[perm[j]];
3183  ++k;
3184  }
3185 
3186  {
3187  FeatureVectorListPtr subXX = new FeatureVectorList (prob->x.FileDesc (), false);
3188  for (j = 0; j < k; j++)
3189  subXX->PushOnBack (subX[j]);
3190  subProb = new svm_problem (*subXX, subY, prob->selFeatures);
3191  delete subXX;
3192  }
3193 
3194  kkint32 p_count=0, n_count = 0;
3195 
3196  for (j = 0; j < k; j++)
3197  {
3198  if (subY[j] > 0)
3199  p_count++;
3200  else
3201  n_count++;
3202  }
3203 
3204 
3205  if ((p_count == 0) && (n_count == 0))
3206  {
3207  for (j = begin; j < end; j++)
3208  dec_values[perm[j]] = 0;
3209  }
3210 
3211  else if ((p_count > 0) && (n_count == 0))
3212  {
3213  for (j = begin; j < end; j++)
3214  dec_values[perm[j]] = 1;
3215  }
3216 
3217  else if ((p_count == 0) && (n_count > 0))
3218  {
3219  for (j = begin; j < end; j++)
3220  dec_values[perm[j]] = -1;
3221  }
3222 
3223  else
3224  {
3225  svm_parameter subparam = *param;
3226  subparam.probability=0;
3227  subparam.C=1.0;
3228  subparam.nr_weight=2;
3229  subparam.weight_label = new kkint32[2];
3230  subparam.weight = new double[2];
3231  subparam.weight_label[0]=+1;
3232  subparam.weight_label[1]=-1;
3233  subparam.weight[0]=Cp;
3234  subparam.weight[1]=Cn;
3235  svm_model* submodel = svm_train (*subProb, subparam, log);
3236 
3237  for (j = begin; j < end; j++)
3238  {
3239  svm_predict_values (submodel, prob->x[perm[j]], &(dec_values[perm[j]]));
3240  // ensure +1 -1 order; reason not using CV subroutine
3241  dec_values[perm[j]] *= submodel->label[0];
3242  }
3243 
3244  delete submodel; submodel = NULL;
3245  //svm_destroy_param (&subparam);
3246  }
3247 
3248  delete subProb; subProb = NULL;
3249  delete subX; subX = NULL;
3250  delete subY; subY = NULL;
3251  }
3252 
3253  sigmoid_train (prob->l, dec_values, prob->y, probA, probB);
3254  delete dec_values; dec_values = NULL;
3255  delete perm; perm = NULL;
3256 } /* svm_binary_svc_probability */
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
const FileDescPtr FileDesc() const
EntryPtr IdxToPtr(kkuint32 idx) const
Definition: KKQueue.h:732
struct SvmModel233 * svm_train(const struct svm_problem *prob, const struct svm_parameter *param)
FeatureVectorList x
Definition: svm289_BFS.h:61
Container class for FeatureVector derived objects.
void sigmoid_train(kkint32 l, const double *dec_values, const double *labels, double &A, double &B)
void swap(T &x, T &y)
Definition: svm289_BFS.h:265
FeatureNumList selFeatures
Definition: svm289_BFS.h:60
Represents a Feature Vector of a single example, labeled or unlabeled.
Definition: FeatureVector.h:59
void svm_predict_values(const Svm_Model *model, const FeatureVector &x, double *dec_values)
Definition: svm2.cpp:3856
const char* svm_check_parameter ( const svm_problem prob,
const svm_parameter param 
)

Definition at line 4672 of file svm289_BFS.cpp.

References SVM289_BFS::svm_parameter::C, SVM289_BFS::C_SVC, SVM289_BFS::svm_parameter::cache_size, SVM289_BFS::svm_parameter::degree, SVM289_BFS::svm_parameter::eps, SVM289_BFS::EPSILON_SVR, SVM289_BFS::svm_parameter::kernel_type, SVM289_BFS::svm_problem::l, SVM289_BFS::LINEAR, SVM289_BFS::svm_parameter::nu, SVM289_BFS::NU_SVC, SVM289_BFS::NU_SVR, SVM289_BFS::ONE_CLASS, SVM289_BFS::svm_parameter::p, SVM289_BFS::POLY, SVM289_BFS::PRECOMPUTED, SVM289_BFS::svm_parameter::probability, SVM289_BFS::RBF, SVM289_BFS::svm_parameter::shrinking, SVM289_BFS::SIGMOID, SVM289_BFS::svm_parameter::svm_type, and SVM289_BFS::svm_problem::y.

4675 {
4676  // svm_type
4677 
4678  SVM_Type svm_type = param->svm_type;
4679 
4680  if (svm_type != SVM_Type::C_SVC &&
4681  svm_type != SVM_Type::NU_SVC &&
4682  svm_type != SVM_Type::ONE_CLASS &&
4683  svm_type != SVM_Type::EPSILON_SVR &&
4684  svm_type != SVM_Type::NU_SVR
4685  )
4686  return "unknown svm type";
4687 
4688  // kernel_type, degree
4689 
4690  kkint32 kernel_type = param->kernel_type;
4691 
4692  if (kernel_type != LINEAR &&
4693  kernel_type != POLY &&
4694  kernel_type != RBF &&
4695  kernel_type != SIGMOID &&
4696  kernel_type != PRECOMPUTED
4697  )
4698  return "unknown kernel type";
4699 
4700  if (param->degree < 0)
4701  return "degree of polynomial kernel < 0";
4702 
4703  // cache_size,eps,C,nu,p,shrinking
4704 
4705  if (param->cache_size <= 0)
4706  return "cache_size <= 0";
4707 
4708  if (param->eps <= 0)
4709  return "eps <= 0";
4710 
4711  if (svm_type == SVM_Type::C_SVC ||
4712  svm_type == SVM_Type::EPSILON_SVR ||
4713  svm_type == SVM_Type::NU_SVR
4714  )
4715  if (param->C <= 0)
4716  return "C <= 0";
4717 
4718  if (svm_type == SVM_Type::NU_SVC ||
4719  svm_type == SVM_Type::ONE_CLASS ||
4720  svm_type == SVM_Type::NU_SVR
4721  )
4722  if ((param->nu <= 0) || (param->nu > 1))
4723  return "nu <= 0 or nu > 1";
4724 
4725  if (svm_type == SVM_Type::EPSILON_SVR)
4726  {
4727  if (param->p < 0)
4728  return "p < 0";
4729  }
4730 
4731  if (param->shrinking != 0 && param->shrinking != 1)
4732  return "shrinking != 0 and shrinking != 1";
4733 
4734  if ((param->probability != 0) && (param->probability != 1))
4735  return "probability != 0 and probability != 1";
4736 
4737  if ((param->probability == 1) && (svm_type == SVM_Type::ONE_CLASS))
4738  return "one-class SVM probability output not supported yet";
4739 
4740 
4741  // check whether nu-svc is feasible
4742 
4743  if (svm_type == SVM_Type::NU_SVC)
4744  {
4745  kkint32 l = prob->l;
4746  kkint32 max_nr_class = 16;
4747  kkint32 nr_class = 0;
4748  kkint32* label = new kkint32[max_nr_class];
4749  kkint32* count = new kkint32[max_nr_class];
4750 
4751  kkint32 i;
4752  for (i = 0; i < l; i++)
4753  {
4754  kkint32 this_label = (kkint32)prob->y[i];
4755  kkint32 j;
4756  for (j = 0; j < nr_class; j++)
4757  {
4758  if (this_label == label[j])
4759  {
4760  ++count[j];
4761  break;
4762  }
4763  }
4764 
4765  if (j == nr_class)
4766  {
4767  if (nr_class == max_nr_class)
4768  {
4769  kkint32 oldMaxNrClass = max_nr_class;
4770  max_nr_class *= 2;
4771  label = GrowAllocation (label, oldMaxNrClass, max_nr_class);
4772  count = GrowAllocation (count, oldMaxNrClass, max_nr_class);
4773  }
4774  label[nr_class] = this_label;
4775  count[nr_class] = 1;
4776  ++nr_class;
4777  }
4778  }
4779 
4780 
4781  for (i = 0; i < nr_class; i++)
4782  {
4783  kkint32 n1 = count[i];
4784  for (kkint32 j = i + 1; j < nr_class; j++)
4785  {
4786  kkint32 n2 = count[j];
4787  if ((param->nu * (n1 + n2) / 2) > Min (n1, n2))
4788  {
4789  delete[] label; label = NULL;
4790  delete[] count; count = NULL;
4791  return "specified nu is infeasible";
4792  }
4793  }
4794  }
4795 
4796  delete[] label; label = NULL;
4797  delete[] count; count = NULL;
4798  }
4799 
4800  return NULL;
4801 } /* svm_check_parameter */
__int32 kkint32
Definition: KKBaseTypes.h:88
T * GrowAllocation(T *src, kkint32 origSize, kkint32 newSize)
Definition: svm289_BFS.cpp:78
#define LINEAR
Definition: UsfCasCor.h:221
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
#define SIGMOID
Definition: UsfCasCor.h:219
kkint32 svm_check_probability_model ( const svm_model model)
void svm_destroy_param ( svm_parameter *&  param)

Definition at line 4664 of file svm289_BFS.cpp.

4665 {
4666  delete param;
4667  param = NULL;
4668 }
void svm_get_labels ( const svm_model model,
kkint32 label 
)

Definition at line 3869 of file svm289_BFS.cpp.

References SVM289_BFS::svm_model::label, and SVM289_BFS::svm_model::nr_class.

3872 {
3873  if (model->label != NULL)
3874  for(kkint32 i=0;i<model->nr_class;i++)
3875  label[i] = model->label[i];
3876 }
__int32 kkint32
Definition: KKBaseTypes.h:88
SVM_Type svm_get_svm_type ( const svm_model model)

Definition at line 3854 of file svm289_BFS.cpp.

References SVM289_BFS::svm_model::param, and SVM289_BFS::svm_parameter::svm_type.

3855 {
3856  return model->param.svm_type;
3857 }
svm_parameter param
Definition: svm289_BFS.h:184
double svm_get_svr_probability ( const svm_model model)

Definition at line 3880 of file svm289_BFS.cpp.

References SVM289_BFS::EPSILON_SVR, SVM289_BFS::NU_SVR, SVM289_BFS::svm_model::param, SVM289_BFS::svm_model::probA, and SVM289_BFS::svm_parameter::svm_type.

3881 {
3882  if ((model->param.svm_type == SVM_Type::EPSILON_SVR || model->param.svm_type == SVM_Type::NU_SVR) &&
3883  model->probA!=NULL)
3884  return model->probA[0];
3885  else
3886  {
3887  fprintf(stderr,"Model doesn't contain information for SVR probability inference\n");
3888  return 0;
3889  }
3890 }
svm_parameter param
Definition: svm289_BFS.h:184
void svm_group_classes ( const svm_problem prob,
kkint32 nr_class_ret,
kkint32 **  label_ret,
kkint32 **  start_ret,
kkint32 **  count_ret,
kkint32 perm 
)

Definition at line 3310 of file svm289_BFS.cpp.

References SVM289_BFS::svm_problem::l, and SVM289_BFS::svm_problem::y.

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

3317 {
3318  kkint32 l = prob->l;
3319  kkint32 max_nr_class = 16;
3320  kkint32 nr_class = 0;
3321  kkint32 *label = new kkint32[max_nr_class];
3322  kkint32 *count = new kkint32[max_nr_class];
3323  kkint32 *data_label = new kkint32[l];
3324  kkint32 i;
3325 
3326  // Count number of examples in each class
3327  for (i = 0; i < l; i++)
3328  {
3329  kkint32 this_label = (kkint32)prob->y[i];
3330  kkint32 j;
3331  for (j = 0; j < nr_class; j++)
3332  {
3333  if (this_label == label[j])
3334  {
3335  ++count[j];
3336  break;
3337  }
3338  }
3339 
3340  data_label[i] = j;
3341  if (j == nr_class)
3342  {
3343  // We have a new class
3344  if (nr_class == max_nr_class)
3345  {
3346  kkint32 newMaxNumClass = max_nr_class * 2;
3347  label = GrowAllocation (label, max_nr_class, newMaxNumClass);
3348  count = GrowAllocation (count, max_nr_class, newMaxNumClass);
3349  max_nr_class = newMaxNumClass;
3350  }
3351  label[nr_class] = this_label;
3352  count[nr_class] = 1;
3353  ++nr_class;
3354  }
3355  }
3356 
3357  kkint32 *start = new kkint32[nr_class];
3358  start[0] = 0;
3359  for (i = 1; i < nr_class; i++)
3360  start[i] = start[i - 1] + count[i - 1];
3361 
3362  for (i = 0; i < l; i++)
3363  {
3364  perm[start[data_label[i]]] = i;
3365  ++start[data_label[i]];
3366  }
3367 
3368  start[0] = 0;
3369  for (i = 1; i < nr_class; i++)
3370  start[i] = start[i - 1] + count[i - 1];
3371 
3372  *nr_class_ret = nr_class;
3373  *label_ret = label;
3374  *start_ret = start;
3375  *count_ret = count;
3376  delete data_label; data_label = NULL;
3377 } /* svm_group_classes*/
__int32 kkint32
Definition: KKBaseTypes.h:88
T * GrowAllocation(T *src, kkint32 origSize, kkint32 newSize)
Definition: svm289_BFS.cpp:78
double svm_svr_probability ( const svm_problem prob,
const svm_parameter param,
RunLog log 
)

Definition at line 3265 of file svm289_BFS.cpp.

References info(), SVM289_BFS::svm_problem::l, SVM289_BFS::svm_parameter::probability, SVM289_BFS::svm_cross_validation(), and SVM289_BFS::svm_problem::y.

Referenced by SVM289_BFS::svm_train().

3269 {
3270  kkint32 i;
3271  kkint32 nr_fold = 5;
3272  double *ymv = new double[prob.l];
3273  double mae = 0;
3274 
3275  svm_parameter newparam = param;
3276  newparam.probability = 0;
3277  svm_cross_validation (prob, newparam, nr_fold, ymv, log);
3278 
3279  for (i = 0; i < prob.l; i++)
3280  {
3281  ymv[i] = prob.y[i] - ymv[i];
3282  mae += fabs (ymv[i]);
3283  }
3284 
3285  mae /= prob.l;
3286  double std = sqrt (2 * mae * mae);
3287  kkint32 count = 0;
3288  mae = 0;
3289  for (i = 0; i < prob.l; i++)
3290  {
3291  if (fabs(ymv[i]) > (5 * std))
3292  count = count + 1;
3293  else
3294  mae += fabs (ymv[i]);
3295  }
3296 
3297  mae /= (prob.l - count);
3298 
3299  info("Prob. model for test data: target value = predicted value + z,\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma= %g\n", mae);
3300  delete ymv; ymv = NULL;
3301  return mae;
3302 } /* svm_svr_probability */
void svm_cross_validation(const svm_problem &prob, const svm_parameter &param, kkint32 nr_fold, double *target, RunLog &log)
__int32 kkint32
Definition: KKBaseTypes.h:88
static void info(const char *fmt,...)
Definition: svm289_BFS.cpp:626