parameters.h
Upload User: xgw_05
Upload Date: 2014-12-08
Package Size: 2726k
Code Size: 3k
Category:

.net

Development Platform:

Java

  1. #ifndef parameters_h
  2. #define parameters_h 1
  3. #include <stdlib.h>
  4. #include <iostream.h>
  5. #include <fstream.h>
  6. #include "globals.h"
  7. /**
  8.  * Class for all SVM-parameters
  9.  * @li read and write access to all parameters
  10.  * @li stream input and output
  11.  *
  12.  * @author Stefan Rueping <rueping@ls8.cs.uni-dortmund.de>
  13.  * @version 0.1
  14.  **/
  15. class parameters_c{
  16.   // neg means "f(x) < y-eps" (<=> "*")
  17.   // machine and kernel type
  18.     // capacity
  19.  public:
  20.   // input and output functions
  21.   friend istream& operator >> (istream& data_stream, parameters_c& the_parameters);
  22.   friend ostream& operator << (ostream& data_stream, parameters_c& the_parameters);
  23.   // default methods
  24.   parameters_c();
  25.   void clear();
  26.   // capacity constraint
  27.   SVMFLOAT realC; 
  28.   // loss function
  29.   SVMFLOAT Lpos, Lneg;
  30.   SVMFLOAT epsilon_pos, epsilon_neg;
  31.   int quadraticLossPos, quadraticLossNeg;
  32.   int balance_cost;
  33.   // default parameters for examples
  34.   int do_scale; // scale examples
  35.   int do_scale_y; // scale y-values
  36.   example_format default_example_format;
  37.   // type of SVM
  38.   int is_pattern; // set Lpos=0 for y>0 and Lneg=0 for y<0
  39.   int is_linear; // kernel=dot, use folding
  40.   int is_distribution;
  41.   int biased; // biased hyperplane (w*x+b) or unbiased (w*x)?
  42.   // do cross validation?
  43.   SVMINT cross_validation; // cross-validate on training set
  44.   int cv_window; // do cross-validation by means of a sliding window
  45.   int cv_inorder; // do cross-validation in given order of examples
  46.   // parameters for search of C
  47.   char search_c;
  48.   SVMINT search_stop;
  49.   SVMFLOAT c_min; // search for C to minimize loss
  50.   SVMFLOAT c_max;
  51.   SVMFLOAT c_delta;
  52.   // numerical optimization parameters
  53.   SVMFLOAT is_zero;  // when is a lagrangian multiplier considered 0
  54.   SVMFLOAT nu; // nu-SVM
  55.   int is_nu;
  56.   SVMINT max_iterations;
  57.   SVMINT working_set_size;
  58.   SVMINT shrink_const;
  59.   SVMFLOAT descend;  // make at least this much descend on WS
  60.   SVMFLOAT convergence_epsilon;
  61.   SVMINT kernel_cache;
  62.   int use_min_prediction;
  63.   SVMFLOAT min_prediction; // let pred =  max(min_prediction,f(x))
  64.   /**
  65.    * Verbosity (higher level includes smaller):
  66.    * 0 : only critical errors
  67.    * 1 : information about success of algorithm
  68.    * 2 : small summary about training and test
  69.    * 3 : larger summary about training
  70.    * 4 : information about each iteration
  71.    * 5 : flood
  72.    */
  73.   int verbosity;
  74.   int print_w; // print whole hyperplane?
  75.   int loo_estim; // print loo estim?
  76.   SVMFLOAT get_Cpos(){ return(Lpos*realC); };
  77.   SVMFLOAT get_Cneg(){ return(Lneg*realC); };
  78. };
  79. istream& operator >> (istream& data_stream, parameters_c& the_parameters);
  80. ostream& operator << (ostream& data_stream, parameters_c& the_parameters);
  81. #endif