Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11542


Ignore:
Timestamp:
11/12/14 17:07:06 (10 years ago)
Author:
bburlacu
Message:

#2234: Fixed bug in CrossValidate method where the OnlineCalculatorError was ignored. Updated GridSearch method to return the crossvalidation mse as an out parameter and to skip nan values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs

    r11464 r11542  
    9292    }
    9393
    94     public static svm_parameter GridSearch(IDataAnalysisProblemData problemData, Dictionary<string, IEnumerable<double>> parameterRanges, int numberOfFolds, bool shuffleFolds = true, int maxDegreeOfParallelism = 1) {
     94    public static svm_parameter GridSearch(out double cvMse, IDataAnalysisProblemData problemData, Dictionary<string, IEnumerable<double>> parameterRanges, int numberOfFolds, bool shuffleFolds = true, int maxDegreeOfParallelism = 1) {
    9595      DoubleValue mse = new DoubleValue(Double.MaxValue);
    9696      var bestParam = DefaultParameters();
     
    108108
    109109        double testMse = CalculateCrossValidationPartitions(partitions, parameters);
    110         lock (locker) {
    111           if (testMse < mse.Value) {
    112             mse.Value = testMse;
    113             bestParam = (svm_parameter)parameters.Clone();
     110        if (!double.IsNaN(testMse)) {
     111          lock (locker) {
     112            if (testMse < mse.Value) {
     113              mse.Value = testMse;
     114              bestParam = (svm_parameter)parameters.Clone();
     115            }
    114116          }
    115117        }
    116118      });
     119      cvMse = mse.Value;
    117120      return bestParam;
    118121    }
     
    128131        for (int i = 0; i < testSvmProblem.l; ++i)
    129132          calc.Add(testSvmProblem.y[i], svm.svm_predict(model, testSvmProblem.x[i]));
    130         avgTestMse += calc.MeanSquaredError;
     133        double mse = calc.ErrorState == OnlineCalculatorError.None ? calc.MeanSquaredError : double.NaN;
     134        avgTestMse += mse;
    131135      }
    132136      avgTestMse /= partitions.Length;
Note: See TracChangeset for help on using the changeset viewer.