Changeset 7682 for branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification
- Timestamp:
- 04/02/12 10:55:26 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblem.cs
r7259 r7682 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Core; 24 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Problems.Instances; 25 29 26 30 namespace HeuristicLab.Problems.DataAnalysis { … … 28 32 [Item("Classification Problem", "A general classification problem.")] 29 33 [Creatable("Problems")] 30 public class ClassificationProblem : DataAnalysisProblem<IClassificationProblemData>, IClassificationProblem, IStorableContent { 34 public class ClassificationProblem : DataAnalysisProblem<IClassificationProblemData>, IClassificationProblem, IStorableContent, 35 IProblemInstanceConsumer<ClassificationData>, IProblemInstanceExporter<ClassificationData>, IProblemInstanceConsumer { 31 36 public string Filename { get; set; } 32 37 … … 45 50 ProblemData = problemData; 46 51 } 52 53 public void Load(ClassificationData data) { 54 Name = data.Name; 55 Description = data.Description; 56 Dataset dataset = new Dataset(data.InputVariables, data.Values); 57 ProblemData = new ClassificationProblemData(dataset, data.AllowedInputVariables, data.TargetVariable); 58 ProblemData.TrainingPartition.Start = data.TrainingPartitionStart; 59 ProblemData.TrainingPartition.End = data.TrainingPartitionEnd; 60 ProblemData.TestPartition.Start = data.TestPartitionStart; 61 ProblemData.TestPartition.End = data.TestPartitionEnd; 62 OnReset(); 63 } 64 65 public ClassificationData Export() { 66 if (!ProblemData.InputVariables.Count.Equals(ProblemData.Dataset.DoubleVariables.Count())) 67 throw new ArgumentException("Not all input variables are double variables! (Export only works with double variables)"); 68 69 ClassificationData claData = new ClassificationData(); 70 claData.Name = Name; 71 claData.Description = Description; 72 claData.TargetVariable = ProblemData.TargetVariable; 73 claData.InputVariables = ProblemData.InputVariables.Select(x => x.Value).ToArray(); 74 claData.AllowedInputVariables = ProblemData.AllowedInputVariables.ToArray(); 75 claData.TrainingPartitionStart = ProblemData.TrainingPartition.Start; 76 claData.TrainingPartitionEnd = ProblemData.TrainingPartition.End; 77 claData.TestPartitionStart = ProblemData.TestPartition.Start; 78 claData.TestPartitionEnd = ProblemData.TestPartition.End; 79 80 List<List<double>> data = new List<List<double>>(); 81 foreach (var variable in ProblemData.Dataset.DoubleVariables) { 82 data.Add(ProblemData.Dataset.GetDoubleValues(variable).ToList()); 83 } 84 claData.Values = Transformer.Transformation(data); 85 86 return claData; 87 } 47 88 } 48 89 }
Note: See TracChangeset
for help on using the changeset viewer.