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