Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/06/12 17:50:17 (12 years ago)
Author:
gkronber
Message:

#1081: merged r7266:7459 from the trunk into the time series prognosis branch.

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs

    r7268 r7460  
    121121      IRegressionProblemData problemData = Problem.ProblemData;
    122122      IEnumerable<string> selectedInputVariables = problemData.AllowedInputVariables;
    123       var solution = CreateSupportVectorRegressionSolution(problemData, selectedInputVariables, SvmType.Value, KernelType.Value, Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value);
     123      double trainR2, testR2;
     124      int nSv;
     125      var solution = CreateSupportVectorRegressionSolution(problemData, selectedInputVariables, SvmType.Value,
     126        KernelType.Value, Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value,
     127        out trainR2, out testR2, out nSv);
    124128
    125129      Results.Add(new Result("Support vector regression solution", "The support vector regression solution.", solution));
     130      Results.Add(new Result("Training R²", "The Pearson's R² of the SVR solution on the training partition.", new DoubleValue(trainR2)));
     131      Results.Add(new Result("Test R²", "The Pearson's R² of the SVR solution on the test partition.", new DoubleValue(testR2)));
     132      Results.Add(new Result("Number of support vectors", "The number of support vectors of the SVR solution.", new IntValue(nSv)));
    126133    }
    127134
    128135    public static SupportVectorRegressionSolution CreateSupportVectorRegressionSolution(IRegressionProblemData problemData, IEnumerable<string> allowedInputVariables,
    129       string svmType, string kernelType, double cost, double nu, double gamma, double epsilon) {
     136      string svmType, string kernelType, double cost, double nu, double gamma, double epsilon,
     137      out double trainingR2, out double testR2, out int nSv) {
    130138      Dataset dataset = problemData.Dataset;
    131139      string targetVariable = problemData.TargetVariable;
     
    146154      SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem);
    147155      SVM.Problem scaledProblem = SVM.Scaling.Scale(rangeTransform, problem);
    148       var model = new SupportVectorMachineModel(SVM.Training.Train(scaledProblem, parameter), rangeTransform, targetVariable, allowedInputVariables);
    149       return new SupportVectorRegressionSolution(model, (IRegressionProblemData)problemData.Clone());
     156      var svmModel = SVM.Training.Train(scaledProblem, parameter);
     157      nSv = svmModel.SupportVectorCount;
     158      var model = new SupportVectorMachineModel(svmModel, rangeTransform, targetVariable, allowedInputVariables);
     159      var solution = new SupportVectorRegressionSolution(model, (IRegressionProblemData)problemData.Clone());
     160      trainingR2 = solution.TrainingRSquared;
     161      testR2 = solution.TestRSquared;
     162      return solution;
    150163    }
    151164    #endregion
Note: See TracChangeset for help on using the changeset viewer.