Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7759


Ignore:
Timestamp:
04/24/12 16:37:40 (13 years ago)
Author:
sforsten
Message:

#1784:

  • deleted ClassificationData and RegressionData. RegressionProblemData and ClassificationProblemData are used instead
  • deleted not needed Transformer
  • ValueGenerator is now a static class and yield return is used return IEnumerable
Location:
branches/ProblemInstancesRegressionAndClassification
Files:
3 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj

    r7758 r7759  
    196196      <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>
    197197      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>
     198      <Private>False</Private>
    198199    </ProjectReference>
    199200    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveProblem.cs

    r7758 r7759  
    1919 */
    2020#endregion
    21 using System;
    22 using System.Collections.Generic;
    2321using System.Linq;
    2422using HeuristicLab.Common;
     
    3331  [Creatable("Problems")]
    3432  public class SymbolicClassificationSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IClassificationProblemData, ISymbolicClassificationSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator>, IClassificationProblem,
    35     IProblemInstanceConsumer<ClassificationData>, IProblemInstanceExporter<ClassificationData> {
     33    IProblemInstanceConsumer<ClassificationProblemData>, IProblemInstanceExporter<ClassificationProblemData> {
    3634    private const double PunishmentFactor = 10;
    3735    private const int InitialMaximumTreeDepth = 8;
     
    113111    }
    114112
    115     public void Load(ClassificationData data) {
     113    public void Load(ClassificationProblemData data) {
    116114      Name = data.Name;
    117115      Description = data.Description;
    118       Dataset dataset = new Dataset(data.InputVariables, data.Values);
    119       ProblemData = new ClassificationProblemData(dataset, data.AllowedInputVariables, data.TargetVariable);
    120       ProblemData.TrainingPartition.Start = data.TrainingPartitionStart;
    121       ProblemData.TrainingPartition.End = data.TrainingPartitionEnd;
    122       ProblemData.TestPartition.Start = data.TestPartitionStart;
    123       ProblemData.TestPartition.End = data.TestPartitionEnd;
     116      ProblemData = new ClassificationProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable);
     117      ProblemData.TrainingPartition.Start = data.TrainingPartition.Start;
     118      ProblemData.TrainingPartition.End = data.TrainingPartition.End;
     119      ProblemData.TestPartition.Start = data.TestPartition.Start;
     120      ProblemData.TestPartition.End = data.TestPartition.End;
    124121      OnReset();
    125122    }
    126123
    127     public ClassificationData Export() {
    128       if (!ProblemData.InputVariables.Count.Equals(ProblemData.Dataset.DoubleVariables.Count()))
    129         throw new ArgumentException("Not all input variables are double variables! (Export only works with double variables)");
    130 
    131       ClassificationData claData = new ClassificationData();
     124    public ClassificationProblemData Export() {
     125      ClassificationProblemData claData = new ClassificationProblemData(ProblemData.Dataset, ProblemData.AllowedInputVariables, ProblemData.TargetVariable);
    132126      claData.Name = Name;
    133127      claData.Description = Description;
    134       claData.TargetVariable = ProblemData.TargetVariable;
    135       claData.InputVariables = ProblemData.InputVariables.Select(x => x.Value).ToArray();
    136       claData.AllowedInputVariables = ProblemData.AllowedInputVariables.ToArray();
    137       claData.TrainingPartitionStart = ProblemData.TrainingPartition.Start;
    138       claData.TrainingPartitionEnd = ProblemData.TrainingPartition.End;
    139       claData.TestPartitionStart = ProblemData.TestPartition.Start;
    140       claData.TestPartitionEnd = ProblemData.TestPartition.End;
    141 
    142       List<List<double>> data = new List<List<double>>();
    143       foreach (var variable in ProblemData.Dataset.DoubleVariables) {
    144         data.Add(ProblemData.Dataset.GetDoubleValues(variable).ToList());
    145       }
    146       claData.Values = Transformer.Transformation(data);
    147 
     128      claData.TrainingPartition.Start = ProblemData.TrainingPartition.Start;
     129      claData.TrainingPartition.End = ProblemData.TrainingPartition.End;
     130      claData.TestPartition.Start = ProblemData.TestPartition.Start;
     131      claData.TestPartition.End = ProblemData.TestPartition.End;
    148132      return claData;
    149133    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r7758 r7759  
    191191      <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>
    192192      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>
     193      <Private>False</Private>
    193194    </ProjectReference>
    194195    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs

    r7758 r7759  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.Linq;
    2523using HeuristicLab.Common;
     
    3432  [Creatable("Problems")]
    3533  public class SymbolicRegressionSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IRegressionProblemData, ISymbolicRegressionSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator>, IRegressionProblem,
    36     IProblemInstanceConsumer<RegressionData>, IProblemInstanceExporter<RegressionData> {
     34    IProblemInstanceConsumer<RegressionProblemData>, IProblemInstanceExporter<RegressionProblemData> {
    3735    private const double PunishmentFactor = 10;
    3836    private const int InitialMaximumTreeDepth = 8;
     
    116114    }
    117115
    118     public void Load(RegressionData data) {
     116    public void Load(RegressionProblemData data) {
    119117      Name = data.Name;
    120118      Description = data.Description;
    121       Dataset dataset = new Dataset(data.InputVariables, data.Values);
    122       ProblemData = new RegressionProblemData(dataset, data.AllowedInputVariables, data.TargetVariable);
    123       ProblemData.TrainingPartition.Start = data.TrainingPartitionStart;
    124       ProblemData.TrainingPartition.End = data.TrainingPartitionEnd;
    125       ProblemData.TestPartition.Start = data.TestPartitionStart;
    126       ProblemData.TestPartition.End = data.TestPartitionEnd;
     119      ProblemData = new RegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable);
     120      ProblemData.TrainingPartition.Start = data.TrainingPartition.Start;
     121      ProblemData.TrainingPartition.End = data.TrainingPartition.End;
     122      ProblemData.TestPartition.Start = data.TestPartition.Start;
     123      ProblemData.TestPartition.End = data.TestPartition.End;
    127124      OnReset();
    128125    }
    129126
    130     public RegressionData Export() {
    131       if (!ProblemData.InputVariables.Count.Equals(ProblemData.Dataset.DoubleVariables.Count()))
    132         throw new ArgumentException("Not all input variables are double variables! (Export only works with double variables)");
    133 
    134       RegressionData regData = new RegressionData();
     127    public RegressionProblemData Export() {
     128      RegressionProblemData regData = new RegressionProblemData(ProblemData.Dataset, ProblemData.AllowedInputVariables, ProblemData.TargetVariable);
    135129      regData.Name = Name;
    136130      regData.Description = Description;
    137       regData.TargetVariable = ProblemData.TargetVariable;
    138       regData.InputVariables = ProblemData.InputVariables.Select(x => x.Value).ToArray();
    139       regData.AllowedInputVariables = ProblemData.AllowedInputVariables.ToArray();
    140       regData.TrainingPartitionStart = ProblemData.TrainingPartition.Start;
    141       regData.TrainingPartitionEnd = ProblemData.TrainingPartition.End;
    142       regData.TestPartitionStart = ProblemData.TestPartition.Start;
    143       regData.TestPartitionEnd = ProblemData.TestPartition.End;
    144 
    145       List<List<double>> data = new List<List<double>>();
    146       foreach (var variable in ProblemData.Dataset.DoubleVariables) {
    147         data.Add(ProblemData.Dataset.GetDoubleValues(variable).ToList());
    148       }
    149       regData.Values = Transformer.Transformation(data);
    150 
     131      regData.TrainingPartition.Start = ProblemData.TrainingPartition.Start;
     132      regData.TrainingPartition.End = ProblemData.TrainingPartition.End;
     133      regData.TestPartition.Start = ProblemData.TestPartition.Start;
     134      regData.TestPartition.End = ProblemData.TestPartition.End;
    151135      return regData;
    152136    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblem.cs

    r7758 r7759  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using HeuristicLab.Common;
    2623using HeuristicLab.Core;
     
    3330  [Creatable("Problems")]
    3431  public class ClassificationProblem : DataAnalysisProblem<IClassificationProblemData>, IClassificationProblem, IStorableContent,
    35     IProblemInstanceConsumer<ClassificationData>, IProblemInstanceExporter<ClassificationData> {
     32    IProblemInstanceConsumer<ClassificationProblemData>, IProblemInstanceExporter<ClassificationProblemData> {
    3633    public string Filename { get; set; }
    3734
     
    4643    }
    4744
    48     public void Load(ClassificationData data) {
     45    public void Load(ClassificationProblemData data) {
    4946      Name = data.Name;
    5047      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;
    5753      OnReset();
    5854    }
    5955
    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);
    6558      claData.Name = Name;
    6659      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;
    8164      return claData;
    8265    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblem.cs

    r7758 r7759  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using HeuristicLab.Common;
    2623using HeuristicLab.Core;
     
    3330  [Creatable("Problems")]
    3431  public class RegressionProblem : DataAnalysisProblem<IRegressionProblemData>, IRegressionProblem, IStorableContent,
    35     IProblemInstanceConsumer<RegressionData>, IProblemInstanceExporter<RegressionData> {
     32    IProblemInstanceConsumer<RegressionProblemData>, IProblemInstanceExporter<RegressionProblemData> {
    3633    public string Filename { get; set; }
    3734
     
    4643    }
    4744
    48     public void Load(RegressionData data) {
     45    public void Load(RegressionProblemData data) {
    4946      Name = data.Name;
    5047      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;
    5753      OnReset();
    5854    }
    5955
    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);
    6558      regData.Name = Name;
    6659      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;
    8164      return regData;
    8265    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Classification/3.4/ArtificialClassificationDataDescriptor.cs

    r7685 r7759  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using HeuristicLab.Problems.DataAnalysis;
    2224
    23 using System.Collections.Generic;
    2425namespace HeuristicLab.Problems.Instances.Classification {
    2526  public abstract class ArtificialClassificationDataDescriptor : IDataDescriptor {
     
    3536    protected abstract int TestPartitionEnd { get; }
    3637
    37     public ClassificationData GenerateClassificationData() {
    38       ClassificationData claData = new ClassificationData();
     38    public ClassificationProblemData GenerateClassificationData() {
     39      Dataset dataset = new Dataset(InputVariables, this.GenerateValues());
     40
     41      ClassificationProblemData claData = new ClassificationProblemData(dataset, AllowedInputVariables, TargetVariable);
    3942      claData.Name = this.Name;
    4043      claData.Description = this.Description;
    41       claData.InputVariables = this.InputVariables;
    42       claData.AllowedInputVariables = this.AllowedInputVariables;
    43       claData.TargetVariable = this.TargetVariable;
    44       claData.Values = Transformer.Transformation(this.GenerateValues());
    45       claData.TrainingPartitionStart = this.TrainingPartitionStart;
    46       claData.TrainingPartitionEnd = this.TrainingPartitionEnd;
    47       claData.TestPartitionStart = this.TestPartitionStart;
    48       claData.TestPartitionEnd = this.TestPartitionEnd;
     44      claData.TrainingPartition.Start = this.TrainingPartitionStart;
     45      claData.TrainingPartition.End = this.TrainingPartitionEnd;
     46      claData.TestPartition.Start = this.TestPartitionStart;
     47      claData.TestPartition.End = this.TestPartitionEnd;
    4948      return claData;
    5049    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Classification/3.4/ArtificialClassificationInstanceProvider.cs

    r7685 r7759  
    2020#endregion
    2121
     22using HeuristicLab.Problems.DataAnalysis;
    2223
    2324namespace HeuristicLab.Problems.Instances.Classification {
    2425  public abstract class ArtificialClassificationInstanceProvider : ClassificationInstanceProvider {
    25     public override ClassificationData LoadData(IDataDescriptor descriptor) {
     26    public override ClassificationProblemData LoadData(IDataDescriptor descriptor) {
    2627      return ((ArtificialClassificationDataDescriptor)descriptor).GenerateClassificationData();
    2728    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Classification/3.4/ClassificationInstanceProvider.cs

    r7685 r7759  
    2626using System.Linq;
    2727using System.Text;
     28using HeuristicLab.Problems.DataAnalysis;
    2829
    2930namespace HeuristicLab.Problems.Instances.Classification {
    30   public abstract class ClassificationInstanceProvider : IProblemInstanceProvider<ClassificationData> {
    31     public ClassificationData LoadData(string path) {
     31  public abstract class ClassificationInstanceProvider : IProblemInstanceProvider<ClassificationProblemData> {
     32    public ClassificationProblemData LoadData(string path) {
    3233      TableFileParser csvFileParser = new TableFileParser();
    3334      csvFileParser.Parse(path);
    3435
    35       ClassificationData claData = new ClassificationData();
     36      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
     37      string targetVar = csvFileParser.VariableNames.Last();
     38      IEnumerable<string> allowedInputVars = csvFileParser.VariableNames.Where(x => !x.Equals(targetVar));
     39
     40      ClassificationProblemData claData = new ClassificationProblemData(dataset, allowedInputVars, targetVar);
    3641      int pos = path.LastIndexOf('\\');
    3742      if (pos < 0)
     
    4146        claData.Name = path.Substring(pos, path.Length - pos);
    4247      }
    43       claData.InputVariables = new List<string>(csvFileParser.VariableNames).ToArray();
    44       claData.TargetVariable = csvFileParser.VariableNames.Last();
    45       claData.AllowedInputVariables = claData.InputVariables.Where(x => !x.Equals(claData.TargetVariable)).ToArray();
    46       //convert to multidimensional array
    47       List<IList> values = csvFileParser.Values;
    48       claData.Values = new double[values.First().Count, values.Count];
    49       for (int i = 0; i < values.Count; i++) {
    50         for (int j = 0; j < values.First().Count; j++) {
    51           claData.Values[j, i] = (double)values[i][j];
    52         }
    53       }
    5448
    5549      int trainingPartEnd = csvFileParser.Rows * 2 / 3;
    56       claData.TrainingPartitionStart = 0;
    57       claData.TrainingPartitionEnd = trainingPartEnd;
    58       claData.TestPartitionStart = trainingPartEnd;
    59       claData.TestPartitionEnd = csvFileParser.Rows;
     50      claData.TrainingPartition.Start = 0;
     51      claData.TrainingPartition.End = trainingPartEnd;
     52      claData.TestPartition.Start = trainingPartEnd;
     53      claData.TestPartition.End = csvFileParser.Rows;
    6054      return claData;
    6155    }
    6256
    63     public void SaveData(ClassificationData instance, string path) {
     57    public void SaveData(ClassificationProblemData instance, string path) {
    6458      StringBuilder strBuilder = new StringBuilder();
    6559
     
    7064      strBuilder.AppendLine();
    7165
    72       double[,] values = instance.Values;
     66      Dataset dataset = instance.Dataset;
    7367
    74       for (int i = 0; i < values.GetLength(0); i++) {
    75         for (int j = 0; j < values.GetLength(1); j++) {
    76           strBuilder.Append(values[i, j] + ";");
     68      for (int i = 0; i < dataset.Rows; i++) {
     69        for (int j = 0; j < dataset.Columns; j++) {
     70          strBuilder.Append(dataset.GetValue(i, j) + ";");
    7771        }
    7872        strBuilder.Remove(strBuilder.Length - 1, 1);
     
    8680
    8781    public abstract IEnumerable<IDataDescriptor> GetDataDescriptors();
    88     public abstract ClassificationData LoadData(IDataDescriptor descriptor);
     82    public abstract ClassificationProblemData LoadData(IDataDescriptor descriptor);
    8983
    9084    public abstract string Name { get; }
     
    9286    public abstract Uri WebLink { get; }
    9387    public abstract string ReferencePublication { get; }
    94 
    95     public IProblemInstanceConsumer<ClassificationData> Consumer { get; set; }
    9688  }
    9789}
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Classification/3.4/HeuristicLab.Problems.Instances.Classification-3.4.csproj

    r7687 r7759  
    3838  </PropertyGroup>
    3939  <ItemGroup>
     40    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     41      <Private>False</Private>
     42    </Reference>
    4043    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4144      <Private>False</Private>
    4245    </Reference>
    4346    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     47      <Private>False</Private>
     48    </Reference>
     49    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4450      <Private>False</Private>
    4551    </Reference>
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Classification/3.4/ResourceClassificationInstanceProvider.cs

    r7758 r7759  
    2626using System.Reflection;
    2727using System.Text.RegularExpressions;
     28using HeuristicLab.Problems.DataAnalysis;
    2829using ICSharpCode.SharpZipLib.Zip;
    2930
     
    4344    }
    4445
    45     public override ClassificationData LoadData(IDataDescriptor id) {
     46    public override ClassificationProblemData LoadData(IDataDescriptor id) {
    4647      var descriptor = (ResourceClassificationDataDescriptor)id;
    4748
    48       ClassificationData claData = LoadData(GetTempFileForResource(descriptor.ResourceName));
     49      ClassificationProblemData claData = LoadData(GetTempFileForResource(descriptor.ResourceName));
    4950      claData.Name = descriptor.Name;
    5051      claData.Description = descriptor.Description;
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ArtificialRegressionDataDescriptor.cs

    r7682 r7759  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Problems.DataAnalysis;
     24
    2325namespace HeuristicLab.Problems.Instances.Regression {
    2426  public abstract class ArtificialRegressionDataDescriptor : IDataDescriptor {
     
    3436    protected abstract int TestPartitionEnd { get; }
    3537
    36     public RegressionData GenerateRegressionData() {
    37       RegressionData regData = new RegressionData();
     38    public RegressionProblemData GenerateRegressionData() {
     39      Dataset dataset = new Dataset(InputVariables, this.GenerateValues());
     40
     41      RegressionProblemData regData = new RegressionProblemData(dataset, AllowedInputVariables, TargetVariable);
    3842      regData.Name = this.Name;
    3943      regData.Description = this.Description;
    40       regData.InputVariables = this.InputVariables;
    41       regData.AllowedInputVariables = this.AllowedInputVariables;
    42       regData.TargetVariable = this.TargetVariable;
    43       regData.Values = Transformer.Transformation(this.GenerateValues());
    44       regData.TrainingPartitionStart = this.TrainingPartitionStart;
    45       regData.TrainingPartitionEnd = this.TrainingPartitionEnd;
    46       regData.TestPartitionStart = this.TestPartitionStart;
    47       regData.TestPartitionEnd = this.TestPartitionEnd;
     44      regData.TrainingPartition.Start = this.TrainingPartitionStart;
     45      regData.TrainingPartition.End = this.TrainingPartitionEnd;
     46      regData.TestPartition.Start = this.TestPartitionStart;
     47      regData.TestPartition.End = this.TestPartitionEnd;
    4848      return regData;
    4949    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ArtificialRegressionInstanceProvider.cs

    r7664 r7759  
    2020#endregion
    2121
     22using HeuristicLab.Problems.DataAnalysis;
    2223
    2324namespace HeuristicLab.Problems.Instances.Regression {
    2425  public abstract class ArtificialRegressionInstanceProvider : RegressionInstanceProvider {
    25     public override RegressionData LoadData(IDataDescriptor descriptor) {
     26    public override RegressionProblemData LoadData(IDataDescriptor descriptor) {
    2627      return ((ArtificialRegressionDataDescriptor)descriptor).GenerateRegressionData();
    2728    }
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/HeuristicLab.Problems.Instances.Regression-3.4.csproj

    r7687 r7759  
    3838  </PropertyGroup>
    3939  <ItemGroup>
     40    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     41      <Private>False</Private>
     42    </Reference>
    4043    <Reference Include="HeuristicLab.Common-3.3">
    4144      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     
    4447    <Reference Include="HeuristicLab.Core-3.3">
    4548      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     49      <Private>False</Private>
     50    </Reference>
     51    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4652      <Private>False</Private>
    4753    </Reference>
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/RealWorld/RealWorldInstanceProvider.cs

    r7758 r7759  
    3939    }
    4040
    41     protected override string FileName { get { return "RealWorld"; } }
     41    protected override string FileExtension { get { return "RealWorld"; } }
    4242  }
    4343}
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/RegressionInstanceProvider.cs

    r7682 r7759  
    2626using System.Linq;
    2727using System.Text;
     28using HeuristicLab.Problems.DataAnalysis;
    2829
    2930namespace HeuristicLab.Problems.Instances.Regression {
    30   public abstract class RegressionInstanceProvider : IProblemInstanceProvider<RegressionData> {
    31     public RegressionData LoadData(string path) {
     31  public abstract class RegressionInstanceProvider : IProblemInstanceProvider<RegressionProblemData> {
     32    public RegressionProblemData LoadData(string path) {
    3233      TableFileParser csvFileParser = new TableFileParser();
    3334      csvFileParser.Parse(path);
    3435
    35       RegressionData regData = new RegressionData();
     36      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
     37      string targetVar = csvFileParser.VariableNames.Last();
     38      IEnumerable<string> allowedInputVars = csvFileParser.VariableNames.Where(x => !x.Equals(targetVar));
     39
     40      RegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar);
    3641      int pos = path.LastIndexOf('\\');
    3742      if (pos < 0)
     
    4146        regData.Name = path.Substring(pos, path.Length - pos);
    4247      }
    43       regData.InputVariables = new List<string>(csvFileParser.VariableNames).ToArray();
    44       regData.TargetVariable = csvFileParser.VariableNames.Last();
    45       regData.AllowedInputVariables = regData.InputVariables.Where(x => !x.Equals(regData.TargetVariable)).ToArray();
    46       //convert to multidimensional array
    47       List<IList> values = csvFileParser.Values;
    48       regData.Values = new double[values.First().Count, values.Count];
    49       for (int i = 0; i < values.Count; i++) {
    50         for (int j = 0; j < values.First().Count; j++) {
    51           regData.Values[j, i] = (double)values[i][j];
    52         }
    53       }
    5448
    5549      int trainingPartEnd = csvFileParser.Rows * 2 / 3;
    56       regData.TrainingPartitionStart = 0;
    57       regData.TrainingPartitionEnd = trainingPartEnd;
    58       regData.TestPartitionStart = trainingPartEnd;
    59       regData.TestPartitionEnd = csvFileParser.Rows;
     50      regData.TrainingPartition.Start = 0;
     51      regData.TrainingPartition.End = trainingPartEnd;
     52      regData.TestPartition.Start = trainingPartEnd;
     53      regData.TestPartition.End = csvFileParser.Rows;
    6054      return regData;
    6155    }
    6256
    63     public void SaveData(RegressionData instance, string path) {
     57    public void SaveData(RegressionProblemData instance, string path) {
    6458      StringBuilder strBuilder = new StringBuilder();
    6559
     
    7064      strBuilder.AppendLine();
    7165
    72       double[,] values = instance.Values;
     66      Dataset dataset = instance.Dataset;
    7367
    74       for (int i = 0; i < values.GetLength(0); i++) {
    75         for (int j = 0; j < values.GetLength(1); j++) {
    76           strBuilder.Append(values[i, j] + ";");
     68      for (int i = 0; i < dataset.Rows; i++) {
     69        for (int j = 0; j < dataset.Columns; j++) {
     70          strBuilder.Append(dataset.GetValue(i, j) + ";");
    7771        }
    7872        strBuilder.Remove(strBuilder.Length - 1, 1);
     
    8680
    8781    public abstract IEnumerable<IDataDescriptor> GetDataDescriptors();
    88     public abstract RegressionData LoadData(IDataDescriptor descriptor);
     82    public abstract RegressionProblemData LoadData(IDataDescriptor descriptor);
    8983
    9084    public abstract string Name { get; }
     
    9286    public abstract Uri WebLink { get; }
    9387    public abstract string ReferencePublication { get; }
    94 
    95     public IProblemInstanceConsumer<RegressionData> Consumer { get; set; }
    9688  }
    9789}
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ResourceRegressionInstanceProvider.cs

    r7758 r7759  
    2626using System.Reflection;
    2727using System.Text.RegularExpressions;
     28using HeuristicLab.Problems.DataAnalysis;
    2829using ICSharpCode.SharpZipLib.Zip;
    2930
     
    3132  public abstract class ResourceRegressionInstanceProvider : RegressionInstanceProvider {
    3233
    33     protected abstract string FileName { get; }
     34    protected abstract string FileExtension { get; }
    3435
    3536    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    36       var solutionsArchiveName = GetResourceName(FileName + @"\.zip");
     37      var solutionsArchiveName = GetResourceName(FileExtension + @"\.zip");
    3738      if (!String.IsNullOrEmpty(solutionsArchiveName)) {
    3839        using (var solutionsZipFile = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) {
     
    4344    }
    4445
    45     public override RegressionData LoadData(IDataDescriptor id) {
     46    public override RegressionProblemData LoadData(IDataDescriptor id) {
    4647      var descriptor = (ResourceRegressionDataDescriptor)id;
    4748
    48       RegressionData regData = LoadData(GetTempFileForResource(descriptor.ResourceName));
     49      RegressionProblemData regData = LoadData(GetTempFileForResource(descriptor.ResourceName));
    4950      regData.Name = descriptor.Name;
    5051      regData.Description = descriptor.Description;
     
    6667
    6768    private string GetTempFileForResource(string resourceName) {
    68       var instanceArchiveName = GetResourceName(FileName + @"\.zip");
     69      var instanceArchiveName = GetResourceName(FileExtension + @"\.zip");
    6970      using (var instancesZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
    7071        var entry = instancesZipFile.GetEntry(resourceName);
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/TrentMcConaghy/TrentMcConaghyInstanceProvider.cs

    r7758 r7759  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
     25using HeuristicLab.Problems.DataAnalysis;
    2426
    2527namespace HeuristicLab.Problems.Instances.Regression {
     
    4345    }
    4446
    45     protected override string FileName { get { return "TrentMcConaghy"; } }
     47    protected override string FileExtension { get { return "TrentMcConaghy"; } }
    4648
    47     public override RegressionData LoadData(IDataDescriptor id) {
    48       RegressionData regData = base.LoadData(id);
    49 
    50       regData.TargetVariable = regData.InputVariables.First();
    51       regData.AllowedInputVariables = regData.InputVariables.Where(x => !x.Equals(regData.TargetVariable)).ToArray();
     49    public override RegressionProblemData LoadData(IDataDescriptor id) {
     50      RegressionProblemData regData = base.LoadData(id);
     51      string targetVar = regData.InputVariables.First().Value;
     52      IEnumerable<string> allowedInputVars = regData.InputVariables.Where(x => !x.Equals(regData.TargetVariable)).Select(x => x.Value);
     53      RegressionProblemData newRegData = new RegressionProblemData(regData.Dataset, allowedInputVars, targetVar);
    5254
    5355      return regData;
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ValueGenerator.cs

    r7698 r7759  
    2626using HeuristicLab.Random;
    2727namespace HeuristicLab.Problems.Instances.Regression {
    28   public class ValueGenerator {
    29     protected static FastRandom rand = new FastRandom();
     28  public static class ValueGenerator {
     29    private static FastRandom rand = new FastRandom();
    3030
    3131    public static IEnumerable<double> GenerateSteps(double start, double end, double stepWidth) {
    32       return Enumerable.Range(0, (int)Math.Round(((end - start) / stepWidth) + 1))
    33                                       .Select(i => (start + i * stepWidth));
     32      int steps = (int)Math.Round(((end - start) / stepWidth) + 1);
     33      for (int i = 0; i < steps; i++)
     34        yield return start + i * stepWidth;
    3435    }
    3536
    3637    public static IEnumerable<double> GenerateUniformDistributedValues(int amount, double start, double end) {
    37       List<double> values = new List<double>();
    38       for (int i = 0; i < amount; i++) {
    39         values.Add(rand.NextDouble() * (end - start) + start);
    40       }
    41       return values;
     38      for (int i = 0; i < amount; i++)
     39        yield return rand.NextDouble() * (end - start) + start;
    4240    }
    4341
    4442    public static IEnumerable<double> GenerateNormalDistributedValues(int amount, double mu, double sigma) {
    45       List<double> values = new List<double>();
    46       for (int i = 0; i < amount; i++) {
    47         values.Add(NormalDistributedRandom.NextDouble(rand, mu, sigma));
    48       }
    49       return values;
     43      for (int i = 0; i < amount; i++)
     44        yield return NormalDistributedRandom.NextDouble(rand, mu, sigma);
    5045    }
    5146
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj

    r7754 r7759  
    119119    <Compile Include="IProblemInstanceExporter.cs" />
    120120    <Compile Include="TableFileParser.cs" />
    121     <Compile Include="Transformer.cs" />
    122121    <Compile Include="Types\ATSPData.cs" />
    123     <Compile Include="Types\ClassificationData.cs" />
    124     <Compile Include="Types\RegressionData.cs" />
    125122    <Compile Include="Types\CTAPData.cs" />
    126123    <Compile Include="IDataDescriptor.cs" />
Note: See TracChangeset for help on using the changeset viewer.