YOUNG-SUK LEE avatar YOUNG-SUK LEE committed 0ba3d77

fix bug in multiple cv runs

Comments (0)

Files changed (1)

tools/LibSVMer/LibSVMer.cpp

 	size_t i, j, iGene, jGene;
 	ifstream ifsm;
 
+        bool added;
+        added = false;
 
 	if (cmdline_parser(iArgs, aszArgs, &sArgs)) {
 		cmdline_parser_print_help();
 						pTestVector[i]);
 				cerr << "Classified " << tmpAllResults.size() << " examples"
 						<< endl;
-				AllResults.insert(AllResults.end(), tmpAllResults.begin(),
-						tmpAllResults.end());
+                                for(std::vector<LIBSVM::Result>::iterator it = tmpAllResults.begin() ; it != tmpAllResults.end() ; it ++){
+                                  added = false;
+                                  for(std::vector<LIBSVM::Result>::iterator ita = AllResults.begin() ; ita != AllResults.end() ; ita ++){
+                                    if ( (*it).GeneName.compare((*ita).GeneName) == 0 ){
+                                      (*ita).Value += (*it).Value;
+                                      added = true;
+                                      break;
+                                    }
+
+                                  }
+
+                                  if(!added)
+                                    AllResults.push_back((*it));
+
+//				AllResults.insert(AllResults.end(), tmpAllResults.begin(),
+//						tmpAllResults.end());
+//
+                                }
 				tmpAllResults.resize(0);
 				if (sArgs.all_flag) {
 					vec_tmpUnlabeledResults = SVM.Classify(
                                 cerr << "end of a cv run" << endl;
 			}
 
+                        for(std::vector<LIBSVM::Result>::iterator it = AllResults.begin();
+                            it != AllResults.end(); ++ it){
+                          (*it).Value /= sArgs.num_cv_runs_arg;
+
+                        }
+
+
+
 			if (sArgs.all_flag) { //add the unlabeled results
 				for (j = 0; j < vec_allUnlabeledResults.size(); j++)
 					vec_allUnlabeledResults[j].Value
 						vec_allUnlabeledResults.end());
 			}
 
+//                        tmpAllResults.clear();
+                        
+
 			ofstream ofsm;
 			ofsm.clear();
 			ofsm.open(sArgs.output_arg);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.