Changeset 7750 for branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
- Timestamp:
- 04/23/12 16:50:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
r7734 r7750 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Linq; 23 25 using HeuristicLab.Common; … … 25 27 using HeuristicLab.Parameters; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Problems.Instances; 27 30 28 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { … … 30 33 [StorableClass] 31 34 [Creatable("Problems")] 32 public class SymbolicRegressionSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IRegressionProblemData, ISymbolicRegressionSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator>, IRegressionProblem { 35 public class SymbolicRegressionSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IRegressionProblemData, ISymbolicRegressionSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator>, IRegressionProblem, 36 IProblemInstanceConsumer<RegressionData>, IProblemInstanceExporter<RegressionData> { 33 37 private const double PunishmentFactor = 10; 34 38 private const int InitialMaximumTreeDepth = 8; … … 116 120 ProblemData = problemData; 117 121 } 122 123 public void Load(RegressionData data) { 124 Name = data.Name; 125 Description = data.Description; 126 Dataset dataset = new Dataset(data.InputVariables, data.Values); 127 ProblemData = new RegressionProblemData(dataset, data.AllowedInputVariables, data.TargetVariable); 128 ProblemData.TrainingPartition.Start = data.TrainingPartitionStart; 129 ProblemData.TrainingPartition.End = data.TrainingPartitionEnd; 130 ProblemData.TestPartition.Start = data.TestPartitionStart; 131 ProblemData.TestPartition.End = data.TestPartitionEnd; 132 OnReset(); 133 } 134 135 public RegressionData Export() { 136 if (!ProblemData.InputVariables.Count.Equals(ProblemData.Dataset.DoubleVariables.Count())) 137 throw new ArgumentException("Not all input variables are double variables! (Export only works with double variables)"); 138 139 RegressionData regData = new RegressionData(); 140 regData.Name = Name; 141 regData.Description = Description; 142 regData.TargetVariable = ProblemData.TargetVariable; 143 regData.InputVariables = ProblemData.InputVariables.Select(x => x.Value).ToArray(); 144 regData.AllowedInputVariables = ProblemData.AllowedInputVariables.ToArray(); 145 regData.TrainingPartitionStart = ProblemData.TrainingPartition.Start; 146 regData.TrainingPartitionEnd = ProblemData.TrainingPartition.End; 147 regData.TestPartitionStart = ProblemData.TestPartition.Start; 148 regData.TestPartitionEnd = ProblemData.TestPartition.End; 149 150 List<List<double>> data = new List<List<double>>(); 151 foreach (var variable in ProblemData.Dataset.DoubleVariables) { 152 data.Add(ProblemData.Dataset.GetDoubleValues(variable).ToList()); 153 } 154 regData.Values = Transformer.Transformation(data); 155 156 return regData; 157 } 118 158 } 119 159 }
Note: See TracChangeset
for help on using the changeset viewer.