Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/02/14 11:38:44 (11 years ago)
Author:
pfleck
Message:
  • Added Transformations to PreprocessingData
  • Added Transformations to DataAnalysisProblemData Parameters
  • Removed SymbolicExpressionTree as inverse transformation.
Location:
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r9456 r10695  
    291291    }
    292292
    293     public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    294       : base(dataset, allowedInputVariables) {
     293    public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null)
     294      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    295295      var validTargetVariableValues = CheckVariablesForPossibleTargetVariables(dataset).Select(x => new StringValue(x).AsReadOnly()).ToList();
    296296      var target = validTargetVariableValues.Where(x => x.Value == targetVariable).DefaultIfEmpty(validTargetVariableValues.First()).First();
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringProblemData.cs

    r9456 r10695  
    2121
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    8687    }
    8788
    88     public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables)
    89       : base(dataset, allowedInputVariables) {
     89    public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null)
     90      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    9091    }
    9192  }
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r9456 r10695  
    3737    protected const string TrainingPartitionParameterName = "TrainingPartition";
    3838    protected const string TestPartitionParameterName = "TestPartition";
     39    protected const string TransformationsParameterName = "Transformations";
    3940
    4041    #region parameter properites
     
    5051    public IFixedValueParameter<IntRange> TestPartitionParameter {
    5152      get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; }
     53    }
     54    public IFixedValueParameter<ReadOnlyItemCollection<ITransformation>> TransformationsParameter {
     55      get { return (IFixedValueParameter<ReadOnlyItemCollection<ITransformation>>)Parameters[TransformationsParameterName]; }
    5256    }
    5357    #endregion
     
    8892    }
    8993
     94    public IEnumerable<ITransformation> Transformations {
     95      get { return TransformationsParameter.Value; }
     96    }
     97
    9098    public virtual bool IsTrainingSample(int index) {
    9199      return index >= 0 && index < Dataset.Rows &&
     
    111119    private void AfterDeserialization() {
    112120      RegisterEventHandlers();
     121
     122      if (!Parameters.ContainsKey(TransformationsParameterName)) {
     123        Parameters.Add(new FixedValueParameter<ReadOnlyItemCollection<ITransformation>>(TransformationsParameterName, "", new ItemCollection<ITransformation>().AsReadOnly()));
     124      }
    113125    }
    114126
    115     protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables) {
     127    protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations) {
    116128      if (dataset == null) throw new ArgumentNullException("The dataset must not be null.");
    117129      if (allowedInputVariables == null) throw new ArgumentNullException("The allowedInputVariables must not be null.");
     
    119131      if (allowedInputVariables.Except(dataset.DoubleVariables).Any())
    120132        throw new ArgumentException("All allowed input variables must be present in the dataset and of type double.");
     133
     134      if (transformations == null) throw new ArgumentNullException("The transformations must not be null.");
    121135
    122136      var inputVariables = new CheckedItemList<StringValue>(dataset.DoubleVariables.Select(x => new StringValue(x)));
     
    129143      int testPartitionEnd = dataset.Rows;
    130144
     145      var transformationsCollection = new ItemCollection<ITransformation>(transformations);
     146
    131147      Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", dataset));
    132148      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly()));
    133149      Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd)));
    134150      Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
     151      Parameters.Add(new FixedValueParameter<ReadOnlyItemCollection<ITransformation>>(TransformationsParameterName, "", transformationsCollection.AsReadOnly()));
    135152
    136153      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r9456 r10695  
    129129    }
    130130
    131     public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    132       : base(dataset, allowedInputVariables) {
     131    public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null)
     132      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    133133      var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
    134134      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First()));
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r9456 r10695  
    3939    IEnumerable<int> TestIndices { get; }
    4040
     41    IEnumerable<ITransformation> Transformations { get; }
     42
    4143    bool IsTrainingSample(int index);
    4244    bool IsTestSample(int index);
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/ITransformation.cs

    r10694 r10695  
    2020#endregion
    2121
     22using System.Collections;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Core;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public interface ITransformation<T> : IParameterizedItem {
     27  public interface ITransformation : IParameterizedItem {
    2728    string Column { get; }
     29  }
     30
     31  public interface ITransformation<T> : ITransformation {
    2832    IEnumerable<T> Apply(IEnumerable<T> data);
    2933    IEnumerable<T> InverseApply(IEnumerable<T> data);
Note: See TracChangeset for help on using the changeset viewer.