1. libsleipnir
  2. sleipnir

Commits

YOUNG-SUK LEE  committed 0b0b0bb

balance svm and multiple run cv

  • Participants
  • Parent commits 63a6fc9
  • Branches sleipnir

Comments (0)

Files changed (6)

File src/libsvm.cpp

View file
  • Ignore whitespace
 namespace LIBSVM {
 
 #include "libsvm.h"
-bool CLIBSVM::posFeatOnly = false;
+struct svm_node* CLIBSVM::x_space = NULL;
 
 bool CLIBSVM::initialize() {
 
         parm.gamma = 0;
         parm.degree = 3;
         parm.kernel_type = LINEAR;
+        
+        model = NULL;
+
+        balance = 0;//Off
 
 	return true;
 }
 
 	return true;
 }
-/*
-SAMPLE * CLIBSVM::CreateXSpace(Sleipnir::CPCL& PCL, vector<SVMLabel> SVMLabels) {
+
+void CLIBSVM::SetXSpace(Sleipnir::CPCL& PCL) {
+	size_t j, k, iGene, numFeatures, numLabels;
+        std::vector<std::string> vecGeneNames;
+        string GeneName;
+        float d;
+
+        numFeatures = PCL.GetExperiments();
+        numLabels = PCL.GetGenes();
+        vecGeneNames = PCL.GetGeneNames();
+        
+cerr << "number of features used: " << numFeatures << endl;
+cerr << "number of labels in data: " << numLabels << endl;
+cerr << "number of gene names: " << vecGeneNames.size() << endl;
+
+        x_space = Malloc(struct svm_node, (1+numFeatures) * numLabels);
+
+        j = 0;//element index
+        
+        for ( std::vector<std::string>::iterator it = vecGeneNames.begin(); it != vecGeneNames.end(); ++it) {
+          GeneName = *it;
+          iGene = PCL.GetGene(GeneName); 
+
+          for ( k = 0; k < numFeatures; k++){
+            x_space[j].index = k;
+            if (!Sleipnir::CMeta::IsNaN(d = PCL.Get(iGene, k))) {
+              x_space[j].value = d;
+            }else{
+              // impute 0 for missing values
+              x_space[j].value = 0;
+            }
+            j++;
+          }
+
+          x_space[j].index = -1;
+          j++;
+        }
+
+
+}
+
+SAMPLE * CLIBSVM::CreateSample(Sleipnir::CPCL& PCL, vector<SVMLabel> SVMLabels) {
 	size_t i, j, k, s, 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);
 
         numFeatures = PCL.GetExperiments();
         numLabels = 0;
         
-        posFeatOnly = CLIBSVM::posFeatOnly; 
-// cerr << "in create sample: " << posFeatOnly << endl;       
-
-	
         iProblem = 0;
 
 	for (i = 0; i < SVMLabels.size(); i++) {
 		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 used: " << numFeatures << endl;
 cerr << "number of labels given: " << SVMLabels.size() << endl;
 cerr << "number of labels in data: " << numLabels << 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);
+
+        if(x_space == NULL) {
+          SetXSpace(PCL);
+        }
 
         max_index = numFeatures;
 
-        j = 0;//element index
         s = 0;//sample index
         for (i = 0; i < SVMLabels.size(); i++) {
             iGene = SVMLabels[i].index;
 
             if (iGene != -1){
-              (prob->x)[s] = &x_space[j];
+              (prob->x)[s] = &x_space[iGene*(1+numFeatures)];
               (prob->y)[s] = SVMLabels[i].Target;
-
-              for(k = 0; k < numFeatures; k++){
-
-                if(posFeatOnly){
-                  // ignore non-positive features
-                  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{
-                  // impute 0 for missing values
-                  x_space[j].value = 0;
-                }
-                j++;
-              }         
-              x_space[j].index = -1;
-              j++;
               s++;
             }
         }
         pSample->n = prob->l;//number of labels
         pSample->problems = prob;
         pSample->numFeatures = numFeatures;
-        pSample->x_space = x_space; 
-	return pSample;
-
-}*/
-
-SAMPLE * CLIBSVM::CreateSample(Sleipnir::CPCL& PCL, vector<SVMLabel> SVMLabels) {
-	size_t i, j, k, s, 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);
-
-        numFeatures = PCL.GetExperiments();
-        numLabels = 0;
-        
-        posFeatOnly = CLIBSVM::posFeatOnly; 
-// cerr << "in create sample: " << posFeatOnly << endl;       
-
-	
-        iProblem = 0;
-
-	for (i = 0; i < SVMLabels.size(); i++) {
-                if (!SVMLabels[i].hasIndex){
-                  SVMLabels[i].SetIndex(PCL.GetGene(SVMLabels[i].GeneName));
-                }
-		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 used: " << numFeatures << endl;
-cerr << "number of labels given: " << SVMLabels.size() << endl;
-cerr << "number of labels in data: " << numLabels << 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
-        s = 0;//sample index
-        for (i = 0; i < SVMLabels.size(); i++) {
-            iGene = SVMLabels[i].index;
-
-            if (iGene != -1){
-              (prob->x)[s] = &x_space[j];
-              (prob->y)[s] = SVMLabels[i].Target;
-
-              for(k = 0; k < numFeatures; k++){
-
-                if(posFeatOnly){
-                  // ignore non-positive features
-                  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{
-                  // impute 0 for missing values
-                  x_space[j].value = 0;
-                }
-                j++;
-              }         
-              x_space[j].index = -1;
-              j++;
-              s++;
-            }
-        }
-
-        SAMPLE* pSample = new SAMPLE;
-
-        pSample->n = prob->l;//number of labels
-        pSample->problems = prob;
-        pSample->numFeatures = numFeatures;
-        pSample->x_space = x_space; 
 	return pSample;
 }
 
       if (iGene != -1 ) {    
         x = pSample->problems->x[j];
         predict_label = svm_predict_values(model,x, dec_values);
-        dec_value = dec_values[0]; //assume that positive class is the first class TODO: currently hackly
+        dec_value = dec_values[0]; //assume that positive class is the first class TODO: currently hacklyi
+
+//cerr << dec_value << endl;
 
         vecResult[j].GeneName = SVMLabels[i].GeneName;
         vecResult[j].Target = SVMLabels[i].Target;
 
       }
     }
+
     free(pSample);
     //delete pSample ;
     free(dec_values);

File src/libsvm.h

View file
  • Ignore whitespace
    size_t     n;            /* n is the total number of examples */
    size_t  numFeatures; 
    struct svm_problem *problems;
-   struct svm_node *x_space;
+//   struct svm_node *x_space;
    sample() {
      n = 0;
      numFeatures = 0;
      problems = NULL;
-     x_space = NULL;
+//     x_space = NULL;
    }
    
    ~sample(){
      //no destructor for problem struct
      free(problems->y);
      free(problems->x);
-     free(x_space);
+//     free(x_space);
      problems = NULL;
    }
 } SAMPLE;
 class CLIBSVM {
 public:
   //struct svm_parameter parm;
-  static bool posFeatOnly;
   struct svm_model* model;
   struct svm_parameter parm;
+  int balance;
 
-  struct svm_node *x_space;
+  static struct svm_node *x_space;
 
   CLIBSVM() {
     initialize();
     svm_free_and_destroy_model( &model );
     model = NULL;
   }
-//  static bool GetPosFeatOnly() {
-//    return posFeatOnly;
-//  }
-//  static void SetPosFeatOnly(bool only){
-//    posFeatOnly = only;
-//  }
+
+  void SetBalance(int bal){
+    balance = bal;
+  }
 
   void SetSVMType(int type) {
     parm.svm_type = type;
   
 
   //static members process data
+  //
+  
+  static void SetXSpace(Sleipnir::CPCL& PCL);
+
+  //
   //single gene predictions
 
   //TODO: add functions to handle PCL files
   //Creates a sample using a PCLset and SVMlabels Looks up genes by name.
   //static SAMPLE* CreateSample(Sleipnir::CPCLSet &PCLSet,
   //			vector<SVMLabel> SVMLabels);
-
+  
   //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);
       }
     }
 
+    if (balance) {
+cerr << "balancing the weights between postivies and negatives. " << endl;
+      parm.nr_weight = 2;
+      parm.weight_label = (int *) realloc(parm.weight_label, sizeof(int)*parm.nr_weight);
+      parm.weight = (double *) realloc(parm.weight, sizeof(double)*parm.nr_weight);
+      parm.weight_label[0] = 1;
+      parm.weight[0] = numn;
+      parm.weight_label[1] = -1;
+      parm.weight[1] = nump;
+    }
+
     if(parms_check()){
       model = svm_train(prob,&parm);
     }else{

File tools/LibSVMer/LibSVMer.cpp

View file
  • Ignore whitespace
 
 	size_t i, j, iGene, jGene;
 	ifstream ifsm;
-        bool posFeatOnly;
 
 
 	if (cmdline_parser(iArgs, aszArgs, &sArgs)) {
 	else if(sArgs.cross_validation_arg < 2){
 	  cerr << "cross_valid is set to 1. No cross validation holdouts will be run." << endl;
 	}
+
+        if (sArgs.num_cv_runs_arg < 1){
+          cerr << "number of cv runs is < 1. Must be set at least 1" << endl;
+          return 1;
+        }
       
         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;
+        SVM.SetBalance(sArgs.balance_flag);
+//cerr << SVM.posFeatOnly << endl;
 
 	if (!SVM.parms_check()) {
 		cerr << "Sanity check failed, see above errors" << endl;
 	}
 
 	LIBSVM::SAMPLE* pTrainSample;
-	vector<LIBSVM::SVMLabel> pTrainVector[sArgs.cross_validation_arg];
-	vector<LIBSVM::SVMLabel> pTestVector[sArgs.cross_validation_arg];
+	vector<LIBSVM::SVMLabel> pTrainVector[sArgs.cross_validation_arg * sArgs.num_cv_runs_arg];
+	vector<LIBSVM::SVMLabel> pTestVector[sArgs.cross_validation_arg * sArgs.num_cv_runs_arg];
 	vector<LIBSVM::Result> AllResults;
 	vector<LIBSVM::Result> tmpAllResults;
 
 		}
 	} else if (sArgs.output_given && sArgs.labels_given) {
 		//do learning and classifying with cross validation
-	        if( sArgs.cross_validation_arg > 1){	    
+/*	        if( sArgs.cross_validation_arg > 1){	    
 		  for (i = 0; i < sArgs.cross_validation_arg; i++) {
 		    pTestVector[i].reserve((size_t) vecLabels.size()
 					   / sArgs.cross_validation_arg + sArgs.cross_validation_arg);
 		      }
 		    }
 		  }
-		}
+		}*/
+                if( sArgs.cross_validation_arg > 1 && sArgs.num_cv_runs_arg >= 1 ){
+                  size_t ii, index;
+                  for (ii = 0; ii < sArgs.num_cv_runs_arg; ii++) {
+                    std::random_shuffle(vecLabels.begin(), vecLabels.end());
+
+                  for (i = 0; i < sArgs.cross_validation_arg; i++) {                  
+                    index = sArgs.cross_validation_arg * ii + i;
+//cerr << index << endl;                    
+  		    pTestVector[index].reserve((size_t) vecLabels.size()
+  					   / sArgs.cross_validation_arg + sArgs.cross_validation_arg);
+		    pTrainVector[index].reserve((size_t) vecLabels.size()
+					    / (sArgs.cross_validation_arg)
+					    * (sArgs.cross_validation_arg - 1)
+					    + sArgs.cross_validation_arg);
+		    for (j = 0; j < vecLabels.size(); j++) {
+//cerr << vecLabels[j].GeneName << endl;
+		      if (j % sArgs.cross_validation_arg == i) {
+			pTestVector[index].push_back(vecLabels[j]);
+		      } else {
+			pTrainVector[index].push_back(vecLabels[j]);
+		      }
+		    }
+		  }
+
+                  }
+                }  
 		else{ // if you have less than 2 fold cross, no cross validation is done, all train genes are used and predicted
 		  
 		  // no holdout so train is the same as test gene set
 				}
 			}
 		}
-		if (sArgs.params_given) { //reading paramters from file
+
+		if (sArgs.params_given) { //reading paramters from file //TODO??? figure out how this code works
 			ifsm.close();
 			ifsm.clear();
 			ifsm.open(sArgs.params_arg);
 				AllResults.resize(0);
 			}
 		} else { //run once
-			for (i = 0; i < sArgs.cross_validation_arg; i++) {
+			for (i = 0; i < sArgs.cross_validation_arg * sArgs.num_cv_runs_arg; i++) {
 				pTrainSample = LIBSVM::CLIBSVM::CreateSample(PCL, //TODO: make more efficient
 						pTrainVector[i]);
 
 								+= vec_tmpUnlabeledResults[j].Value;
 
 				}
+cerr << "blah" << endl;
                                 LIBSVM::CLIBSVM::PrintSample(*pTrainSample);
+
                                 size_t mem = CMeta::GetMemoryUsage();
                                 cerr << "before free: " << mem << endl;
+
 				if (i > 0) {
 					//LIBSVM::CLIBSVM::FreeSample(*pTrainSample);
                                         free(pTrainSample);
 				}
+
                                 mem = CMeta::GetMemoryUsage();
                                 cerr << "after free: " << mem << endl;
                                 cerr << "end of a cv run" << endl;

File tools/LibSVMer/LibSVMer.ggo

View file
  • Ignore whitespace
 										flag	off
 option	"cross_validation"		c	"Number of cross-validation sets ( arg of 1 will turn off cross-validation )"
 										int default="5" no
+option  "num_cv_runs"                   r       "Number of cross-validation runs"
+                                                                                int default="1" no
 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"
+option "balance"         b   "weight classes such that C_P * n_P = C_N * n_N"
                                                                                 flag off
 option "tradeoff"    			t   "SVM tradeoff constant C of C-SVC"
 										float default="1" no

File tools/LibSVMer/cmdline.c

View file
  • Ignore whitespace
 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  \n                                  (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  (default=off)",
   "\nOptions:",
-  "  -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)",
+  "  -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')",
+  "  -r, --num_cv_runs=INT       Number of cross-validation runs  (default=`1')",
+  "  -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')",
+  "  -b, --balance               weight classes such that C_P * n_P = C_N * n_N  \n                                (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->skip_given = 0 ;
   args_info->normalize_given = 0 ;
   args_info->cross_validation_given = 0 ;
+  args_info->num_cv_runs_given = 0 ;
   args_info->svm_type_given = 0 ;
-  args_info->positive_features_only_given = 0 ;
+  args_info->balance_given = 0 ;
   args_info->tradeoff_given = 0 ;
   args_info->nu_given = 0 ;
   args_info->params_given = 0 ;
   args_info->normalize_flag = 0;
   args_info->cross_validation_arg = 5;
   args_info->cross_validation_orig = NULL;
+  args_info->num_cv_runs_arg = 1;
+  args_info->num_cv_runs_orig = NULL;
   args_info->svm_type_arg = 0;
   args_info->svm_type_orig = NULL;
-  args_info->positive_features_only_flag = 0;
+  args_info->balance_flag = 0;
   args_info->tradeoff_arg = 1;
   args_info->tradeoff_orig = NULL;
   args_info->nu_arg = 0.5;
   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] ;
+  args_info->num_cv_runs_help = gengetopt_args_info_help[12] ;
+  args_info->svm_type_help = gengetopt_args_info_help[13] ;
+  args_info->balance_help = gengetopt_args_info_help[14] ;
+  args_info->tradeoff_help = gengetopt_args_info_help[15] ;
+  args_info->nu_help = gengetopt_args_info_help[16] ;
+  args_info->params_help = gengetopt_args_info_help[17] ;
+  args_info->mmap_help = gengetopt_args_info_help[18] ;
   
 }
 
   free_string_field (&(args_info->model_orig));
   free_string_field (&(args_info->skip_orig));
   free_string_field (&(args_info->cross_validation_orig));
+  free_string_field (&(args_info->num_cv_runs_orig));
   free_string_field (&(args_info->svm_type_orig));
   free_string_field (&(args_info->tradeoff_orig));
   free_string_field (&(args_info->nu_orig));
     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->num_cv_runs_given)
+    write_into_file(outfile, "num_cv_runs", args_info->num_cv_runs_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->balance_given)
+    write_into_file(outfile, "balance", 0, 0 );
   if (args_info->tradeoff_given)
     write_into_file(outfile, "tradeoff", args_info->tradeoff_orig, 0);
   if (args_info->nu_given)
         { "skip",	1, NULL, 's' },
         { "normalize",	0, NULL, 'n' },
         { "cross_validation",	1, NULL, 'c' },
+        { "num_cv_runs",	1, NULL, 'r' },
         { "svm_type",	1, NULL, 'v' },
-        { "positive_features_only",	0, NULL, 'f' },
+        { "balance",	0, NULL, 'b' },
         { "tradeoff",	1, NULL, 't' },
         { "nu",	1, NULL, 'u' },
         { "params",	1, NULL, 'p' },
         { NULL,	0, NULL, 0 }
       };
 
-      c = getopt_long (argc, argv, "hVl:o:i:m:as:nc:v:ft:u:p:M", long_options, &option_index);
+      c = getopt_long (argc, argv, "hVl:o:i:m:as:nc:r:v:bt:u:p:M", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
             goto failure;
         
           break;
+        case 'r':	/* Number of cross-validation runs.  */
+        
+        
+          if (update_arg( (void *)&(args_info->num_cv_runs_arg), 
+               &(args_info->num_cv_runs_orig), &(args_info->num_cv_runs_given),
+              &(local_args_info.num_cv_runs_given), optarg, 0, "1", ARG_INT,
+              check_ambiguity, override, 0, 0,
+              "num_cv_runs", 'r',
+              additional_error))
+            goto failure;
+        
+          break;
         case 'v':	/* Sets type of SVM (default 0)
         0\tC-SVC
         1\tnu-SVC
             goto failure;
         
           break;
-        case 'f':	/* select positive features (i.e. genes) note that input must be complete matrix.  */
+        case 'b':	/* weight classes such that C_P * n_P = C_N * n_N.  */
         
         
-          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',
+          if (update_arg((void *)&(args_info->balance_flag), 0, &(args_info->balance_given),
+              &(local_args_info.balance_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "balance", 'b',
               additional_error))
             goto failure;
         

File tools/LibSVMer/cmdline.h

View file
  • Ignore whitespace
   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 num_cv_runs_arg;	/**< @brief Number of cross-validation runs (default='1').  */
+  char * num_cv_runs_orig;	/**< @brief Number of cross-validation runs original value given at command line.  */
+  const char *num_cv_runs_help; /**< @brief Number of cross-validation runs help description.  */
   int svm_type_arg;	/**< @brief Sets type of SVM (default 0)
   0\tC-SVC
   1\tnu-SVC
   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.  */
+  int balance_flag;	/**< @brief weight classes such that C_P * n_P = C_N * n_N (default=off).  */
+  const char *balance_help; /**< @brief weight classes such that C_P * n_P = C_N * n_N 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.  */
   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 num_cv_runs_given ;	/**< @brief Whether num_cv_runs 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 balance_given ;	/**< @brief Whether balance 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.  */