Changeset 7460 for branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorClassification.cs
- Timestamp:
- 02/06/12 17:50:17 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries
- Property svn:ignore
-
old new 3 3 *.resharper 4 4 *.suo 5 *.user 5 6 *.vsp 6 7 Doxygen 8 FxCopResults.txt 7 9 Google.ProtocolBuffers-0.9.1.dll 8 10 HeuristicLab 3.3.5.1.ReSharper.user
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorClassification.cs
r7268 r7460 113 113 IClassificationProblemData problemData = Problem.ProblemData; 114 114 IEnumerable<string> selectedInputVariables = problemData.AllowedInputVariables; 115 var solution = CreateSupportVectorClassificationSolution(problemData, selectedInputVariables, SvmType.Value, KernelType.Value, Cost.Value, Nu.Value, Gamma.Value); 115 double trainingAccuracy, testAccuracy; 116 int nSv; 117 var solution = CreateSupportVectorClassificationSolution(problemData, selectedInputVariables, 118 SvmType.Value, KernelType.Value, Cost.Value, Nu.Value, Gamma.Value, 119 out trainingAccuracy, out testAccuracy, out nSv); 116 120 117 121 Results.Add(new Result("Support vector classification solution", "The support vector classification solution.", solution)); 122 Results.Add(new Result("Training accuracy", "The accuracy of the SVR solution on the training partition.", new DoubleValue(trainingAccuracy))); 123 Results.Add(new Result("Test R²", "The accuracy of the SVR solution on the test partition.", new DoubleValue(testAccuracy))); 124 Results.Add(new Result("Number of support vectors", "The number of support vectors of the SVR solution.", new IntValue(nSv))); 118 125 } 119 126 120 127 public static SupportVectorClassificationSolution CreateSupportVectorClassificationSolution(IClassificationProblemData problemData, IEnumerable<string> allowedInputVariables, 121 string svmType, string kernelType, double cost, double nu, double gamma) { 128 string svmType, string kernelType, double cost, double nu, double gamma, 129 out double trainingAccuracy, out double testAccuracy, out int nSv) { 122 130 Dataset dataset = problemData.Dataset; 123 131 string targetVariable = problemData.TargetVariable; … … 148 156 SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem); 149 157 SVM.Problem scaledProblem = SVM.Scaling.Scale(rangeTransform, problem); 150 var model = new SupportVectorMachineModel(SVM.Training.Train(scaledProblem, parameter), rangeTransform, targetVariable, allowedInputVariables, problemData.ClassValues); 158 var svmModel = SVM.Training.Train(scaledProblem, parameter); 159 var model = new SupportVectorMachineModel(svmModel, rangeTransform, targetVariable, allowedInputVariables, problemData.ClassValues); 160 var solution = new SupportVectorClassificationSolution(model, (IClassificationProblemData)problemData.Clone()); 151 161 152 return new SupportVectorClassificationSolution(model, (IClassificationProblemData)problemData.Clone()); 162 nSv = svmModel.SupportVectorCount; 163 trainingAccuracy = solution.TrainingAccuracy; 164 testAccuracy = solution.TestAccuracy; 165 166 return solution; 153 167 } 154 168 #endregion
Note: See TracChangeset
for help on using the changeset viewer.