Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/10 17:58:03 (14 years ago)
Author:
gkronber
Message:

Worked on support vector regression operators and views. #1009

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  
    217217      model.ClassLabels = null;
    218218      model.NumberOfSVPerClass = null;
     219      model.SupportVectorIndizes = new int[0];
    219220
    220221      bool headerFinished = false;
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/ParameterSelection.cs

    r2645 r3884  
    150150                    parameters.C = CValues[i];
    151151                    parameters.Gamma = GammaValues[j];
    152                     double test = Training.PerformCrossValidation(problem, parameters, nrfold);
     152                    double test = Training.PerformCrossValidation(problem, parameters, nrfold, true);
    153153                    Console.Write("{0} {1} {2}", parameters.C, parameters.Gamma, test);
    154154                    if(output != null)
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Solver.cs

    r3858 r3884  
    15551555            Parameter newparam = (Parameter)param.Clone();
    15561556            newparam.Probability = false;
    1557             svm_cross_validation(prob, newparam, nr_fold, ymv);
     1557            svm_cross_validation(prob, newparam, nr_fold, ymv, true);
    15581558            for (i = 0; i < prob.Count; i++)
    15591559            {
     
    18721872
    18731873        // 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)
    18751875        {
    18761876            Random rand = new Random();
     
    19361936            {
    19371937                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++) {
    19401940                    int j = i + (int)(rand.NextDouble() * (l - i));
    19411941                    do { int _ = perm[i]; perm[i] = perm[j]; perm[j] = _; } while (false);
     1942                  }
    19421943                }
    19431944                for (i = 0; i <= nr_fold; i++)
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Training.cs

    r3879 r3884  
    4343        }
    4444
    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)
    4646        {
    4747            int i;
    4848            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);
    5050            int total_correct = 0;
    5151            double total_error = 0;
     
    8787            parseCommandLine(args, out parameters, out problem, out crossValidation, out nrfold, out modelFilename);
    8888            if (crossValidation)
    89                 PerformCrossValidation(problem, parameters, nrfold);
     89                PerformCrossValidation(problem, parameters, nrfold, true);
    9090            else Model.Write(modelFilename, Train(problem, parameters));
    9191        }
     
    9898        /// <param name="nrfold">The number of cross validations to use</param>
    9999        /// <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)
    101101        {
    102102            string error = Procedures.svm_check_parameter(problem, parameters);
    103103            if (error == null)
    104                 return doCrossValidation(problem, parameters, nrfold);
     104                return doCrossValidation(problem, parameters, nrfold, shuffleTraining);
    105105            else throw new Exception(error);
    106106        }
Note: See TracChangeset for help on using the changeset viewer.