Commits

YOUNG-SUK LEE committed ca05954

add nu-svm, one-class svm, positive gene feature selection

Comments (0)

Files changed (7)

 namespace LIBSVM {
 
 #include "libsvm.h"
+bool CLIBSVM::posFeatOnly = false;
 
 bool CLIBSVM::initialize() {
 
 
 bool CLIBSVM::parms_check() {
 	if (parm.C < 0) {
-		fprintf(
-				stderr,
-				"\nTrade-off between training error and margin is not set (C<0)!\nC value will be set to default value. Clight = Cpef * 100 / n \n");
-		fprintf(stderr, "be less than 1.0 !!!\n\n");
-		return false;
+	  fprintf(
+	    stderr,
+	    "\nTrade-off between training error and margin is not set (C<0)!\nC value will be set to default value. Clight = Cpef * 100 / n \n");
+	  fprintf(stderr, "be less than 1.0 !!!\n\n");
+	  return false;
 	}
 	if (parm.eps <= 0) {
-		fprintf(stderr,
-				"\nThe epsilon parameter must be greater than zero!\n\n");
-		return false;
+	  fprintf(stderr,
+		"\nThe epsilon parameter must be greater than zero!\n\n");
+	  return false;
 	}
 
+        if (parm.nu < 0 | parm.nu > 1) {
+            fprintf(stderr, "nu parameter must be between 0 and 1");
+            return false;
+        }
+
         //TODO: add more parameter checks 
 
 	return true;
 SAMPLE * CLIBSVM::CreateSample(Sleipnir::CPCL& PCL, vector<SVMLabel> SVMLabels) {
 	size_t i, j, k, iGene, iProblem, numFeatures, numLabels, max_index;
         float d;
+        bool posFeatOnly;
 
         struct svm_problem* prob;
         struct svm_node* x_space;
+        vector<size_t> iPosFeats;
 
         prob = Malloc(struct svm_problem,1);
 
-//        prob->l = 0;//number of labels in PCL
         numFeatures = PCL.GetExperiments();
         numLabels = 0;
+        
+        posFeatOnly = CLIBSVM::posFeatOnly; 
+ cerr << "in create sample: " << posFeatOnly << endl;       
 
-        cout << "number of features: " << numFeatures << endl;
 	
         iProblem = 0;
 
 		iGene = SVMLabels[i].index;
 		if (iGene != -1) {
                   numLabels++;
+                  if(posFeatOnly){
+                    if(SVMLabels[i].Target > 0){
+                      iPosFeats.push_back(iGene);
+                    }
+                  }
 		}
 	}
- 
+
+        if(posFeatOnly){
+          numFeatures = iPosFeats.size();
+        }
+
+cerr << "number of features: " << numFeatures << endl;
+
         prob->l = numLabels;
         prob->y = Malloc(double,numLabels);
         prob->x = Malloc(struct svm_node *, numLabels);
         x_space = Malloc(struct svm_node, (1+numFeatures) * numLabels);
 
-
         max_index = numFeatures;
 
         j = 0;//element index
               (prob->y)[i] = SVMLabels[i].Target;
 
               for(k = 0; k < numFeatures; k++){
+
+                if(posFeatOnly){
+                  if(find(iPosFeats.begin(),iPosFeats.end(),k) != iPosFeats.end()){
+                    continue; 
+                  }
+                }
+
                 x_space[j].index = k;
                 if (!Sleipnir::CMeta::IsNaN(d = PCL.Get(iGene, k))) {
                   x_space[j].value = d;
                 }else{
-                  x_space[j].value = 1; //TODO: make this a flag!!!
-                  //if missing value??? SVMPerf imputes 0 ... what about gene i to gene i ? should impute 1?
+                  x_space[j].value = 0;
                 }
                 j++;
               }         
         }
 
         SAMPLE* pSample = new SAMPLE;
-//        pSample = Malloc(SAMPLE,1);
 
         pSample->n = prob->l;//number of labels
         pSample->problems = prob;
         pSample->numFeatures = numFeatures;
         
-        cout << ((pSample->problems)->y)[0] << endl;
-        cout << ((pSample->problems)->y)[1] << endl;
-PrintSample(*pSample);
 	return pSample;
 }
 
-
-/*
-SAMPLE * CLIBSVM::CreateSample(Sleipnir::CDat& Dat, vector<SVMLabel> SVMLabels) {
-	size_t i, j, k, iGene, iProblem, numFeatures, max_index;
-        float d;
-
-        struct svm_problem* prob;
-        struct svm_node *x_space;
-
-        prob->l = 0;//number of labels in Dat
-        numFeatures = Dat.GetGenes();
-        iProblem = 0;
-
-	for (i = 0; i < SVMLabels.size(); i++) {
-          iGene = Dat.GetGene(SVMLabels[i].GeneName);
-          if (iGene != -1) {
-            (prob->l)++;
-          }
-	}
-
- 
-        prob->y = Malloc(double,prob->l);
-        prob->x = Malloc(struct svm_node *, prob->l);
-        x_space = Malloc(struct svm_node, numFeatures * (prob->l));
-
-        max_index = numFeatures;
-        j = 0;
-
-        for (i = 0; i < SVMLabels.size(); i++) {
-            iGene = Dat.GetGene(SVMLabels[i].GeneName);
-            if (iGene != -1){
-              (prob->x)[i] = &x_space[j];
-              (prob->y)[i] = SVMLabels[i].Target;
-              for(k = 0; k < numFeatures; k++){
-                x_space[j].index = k;
-                if (!Sleipnir::CMeta::IsNaN(d = Dat.Get(iGene, k))) {
-                  x_space[j].value = d;
-                }else{
-                  x_space[j].value = 1; //TODO: make this a flag!!!
-                  //if missing value??? SVMPerf imputes 0 ... what about gene i to gene i ? should impute 1?
-                }
-              }
-              j++;
-            }
-        }
-
-        SAMPLE* pSample;
-        pSample = Malloc(SAMPLE,1);
-        
-        pSample->n = prob->l;
-        pSample->problems = prob;
-
-	return pSample;
-}*/
-
+//TODO: create sample for dab/dat files
+//
 
 vector<Result> CLIBSVM::Classify(Sleipnir::CPCL &PCL,
         vector<SVMLabel> SVMLabels) {
     int svm_type = svm_get_svm_type(model);
     int nr_class = svm_get_nr_class(model);
 
-cerr << nr_class << endl;
-cerr << pSample->n << endl;;
-
     dec_values = Malloc(double, nr_class*(nr_class-1)/2);
     vecResult.resize(pSample->n);
 
-cerr << "number of samples: " << vecResult.size() << endl;
-cerr << "length of svm labels: " << SVMLabels.size() << endl;
-
     j= 0; //pSample index
     for(i = 0 ; i < SVMLabels.size() ; i++){
       if(!SVMLabels[i].hasIndex){//assume createSample sequentially added to pSample TODO: currently hacky
 
 namespace LIBSVM {
 
+
 extern "C" {
 #define class Class2
 #include <libsvm/svm.h>
 	double Target;
 	size_t index;
 	bool hasIndex;
+        
 	SVMLabel(std::string name, double target) {
 		GeneName = name;
 		Target = target;
 class CLIBSVM {
 public:
   //struct svm_parameter parm;
+  static bool posFeatOnly;
   struct svm_model* model;
   struct svm_parameter parm;
   
   CLIBSVM() {
     initialize();
   }
+//  static bool GetPosFeatOnly() {
+//    return posFeatOnly;
+//  }
+//  static void SetPosFeatOnly(bool only){
+//    posFeatOnly = only;
+//  }
 
   void SetSVMType(int type) {
     parm.svm_type = type;
   }
-  //void SetLossFunction(size_t loss_f) {
-    //libsvm has only one loss function
-  //}
 
   void SetTradeoff(double tradeoff) {
     parm.C = tradeoff; //TODO: only applicable for vanilla svm
     parm.degree = D;
   }
 
-  //void UseCPSP() { // unavailabe for libsvm
-  //}
-  //
-
   void SetRBFGamma(double g) {
     parm.gamma = g;
-    //UseCPSP not available for libsvm
   }
 
-  //void UseSlackRescaling(){  }
-  //void UseMarginRescaling() { }
-  //void SetPrecisionFraction(double frac) { }
+  void SetNu(double nu) {
+    parm.nu = nu;
+  }
 
   void ReadModel(char* model_file) {
     FreeModel();
 
   //Creates a sample of svm_problems using a single PCL and SVMlabels Looks up genes by name.
   static SAMPLE* CreateSample(Sleipnir::CPCL &PCL, vector<SVMLabel> SVMLabels);
+  //static SAMPLE* CreateSample(Sleipnir::CPCL &PCL, vector<SVMLabel> SVMLabels, bool posFeatOnly);
 
   //Same as above except creates bootstrap samples and does not duplicate data
   //static SAMPLE** CreateSampleBootStrap(Sleipnir::CPCL &PCL,
 
   //Classify single genes
   vector<Result> Classify(Sleipnir::CPCL& PCL, vector<SVMLabel> SVMLabels);
+  vector<Result> Classify(Sleipnir::CPCL& PCL, vector<SVMLabel> SVMLabels, bool posFeatOnly);
+  
   //vector<Result> Classify(Sleipnir::CPCLSet& PCLSet,
   //			vector<SVMLabel> SVMLabels);
-  vector<Result> Classify(Sleipnir::CDat& Dat, vector<SVMLabel> SVMLabels);
+  //vector<Result> Classify(Sleipnir::CDat& Dat, vector<SVMLabel> SVMLabels);
 
   //MEMBER functions wraps learning
   void Learn(SAMPLE &sample) {
     size_t i;
     size_t numn, nump;
 
-
     struct svm_problem* prob = sample.problems;
 
-    cout << "alsdjfaslkfjd" << endl;
-
     numn = nump = 0;
 
     for(i = 0; i < sample.n; i++){
       }
     }
 
-cout << "number of positives: " << nump << endl;
-cout << "number of negatives: " << numn << endl;
-cout << "cache size: " << parm.cache_size << endl;
-cout << "kernel_type: " << parm.kernel_type << endl;
-cout << "svm_type: " << parm.svm_type << endl;
-const char* output = svm_check_parameter( prob, &parm ) ;//returns null if no issues..
-printf("%s | ", output);
-cout << "an svm_node index: " << (((*prob).x)[0][0]).index << endl;
-cout << "an svm_node value: " << (((*prob).x)[0][0]).value << endl;
-cout.flush();
-//cout <<      svm_check_parameter(prob,&parm) << endl;
-    //no need for rescaling labels because only one loss function for libsvm\
-
     if(parms_check()){
-//cout <<      svm_check_parameter(prob,&parm) << endl;
-//      struct svm_problem* prob = sample.problems;        //sample.problem
-//      cout << "here: " << (*prob).l << endl;
       model = svm_train(prob,&parm);
-      cerr << "done learning model" << endl;
-cout << svm_get_svm_type(model) << endl;
     }else{
-      cerr << "invalid parms" << endl;
     }
   }
 
   static void FreeSample(SAMPLE s){
-cerr << "free sample: " << endl;
-PrintSample(s);
-
-    FreeProblem(s.problems, s.numFeatures);
-    //free(&s);    
+    FreeProblem(s.problems);
   }
 
-  static void FreeProblem(svm_problem *prob, size_t numFeatures){
-    //int i = prob->l; //number of examples
-    size_t i, j ;
-    i = j = 0;
-
-//PrintProblem(prob);
-
+  static void FreeProblem(svm_problem *prob){
     free(prob->y);
-
     free(prob->x);
-
-//    for(i = 0 ; i < prob->l ; i++){
-//      for(j = 0 ; j < numFeatures ; j ++){
-
-//PrintNode((prob->x)[i][j]);
-
-//        free((prob->x)[i]);
-//      }
-//    }
-
-//    free(prob); ??? why can't i free?
     return;
   }
 
   static void PrintSample(SAMPLE s){
     PrintProblem(s.problems);
-cerr << "number of labels: " << s.n << endl;
   }
 
   static void PrintProblem(svm_problem *prob){
     size_t i, j ;
     i = j = 0;
 
-//    free(prob->y);
-
     for(i = 0 ; i < 3 ; i++){
-cerr << "label: " << (prob->y)[i] << endl;
       for(j = 0 ; j < 2 ; j ++){
-
-PrintNode((prob->x)[i][j]);
-
-//        free(&((prob->x)[i][j]));
+        PrintNode((prob->x)[i][j]);
       }
     }
 
-//    free(prob);
     return;
   }
 

tools/LibSVMer/LibSVMer.cpp

 }
 
 int main(int iArgs, char** aszArgs) {
-//	cout << "blah" << endl;
 
 	gengetopt_args_info sArgs;
 
 
 	size_t i, j, iGene, jGene;
 	ifstream ifsm;
+        bool posFeatOnly;
+
+
 	if (cmdline_parser(iArgs, aszArgs, &sArgs)) {
 		cmdline_parser_print_help();
 		return 1;
 	else if(sArgs.cross_validation_arg < 2){
 	  cerr << "cross_valid is set to 1. No cross validation holdouts will be run." << endl;
 	}
-	
-	SVM.SetTradeoff(sArgs.tradeoff_arg);
-
+      
+        SVM.SetTradeoff(sArgs.tradeoff_arg);
+        SVM.SetNu(sArgs.nu_arg);
+        SVM.SetSVMType(sArgs.svm_type_arg);
+        CLIBSVM temp;
+        
+        SVM.posFeatOnly = sArgs.positive_features_only_flag;
+cerr << SVM.posFeatOnly << endl;
 
 	if (!SVM.parms_check()) {
 		cerr << "Sanity check failed, see above errors" << endl;
 		return 1;
 	}
 
-	//  cout << "there are " << vecLabels.size() << " labels processed" << endl;
 	size_t iFile;
 	vector<string> PCLs;
-	if (sArgs.input_given) {//TODO: allow PCL file inputs
-//          cerr << "PCL as input not yet available" << endl;
-
-//          return 1;
-          
+	if (sArgs.input_given) {
 		if (!PCL.Open(sArgs.input_arg, sArgs.skip_arg, sArgs.mmap_flag)) {
 			cerr << "Could not open input PCL" << endl;
 			return 1;
 		}
 	}
 
-//cout << "here1: " << svm_get_svm_type(SVM.model) << endl;
-//cout << SVM.parm.C << endl;
-
 	vector<LIBSVM::SVMLabel> vecLabels;
 	set<string> setLabeledGenes;
 	if (sArgs.labels_given) {
 			for (i = 0; i < sArgs.cross_validation_arg; i++) {
 				pTrainSample = LIBSVM::CLIBSVM::CreateSample(PCL, //TODO: make more efficient
 						pTrainVector[i]);
-//                                LIBSVM::CLIBSVM::PrintSample(*pTrainSample);
-//				LIBSVM::CLIBSVM::FreeSample(*pTrainSample);
-//                                continue;
-
-//cout << "here2: " << svm_get_svm_type(SVM.model) << endl;
-//cout << "here3: " << SVM.parm.C << endl;
-
-//                                cerr << "number of training labels: " << pTrainVector[i].size() << endl;
-//                                cerr << "number of training samples: " << pTrainSample->n << endl;
-//                                cerr << "number of testing labels: " << pTestVector[i].size() << endl;
-				
-//continue;
-//for( std::vector<LIBSVM::SVMLabel>::const_iterator q = pTestVector[i].begin(); q != pTestVector[i].end(); ++q)
-//      std::cout << (*q).GeneName << ' ';
-
-//                                cout << pTrainSample->problems
-//sleep(15);
-//cout << PCL.GetFeatures() << endl;
-//cout << PCL.GetGenes() << endl;
-
 
 				cerr << "Cross Validation Trial " << i << endl;
 

tools/LibSVMer/LibSVMer.ggo

 option  "all"       			a   "Always classify all genes in PCLs"  
 										flag off
 
-option  "slack"       			S   "Use slack rescaling (not implemented for ROC loss)"
-										flag off
-
 section "Options"
-option "verbosity"  			v   "Sets the svm_struct verbosity"
-										int default="0" no
 option "skip"      				s   "Number of columns to skip in input pcls"
 										int default="2" no
 option	"normalize"				n	"Normalize PCLS to 0 mean 1 variance"
 										flag	off
 option	"cross_validation"		c	"Number of cross-validation sets ( arg of 1 will turn off cross-validation )"
 										int default="5" no
-option "error_function" 		e   "Sets the loss function for SVM learning: Choice of:
-0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
-1\tF1: 100 minus the F1-score in percent.
-2\tErrorrate: Percentage of errors in prediction vector.
-3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
-4\tPrec@k: 100 minus precision at k in percent.
-5\tRec@k: 100 minus recall at k in percent.
-10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n" 
-										int default="10" no
-
-option "k_value"    			k   "Value of k parameter used for Prec@k and Rec@k in (0,1)"
-										float default="0.5" no
-option "tradeoff"    			t   "SVM tradeoff constant C"
+option "svm_type"                       v       "Sets type of SVM (default 0)
+0\tC-SVC
+1\tnu-SVC
+2\tone-class SVM\n"
+                                                                                int default="0" no
+option "positive_features_only"         f   "select positive features (i.e. genes) note that input must be complete matrix"
+                                                                                flag off
+option "tradeoff"    			t   "SVM tradeoff constant C of C-SVC"
 										float default="1" no
+option "nu"                             u   "nu parameter of nu-SVC, one-class SVM"
+                                                                                float default="0.5" no
 option "params"   				p   "Parameter file"
 										string  typestr="filename"   no
+
 option	"mmap"					M	"Memory map binary input"
 										flag	off

tools/LibSVMer/cmdline.c

 const char *gengetopt_args_info_description = "";
 
 const char *gengetopt_args_info_help[] = {
-  "  -h, --help                  Print help and exit",
-  "  -V, --version               Print version and exit",
+  "  -h, --help                    Print help and exit",
+  "  -V, --version                 Print version and exit",
   "\nMain:",
-  "  -l, --labels=filename       Labels file",
-  "  -o, --output=filename       Output file ",
-  "  -i, --input=filename        Input PCL file ",
-  "  -m, --model=filename        Model file",
-  "  -a, --all                   Always classify all genes in PCLs  (default=off)",
-  "  -S, --slack                 Use slack rescaling (not implemented for ROC \n                                loss)  (default=off)",
+  "  -l, --labels=filename         Labels file",
+  "  -o, --output=filename         Output file ",
+  "  -i, --input=filename          Input PCL file ",
+  "  -m, --model=filename          Model file",
+  "  -a, --all                     Always classify all genes in PCLs  \n                                  (default=off)",
   "\nOptions:",
-  "  -v, --verbosity=INT         Sets the svm_struct verbosity  (default=`0')",
-  "  -s, --skip=INT              Number of columns to skip in input pcls  \n                                (default=`2')",
-  "  -n, --normalize             Normalize PCLS to 0 mean 1 variance  \n                                (default=off)",
-  "  -c, --cross_validation=INT  Number of cross-validation sets ( arg of 1 will \n                                turn off cross-validation )  (default=`5')",
-  "  -e, --error_function=INT    Sets the loss function for SVM learning: Choice \n                                of:\n\n                                0\tZero/one loss: 1 if vector of predictions \n                                contains error, 0 otherwise.\n\n                                1\tF1: 100 minus the F1-score in percent.\n\n                                2\tErrorrate: Percentage of errors in \n                                prediction vector.\n\n                                3\tPrec/Rec Breakeven: 100 minus PRBEP in \n                                percent.\n\n                                4\tPrec@k: 100 minus precision at k in percent.\n\n                                5\tRec@k: 100 minus recall at k in percent.\n\n                                10\tROCArea: Percentage of swapped pos/neg \n                                pairs (i.e. 100 - ROCArea).\n                                  (default=`10')",
-  "  -k, --k_value=FLOAT         Value of k parameter used for Prec@k and Rec@k in \n                                (0,1)  (default=`0.5')",
-  "  -t, --tradeoff=FLOAT        SVM tradeoff constant C  (default=`1')",
-  "  -p, --params=filename       Parameter file",
-  "  -M, --mmap                  Memory map binary input  (default=off)",
+  "  -s, --skip=INT                Number of columns to skip in input pcls  \n                                  (default=`2')",
+  "  -n, --normalize               Normalize PCLS to 0 mean 1 variance  \n                                  (default=off)",
+  "  -c, --cross_validation=INT    Number of cross-validation sets ( arg of 1 will \n                                  turn off cross-validation )  (default=`5')",
+  "  -v, --svm_type=INT            Sets type of SVM (default 0)\n\n                                  0\tC-SVC\n\n                                  1\tnu-SVC\n\n                                  2\tone-class SVM\n                                    (default=`0')",
+  "  -f, --positive_features_only  select positive features (i.e. genes) note that \n                                  input must be complete matrix  (default=off)",
+  "  -t, --tradeoff=FLOAT          SVM tradeoff constant C of C-SVC  (default=`1')",
+  "  -u, --nu=FLOAT                nu parameter of nu-SVC, one-class SVM  \n                                  (default=`0.5')",
+  "  -p, --params=filename         Parameter file",
+  "  -M, --mmap                    Memory map binary input  (default=off)",
     0
 };
 
   args_info->input_given = 0 ;
   args_info->model_given = 0 ;
   args_info->all_given = 0 ;
-  args_info->slack_given = 0 ;
-  args_info->verbosity_given = 0 ;
   args_info->skip_given = 0 ;
   args_info->normalize_given = 0 ;
   args_info->cross_validation_given = 0 ;
-  args_info->error_function_given = 0 ;
-  args_info->k_value_given = 0 ;
+  args_info->svm_type_given = 0 ;
+  args_info->positive_features_only_given = 0 ;
   args_info->tradeoff_given = 0 ;
+  args_info->nu_given = 0 ;
   args_info->params_given = 0 ;
   args_info->mmap_given = 0 ;
 }
   args_info->model_arg = NULL;
   args_info->model_orig = NULL;
   args_info->all_flag = 0;
-  args_info->slack_flag = 0;
-  args_info->verbosity_arg = 0;
-  args_info->verbosity_orig = NULL;
   args_info->skip_arg = 2;
   args_info->skip_orig = NULL;
   args_info->normalize_flag = 0;
   args_info->cross_validation_arg = 5;
   args_info->cross_validation_orig = NULL;
-  args_info->error_function_arg = 10;
-  args_info->error_function_orig = NULL;
-  args_info->k_value_arg = 0.5;
-  args_info->k_value_orig = NULL;
+  args_info->svm_type_arg = 0;
+  args_info->svm_type_orig = NULL;
+  args_info->positive_features_only_flag = 0;
   args_info->tradeoff_arg = 1;
   args_info->tradeoff_orig = NULL;
+  args_info->nu_arg = 0.5;
+  args_info->nu_orig = NULL;
   args_info->params_arg = NULL;
   args_info->params_orig = NULL;
   args_info->mmap_flag = 0;
   args_info->input_help = gengetopt_args_info_help[5] ;
   args_info->model_help = gengetopt_args_info_help[6] ;
   args_info->all_help = gengetopt_args_info_help[7] ;
-  args_info->slack_help = gengetopt_args_info_help[8] ;
-  args_info->verbosity_help = gengetopt_args_info_help[10] ;
-  args_info->skip_help = gengetopt_args_info_help[11] ;
-  args_info->normalize_help = gengetopt_args_info_help[12] ;
-  args_info->cross_validation_help = gengetopt_args_info_help[13] ;
-  args_info->error_function_help = gengetopt_args_info_help[14] ;
-  args_info->k_value_help = gengetopt_args_info_help[15] ;
-  args_info->tradeoff_help = gengetopt_args_info_help[16] ;
-  args_info->params_help = gengetopt_args_info_help[17] ;
-  args_info->mmap_help = gengetopt_args_info_help[18] ;
+  args_info->skip_help = gengetopt_args_info_help[9] ;
+  args_info->normalize_help = gengetopt_args_info_help[10] ;
+  args_info->cross_validation_help = gengetopt_args_info_help[11] ;
+  args_info->svm_type_help = gengetopt_args_info_help[12] ;
+  args_info->positive_features_only_help = gengetopt_args_info_help[13] ;
+  args_info->tradeoff_help = gengetopt_args_info_help[14] ;
+  args_info->nu_help = gengetopt_args_info_help[15] ;
+  args_info->params_help = gengetopt_args_info_help[16] ;
+  args_info->mmap_help = gengetopt_args_info_help[17] ;
   
 }
 
   free_string_field (&(args_info->input_orig));
   free_string_field (&(args_info->model_arg));
   free_string_field (&(args_info->model_orig));
-  free_string_field (&(args_info->verbosity_orig));
   free_string_field (&(args_info->skip_orig));
   free_string_field (&(args_info->cross_validation_orig));
-  free_string_field (&(args_info->error_function_orig));
-  free_string_field (&(args_info->k_value_orig));
+  free_string_field (&(args_info->svm_type_orig));
   free_string_field (&(args_info->tradeoff_orig));
+  free_string_field (&(args_info->nu_orig));
   free_string_field (&(args_info->params_arg));
   free_string_field (&(args_info->params_orig));
   
     write_into_file(outfile, "model", args_info->model_orig, 0);
   if (args_info->all_given)
     write_into_file(outfile, "all", 0, 0 );
-  if (args_info->slack_given)
-    write_into_file(outfile, "slack", 0, 0 );
-  if (args_info->verbosity_given)
-    write_into_file(outfile, "verbosity", args_info->verbosity_orig, 0);
   if (args_info->skip_given)
     write_into_file(outfile, "skip", args_info->skip_orig, 0);
   if (args_info->normalize_given)
     write_into_file(outfile, "normalize", 0, 0 );
   if (args_info->cross_validation_given)
     write_into_file(outfile, "cross_validation", args_info->cross_validation_orig, 0);
-  if (args_info->error_function_given)
-    write_into_file(outfile, "error_function", args_info->error_function_orig, 0);
-  if (args_info->k_value_given)
-    write_into_file(outfile, "k_value", args_info->k_value_orig, 0);
+  if (args_info->svm_type_given)
+    write_into_file(outfile, "svm_type", args_info->svm_type_orig, 0);
+  if (args_info->positive_features_only_given)
+    write_into_file(outfile, "positive_features_only", 0, 0 );
   if (args_info->tradeoff_given)
     write_into_file(outfile, "tradeoff", args_info->tradeoff_orig, 0);
+  if (args_info->nu_given)
+    write_into_file(outfile, "nu", args_info->nu_orig, 0);
   if (args_info->params_given)
     write_into_file(outfile, "params", args_info->params_orig, 0);
   if (args_info->mmap_given)
         { "input",	1, NULL, 'i' },
         { "model",	1, NULL, 'm' },
         { "all",	0, NULL, 'a' },
-        { "slack",	0, NULL, 'S' },
-        { "verbosity",	1, NULL, 'v' },
         { "skip",	1, NULL, 's' },
         { "normalize",	0, NULL, 'n' },
         { "cross_validation",	1, NULL, 'c' },
-        { "error_function",	1, NULL, 'e' },
-        { "k_value",	1, NULL, 'k' },
+        { "svm_type",	1, NULL, 'v' },
+        { "positive_features_only",	0, NULL, 'f' },
         { "tradeoff",	1, NULL, 't' },
+        { "nu",	1, NULL, 'u' },
         { "params",	1, NULL, 'p' },
         { "mmap",	0, NULL, 'M' },
         { NULL,	0, NULL, 0 }
       };
 
-      c = getopt_long (argc, argv, "hVl:o:i:m:aSv:s:nc:e:k:t:p:M", long_options, &option_index);
+      c = getopt_long (argc, argv, "hVl:o:i:m:as:nc:v:ft:u:p:M", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
             goto failure;
         
           break;
-        case 'S':	/* Use slack rescaling (not implemented for ROC loss).  */
-        
-        
-          if (update_arg((void *)&(args_info->slack_flag), 0, &(args_info->slack_given),
-              &(local_args_info.slack_given), optarg, 0, 0, ARG_FLAG,
-              check_ambiguity, override, 1, 0, "slack", 'S',
-              additional_error))
-            goto failure;
-        
-          break;
-        case 'v':	/* Sets the svm_struct verbosity.  */
-        
-        
-          if (update_arg( (void *)&(args_info->verbosity_arg), 
-               &(args_info->verbosity_orig), &(args_info->verbosity_given),
-              &(local_args_info.verbosity_given), optarg, 0, "0", ARG_INT,
-              check_ambiguity, override, 0, 0,
-              "verbosity", 'v',
-              additional_error))
-            goto failure;
-        
-          break;
         case 's':	/* Number of columns to skip in input pcls.  */
         
         
             goto failure;
         
           break;
-        case 'e':	/* Sets the loss function for SVM learning: Choice of:
-        0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
-        1\tF1: 100 minus the F1-score in percent.
-        2\tErrorrate: Percentage of errors in prediction vector.
-        3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
-        4\tPrec@k: 100 minus precision at k in percent.
-        5\tRec@k: 100 minus recall at k in percent.
-        10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n.  */
+        case 'v':	/* Sets type of SVM (default 0)
+        0\tC-SVC
+        1\tnu-SVC
+        2\tone-class SVM\n.  */
         
         
-          if (update_arg( (void *)&(args_info->error_function_arg), 
-               &(args_info->error_function_orig), &(args_info->error_function_given),
-              &(local_args_info.error_function_given), optarg, 0, "10", ARG_INT,
+          if (update_arg( (void *)&(args_info->svm_type_arg), 
+               &(args_info->svm_type_orig), &(args_info->svm_type_given),
+              &(local_args_info.svm_type_given), optarg, 0, "0", ARG_INT,
               check_ambiguity, override, 0, 0,
-              "error_function", 'e',
+              "svm_type", 'v',
               additional_error))
             goto failure;
         
           break;
-        case 'k':	/* Value of k parameter used for Prec@k and Rec@k in (0,1).  */
+        case 'f':	/* select positive features (i.e. genes) note that input must be complete matrix.  */
         
         
-          if (update_arg( (void *)&(args_info->k_value_arg), 
-               &(args_info->k_value_orig), &(args_info->k_value_given),
-              &(local_args_info.k_value_given), optarg, 0, "0.5", ARG_FLOAT,
-              check_ambiguity, override, 0, 0,
-              "k_value", 'k',
+          if (update_arg((void *)&(args_info->positive_features_only_flag), 0, &(args_info->positive_features_only_given),
+              &(local_args_info.positive_features_only_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "positive_features_only", 'f',
               additional_error))
             goto failure;
         
           break;
-        case 't':	/* SVM tradeoff constant C.  */
+        case 't':	/* SVM tradeoff constant C of C-SVC.  */
         
         
           if (update_arg( (void *)&(args_info->tradeoff_arg), 
             goto failure;
         
           break;
+        case 'u':	/* nu parameter of nu-SVC, one-class SVM.  */
+        
+        
+          if (update_arg( (void *)&(args_info->nu_arg), 
+               &(args_info->nu_orig), &(args_info->nu_given),
+              &(local_args_info.nu_given), optarg, 0, "0.5", ARG_FLOAT,
+              check_ambiguity, override, 0, 0,
+              "nu", 'u',
+              additional_error))
+            goto failure;
+        
+          break;
         case 'p':	/* Parameter file.  */
         
         

tools/LibSVMer/cmdline.h

   const char *model_help; /**< @brief Model file help description.  */
   int all_flag;	/**< @brief Always classify all genes in PCLs (default=off).  */
   const char *all_help; /**< @brief Always classify all genes in PCLs help description.  */
-  int slack_flag;	/**< @brief Use slack rescaling (not implemented for ROC loss) (default=off).  */
-  const char *slack_help; /**< @brief Use slack rescaling (not implemented for ROC loss) help description.  */
-  int verbosity_arg;	/**< @brief Sets the svm_struct verbosity (default='0').  */
-  char * verbosity_orig;	/**< @brief Sets the svm_struct verbosity original value given at command line.  */
-  const char *verbosity_help; /**< @brief Sets the svm_struct verbosity help description.  */
   int skip_arg;	/**< @brief Number of columns to skip in input pcls (default='2').  */
   char * skip_orig;	/**< @brief Number of columns to skip in input pcls original value given at command line.  */
   const char *skip_help; /**< @brief Number of columns to skip in input pcls help description.  */
   int cross_validation_arg;	/**< @brief Number of cross-validation sets ( arg of 1 will turn off cross-validation ) (default='5').  */
   char * cross_validation_orig;	/**< @brief Number of cross-validation sets ( arg of 1 will turn off cross-validation ) original value given at command line.  */
   const char *cross_validation_help; /**< @brief Number of cross-validation sets ( arg of 1 will turn off cross-validation ) help description.  */
-  int error_function_arg;	/**< @brief Sets the loss function for SVM learning: Choice of:
-  0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
-  1\tF1: 100 minus the F1-score in percent.
-  2\tErrorrate: Percentage of errors in prediction vector.
-  3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
-  4\tPrec@k: 100 minus precision at k in percent.
-  5\tRec@k: 100 minus recall at k in percent.
-  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n (default='10').  */
-  char * error_function_orig;	/**< @brief Sets the loss function for SVM learning: Choice of:
-  0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
-  1\tF1: 100 minus the F1-score in percent.
-  2\tErrorrate: Percentage of errors in prediction vector.
-  3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
-  4\tPrec@k: 100 minus precision at k in percent.
-  5\tRec@k: 100 minus recall at k in percent.
-  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n original value given at command line.  */
-  const char *error_function_help; /**< @brief Sets the loss function for SVM learning: Choice of:
-  0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
-  1\tF1: 100 minus the F1-score in percent.
-  2\tErrorrate: Percentage of errors in prediction vector.
-  3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
-  4\tPrec@k: 100 minus precision at k in percent.
-  5\tRec@k: 100 minus recall at k in percent.
-  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n help description.  */
-  float k_value_arg;	/**< @brief Value of k parameter used for Prec@k and Rec@k in (0,1) (default='0.5').  */
-  char * k_value_orig;	/**< @brief Value of k parameter used for Prec@k and Rec@k in (0,1) original value given at command line.  */
-  const char *k_value_help; /**< @brief Value of k parameter used for Prec@k and Rec@k in (0,1) help description.  */
-  float tradeoff_arg;	/**< @brief SVM tradeoff constant C (default='1').  */
-  char * tradeoff_orig;	/**< @brief SVM tradeoff constant C original value given at command line.  */
-  const char *tradeoff_help; /**< @brief SVM tradeoff constant C help description.  */
+  int svm_type_arg;	/**< @brief Sets type of SVM (default 0)
+  0\tC-SVC
+  1\tnu-SVC
+  2\tone-class SVM\n (default='0').  */
+  char * svm_type_orig;	/**< @brief Sets type of SVM (default 0)
+  0\tC-SVC
+  1\tnu-SVC
+  2\tone-class SVM\n original value given at command line.  */
+  const char *svm_type_help; /**< @brief Sets type of SVM (default 0)
+  0\tC-SVC
+  1\tnu-SVC
+  2\tone-class SVM\n help description.  */
+  int positive_features_only_flag;	/**< @brief select positive features (i.e. genes) note that input must be complete matrix (default=off).  */
+  const char *positive_features_only_help; /**< @brief select positive features (i.e. genes) note that input must be complete matrix help description.  */
+  float tradeoff_arg;	/**< @brief SVM tradeoff constant C of C-SVC (default='1').  */
+  char * tradeoff_orig;	/**< @brief SVM tradeoff constant C of C-SVC original value given at command line.  */
+  const char *tradeoff_help; /**< @brief SVM tradeoff constant C of C-SVC help description.  */
+  float nu_arg;	/**< @brief nu parameter of nu-SVC, one-class SVM (default='0.5').  */
+  char * nu_orig;	/**< @brief nu parameter of nu-SVC, one-class SVM original value given at command line.  */
+  const char *nu_help; /**< @brief nu parameter of nu-SVC, one-class SVM help description.  */
   char * params_arg;	/**< @brief Parameter file.  */
   char * params_orig;	/**< @brief Parameter file original value given at command line.  */
   const char *params_help; /**< @brief Parameter file help description.  */
   unsigned int input_given ;	/**< @brief Whether input was given.  */
   unsigned int model_given ;	/**< @brief Whether model was given.  */
   unsigned int all_given ;	/**< @brief Whether all was given.  */
-  unsigned int slack_given ;	/**< @brief Whether slack was given.  */
-  unsigned int verbosity_given ;	/**< @brief Whether verbosity was given.  */
   unsigned int skip_given ;	/**< @brief Whether skip was given.  */
   unsigned int normalize_given ;	/**< @brief Whether normalize was given.  */
   unsigned int cross_validation_given ;	/**< @brief Whether cross_validation was given.  */
-  unsigned int error_function_given ;	/**< @brief Whether error_function was given.  */
-  unsigned int k_value_given ;	/**< @brief Whether k_value was given.  */
+  unsigned int svm_type_given ;	/**< @brief Whether svm_type was given.  */
+  unsigned int positive_features_only_given ;	/**< @brief Whether positive_features_only was given.  */
   unsigned int tradeoff_given ;	/**< @brief Whether tradeoff was given.  */
+  unsigned int nu_given ;	/**< @brief Whether nu was given.  */
   unsigned int params_given ;	/**< @brief Whether params was given.  */
   unsigned int mmap_given ;	/**< @brief Whether mmap was given.  */
 

tools/SVMperfer/SVMperfer.ggo

 option "params"   				p   "Parameter file"
 										string  typestr="filename"   no
 option	"mmap"					M	"Memory map binary input"
-										flag	off
+										flag	off