Changeset 7759 for branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblem.cs
- Timestamp:
- 04/24/12 16:37:40 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblem.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 ClassificationProblem : DataAnalysisProblem<IClassificationProblemData>, IClassificationProblem, IStorableContent, 35 IProblemInstanceConsumer<Classification Data>, IProblemInstanceExporter<ClassificationData> {32 IProblemInstanceConsumer<ClassificationProblemData>, IProblemInstanceExporter<ClassificationProblemData> { 36 33 public string Filename { get; set; } 37 34 … … 46 43 } 47 44 48 public void Load(Classification Data data) {45 public void Load(ClassificationProblemData data) { 49 46 Name = data.Name; 50 47 Description = data.Description; 51 Dataset dataset = new Dataset(data.InputVariables, data.Values); 52 ProblemData = new ClassificationProblemData(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 ClassificationProblemData(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 ClassificationData 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 ClassificationData claData = new ClassificationData(); 56 public ClassificationProblemData Export() { 57 ClassificationProblemData claData = new ClassificationProblemData(ProblemData.Dataset, ProblemData.AllowedInputVariables, ProblemData.TargetVariable); 65 58 claData.Name = Name; 66 59 claData.Description = Description; 67 claData.TargetVariable = ProblemData.TargetVariable; 68 claData.InputVariables = ProblemData.InputVariables.Select(x => x.Value).ToArray(); 69 claData.AllowedInputVariables = ProblemData.AllowedInputVariables.ToArray(); 70 claData.TrainingPartitionStart = ProblemData.TrainingPartition.Start; 71 claData.TrainingPartitionEnd = ProblemData.TrainingPartition.End; 72 claData.TestPartitionStart = ProblemData.TestPartition.Start; 73 claData.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 claData.Values = Transformer.Transformation(data); 80 60 claData.TrainingPartition.Start = ProblemData.TrainingPartition.Start; 61 claData.TrainingPartition.End = ProblemData.TrainingPartition.End; 62 claData.TestPartition.Start = ProblemData.TestPartition.Start; 63 claData.TestPartition.End = ProblemData.TestPartition.End; 81 64 return claData; 82 65 }
Note: See TracChangeset
for help on using the changeset viewer.