Changeset 3884 for trunk/sources/HeuristicLab.ExtLibs
- Timestamp:
- 06/01/10 17:58:03 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Model.cs
r3858 r3884 217 217 model.ClassLabels = null; 218 218 model.NumberOfSVPerClass = null; 219 model.SupportVectorIndizes = new int[0]; 219 220 220 221 bool headerFinished = false; -
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/ParameterSelection.cs
r2645 r3884 150 150 parameters.C = CValues[i]; 151 151 parameters.Gamma = GammaValues[j]; 152 double test = Training.PerformCrossValidation(problem, parameters, nrfold );152 double test = Training.PerformCrossValidation(problem, parameters, nrfold, true); 153 153 Console.Write("{0} {1} {2}", parameters.C, parameters.Gamma, test); 154 154 if(output != null) -
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Solver.cs
r3858 r3884 1555 1555 Parameter newparam = (Parameter)param.Clone(); 1556 1556 newparam.Probability = false; 1557 svm_cross_validation(prob, newparam, nr_fold, ymv );1557 svm_cross_validation(prob, newparam, nr_fold, ymv, true); 1558 1558 for (i = 0; i < prob.Count; i++) 1559 1559 { … … 1872 1872 1873 1873 // Stratified cross validation 1874 public static void svm_cross_validation(Problem prob, Parameter param, int nr_fold, double[] target )1874 public static void svm_cross_validation(Problem prob, Parameter param, int nr_fold, double[] target, bool shuffleTraining) 1875 1875 { 1876 1876 Random rand = new Random(); … … 1936 1936 { 1937 1937 for (i = 0; i < l; i++) perm[i] = i; 1938 for (i = 0; i < l; i++)1939 {1938 if (shuffleTraining) { 1939 for (i = 0; i < l; i++) { 1940 1940 int j = i + (int)(rand.NextDouble() * (l - i)); 1941 1941 do { int _ = perm[i]; perm[i] = perm[j]; perm[j] = _; } while (false); 1942 } 1942 1943 } 1943 1944 for (i = 0; i <= nr_fold; i++) -
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Training.cs
r3879 r3884 43 43 } 44 44 45 private static double doCrossValidation(Problem problem, Parameter parameters, int nr_fold )45 private static double doCrossValidation(Problem problem, Parameter parameters, int nr_fold, bool shuffleTraining) 46 46 { 47 47 int i; 48 48 double[] target = new double[problem.Count]; 49 Procedures.svm_cross_validation(problem, parameters, nr_fold, target );49 Procedures.svm_cross_validation(problem, parameters, nr_fold, target, shuffleTraining); 50 50 int total_correct = 0; 51 51 double total_error = 0; … … 87 87 parseCommandLine(args, out parameters, out problem, out crossValidation, out nrfold, out modelFilename); 88 88 if (crossValidation) 89 PerformCrossValidation(problem, parameters, nrfold );89 PerformCrossValidation(problem, parameters, nrfold, true); 90 90 else Model.Write(modelFilename, Train(problem, parameters)); 91 91 } … … 98 98 /// <param name="nrfold">The number of cross validations to use</param> 99 99 /// <returns>The cross validation score</returns> 100 public static double PerformCrossValidation(Problem problem, Parameter parameters, int nrfold )100 public static double PerformCrossValidation(Problem problem, Parameter parameters, int nrfold, bool shuffleTraining) 101 101 { 102 102 string error = Procedures.svm_check_parameter(problem, parameters); 103 103 if (error == null) 104 return doCrossValidation(problem, parameters, nrfold );104 return doCrossValidation(problem, parameters, nrfold, shuffleTraining); 105 105 else throw new Exception(error); 106 106 }
Note: See TracChangeset
for help on using the changeset viewer.