Changeset 5275 for branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineModelCreator.cs
- Timestamp:
- 01/11/11 15:03:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineModelCreator.cs
r4068 r5275 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Core; 24 27 using HeuristicLab.Data; … … 34 37 [StorableClass] 35 38 [Item("SupportVectorMachineModelCreator", "Represents an operator that creates a support vector machine model.")] 36 public class SupportVectorMachineModelCreator : SingleSuccessorOperator {39 public sealed class SupportVectorMachineModelCreator : SingleSuccessorOperator { 37 40 private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData"; 38 41 private const string SvmTypeParameterName = "SvmType"; … … 108 111 #endregion 109 112 113 [StorableConstructor] 114 private SupportVectorMachineModelCreator(bool deserializing) : base(deserializing) { } 115 private SupportVectorMachineModelCreator(SupportVectorMachineModelCreator original, Cloner cloner) : base(original, cloner) { } 116 public override IDeepCloneable Clone(Cloner cloner) { 117 return new SupportVectorMachineModelCreator(this, cloner); 118 } 110 119 public SupportVectorMachineModelCreator() 111 120 : base() { … … 125 134 126 135 public override IOperation Apply() { 136 int start = SamplesStart.Value; 137 int end = SamplesEnd.Value; 138 IEnumerable<int> rows = 139 Enumerable.Range(start, end - start) 140 .Where(i => i < DataAnalysisProblemData.TestSamplesStart.Value || DataAnalysisProblemData.TestSamplesEnd.Value <= i); 141 127 142 SupportVectorMachineModel model = TrainModel(DataAnalysisProblemData, 128 SamplesStart.Value, SamplesEnd.Value,143 rows, 129 144 SvmType.Value, KernelType.Value, 130 145 Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value); … … 138 153 string svmType, string kernelType, 139 154 double cost, double nu, double gamma, double epsilon) { 140 return TrainModel(problemData, problemData.Training SamplesStart.Value, problemData.TrainingSamplesEnd.Value, svmType, kernelType, cost, nu, gamma, epsilon);155 return TrainModel(problemData, problemData.TrainingIndizes, svmType, kernelType, cost, nu, gamma, epsilon); 141 156 } 142 157 143 158 public static SupportVectorMachineModel TrainModel( 144 159 DataAnalysisProblemData problemData, 145 int start, int end,160 IEnumerable<int> trainingIndizes, 146 161 string svmType, string kernelType, 147 162 double cost, double nu, double gamma, double epsilon) { … … 160 175 161 176 162 SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, start, end);177 SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, trainingIndizes); 163 178 SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem); 164 179 SVM.Problem scaledProblem = Scaling.Scale(rangeTransform, problem);
Note: See TracChangeset
for help on using the changeset viewer.