Changeset 5275 for branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression
- Timestamp:
- 01/11/11 15:03:46 (14 years ago)
- Location:
- branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression/BestSupportVectorRegressionSolutionAnalyzer.cs
r4068 r5275 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 52 53 #endregion 53 54 55 [StorableConstructor] 56 private BestSupportVectorRegressionSolutionAnalyzer(bool deserializing) : base(deserializing) { } 57 private BestSupportVectorRegressionSolutionAnalyzer(BestSupportVectorRegressionSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { } 54 58 public BestSupportVectorRegressionSolutionAnalyzer() 55 59 : base() { 56 60 Parameters.Add(new ScopeTreeLookupParameter<SupportVectorMachineModel>(SupportVectorRegressionModelParameterName, "The support vector regression models to analyze.")); 57 61 Parameters.Add(new LookupParameter<SupportVectorRegressionSolution>(BestSolutionParameterName, "The best support vector regression solution.")); 62 } 63 64 public override IDeepCloneable Clone(Cloner cloner) { 65 return new BestSupportVectorRegressionSolutionAnalyzer(this, cloner); 58 66 } 59 67 … … 68 76 where ProblemData.InputVariables.ItemChecked(var) 69 77 select var.Value; 70 var solution = new SupportVectorRegressionSolution( ProblemData, SupportVectorMachineModel[i], inputVariables, lowerEstimationLimit, upperEstimationLimit);78 var solution = new SupportVectorRegressionSolution((DataAnalysisProblemData)ProblemData.Clone(), SupportVectorMachineModel[i], inputVariables, lowerEstimationLimit, upperEstimationLimit); 71 79 72 80 BestSolutionParameter.ActualValue = solution; -
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression/SupportVectorRegressionSolution.cs
r4068 r5275 24 24 using System.Drawing; 25 25 using System.Linq; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 36 37 [StorableClass] 37 38 public sealed class SupportVectorRegressionSolution : DataAnalysisSolution { 38 public SupportVectorRegressionSolution() : base() { }39 public SupportVectorRegressionSolution(DataAnalysisProblemData problemData, SupportVectorMachineModel model, IEnumerable<string> inputVariables, double lowerEstimationLimit, double upperEstimationLimit)40 : base(problemData, lowerEstimationLimit, upperEstimationLimit) {41 this.Model = model;42 }43 44 39 public override Image ItemImage { 45 40 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Function; } … … 53 48 public Dataset SupportVectors { 54 49 get { return CalculateSupportVectors(); } 50 } 51 52 private List<double> estimatedValues; 53 public override IEnumerable<double> EstimatedValues { 54 get { 55 if (estimatedValues == null) RecalculateEstimatedValues(); 56 return estimatedValues; 57 } 58 } 59 60 public override IEnumerable<double> EstimatedTrainingValues { 61 get { 62 return GetEstimatedValues(ProblemData.TrainingIndizes); 63 } 64 } 65 66 public override IEnumerable<double> EstimatedTestValues { 67 get { 68 return GetEstimatedValues(ProblemData.TestIndizes); 69 } 70 } 71 72 [StorableConstructor] 73 private SupportVectorRegressionSolution(bool deserializing) : base(deserializing) { } 74 private SupportVectorRegressionSolution(SupportVectorRegressionSolution original, Cloner cloner) : base(original, cloner) { } 75 public SupportVectorRegressionSolution() : base() { } 76 public SupportVectorRegressionSolution(DataAnalysisProblemData problemData, SupportVectorMachineModel model, IEnumerable<string> inputVariables, double lowerEstimationLimit, double upperEstimationLimit) 77 : base(problemData, lowerEstimationLimit, upperEstimationLimit) { 78 this.Model = model; 79 } 80 81 public override IDeepCloneable Clone(Cloner cloner) { 82 return new SupportVectorRegressionSolution(this, cloner); 55 83 } 56 84 … … 73 101 74 102 protected override void RecalculateEstimatedValues() { 75 SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(ProblemData, 0, ProblemData.Dataset.Rows);103 SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(ProblemData, Enumerable.Range(0, ProblemData.Dataset.Rows)); 76 104 SVM.Problem scaledProblem = Scaling.Scale(Model.RangeTransform, problem); 77 105 … … 83 111 } 84 112 85 private List<double> estimatedValues;86 public override IEnumerable<double> EstimatedValues {87 get {88 if (estimatedValues == null) RecalculateEstimatedValues();89 return estimatedValues.AsEnumerable();90 }91 }92 113 93 public override IEnumerable<double> EstimatedTrainingValues { 94 get { 95 if (estimatedValues == null) RecalculateEstimatedValues(); 96 int start = ProblemData.TrainingSamplesStart.Value; 97 int n = ProblemData.TrainingSamplesEnd.Value - start; 98 return estimatedValues.Skip(start).Take(n).ToList(); 99 } 100 } 101 102 public override IEnumerable<double> EstimatedTestValues { 103 get { 104 if (estimatedValues == null) RecalculateEstimatedValues(); 105 int start = ProblemData.TestSamplesStart.Value; 106 int n = ProblemData.TestSamplesEnd.Value - start; 107 return estimatedValues.Skip(start).Take(n).ToList(); 108 } 114 private IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows) { 115 if (estimatedValues == null) RecalculateEstimatedValues(); 116 foreach (int row in rows) 117 yield return estimatedValues[row]; 109 118 } 110 119 }
Note: See TracChangeset
for help on using the changeset viewer.