Changeset 7759 for branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblem.cs
- Timestamp:
- 04/24/12 16:37:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblem.cs
r7758 r7759 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 22 using HeuristicLab.Common; 26 23 using HeuristicLab.Core; … … 33 30 [Creatable("Problems")] 34 31 public class RegressionProblem : DataAnalysisProblem<IRegressionProblemData>, IRegressionProblem, IStorableContent, 35 IProblemInstanceConsumer<Regression Data>, IProblemInstanceExporter<RegressionData> {32 IProblemInstanceConsumer<RegressionProblemData>, IProblemInstanceExporter<RegressionProblemData> { 36 33 public string Filename { get; set; } 37 34 … … 46 43 } 47 44 48 public void Load(Regression Data data) {45 public void Load(RegressionProblemData data) { 49 46 Name = data.Name; 50 47 Description = data.Description; 51 Dataset dataset = new Dataset(data.InputVariables, data.Values); 52 ProblemData = new RegressionProblemData(dataset, data.AllowedInputVariables, data.TargetVariable); 53 ProblemData.TrainingPartition.Start = data.TrainingPartitionStart; 54 ProblemData.TrainingPartition.End = data.TrainingPartitionEnd; 55 ProblemData.TestPartition.Start = data.TestPartitionStart; 56 ProblemData.TestPartition.End = data.TestPartitionEnd; 48 ProblemData = new RegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable); 49 ProblemData.TrainingPartition.Start = data.TrainingPartition.Start; 50 ProblemData.TrainingPartition.End = data.TrainingPartition.End; 51 ProblemData.TestPartition.Start = data.TestPartition.Start; 52 ProblemData.TestPartition.End = data.TestPartition.End; 57 53 OnReset(); 58 54 } 59 55 60 public RegressionData Export() { 61 if (!ProblemData.InputVariables.Count.Equals(ProblemData.Dataset.DoubleVariables.Count())) 62 throw new ArgumentException("Not all input variables are double variables! (Export only works with double variables)"); 63 64 RegressionData regData = new RegressionData(); 56 public RegressionProblemData Export() { 57 RegressionProblemData regData = new RegressionProblemData(ProblemData.Dataset, ProblemData.AllowedInputVariables, ProblemData.TargetVariable); 65 58 regData.Name = Name; 66 59 regData.Description = Description; 67 regData.TargetVariable = ProblemData.TargetVariable; 68 regData.InputVariables = ProblemData.InputVariables.Select(x => x.Value).ToArray(); 69 regData.AllowedInputVariables = ProblemData.AllowedInputVariables.ToArray(); 70 regData.TrainingPartitionStart = ProblemData.TrainingPartition.Start; 71 regData.TrainingPartitionEnd = ProblemData.TrainingPartition.End; 72 regData.TestPartitionStart = ProblemData.TestPartition.Start; 73 regData.TestPartitionEnd = ProblemData.TestPartition.End; 74 75 List<List<double>> data = new List<List<double>>(); 76 foreach (var variable in ProblemData.Dataset.DoubleVariables) { 77 data.Add(ProblemData.Dataset.GetDoubleValues(variable).ToList()); 78 } 79 regData.Values = Transformer.Transformation(data); 80 60 regData.TrainingPartition.Start = ProblemData.TrainingPartition.Start; 61 regData.TrainingPartition.End = ProblemData.TrainingPartition.End; 62 regData.TestPartition.Start = ProblemData.TestPartition.Start; 63 regData.TestPartition.End = ProblemData.TestPartition.End; 81 64 return regData; 82 65 }
Note: See TracChangeset
for help on using the changeset viewer.