Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10994 for branches


Ignore:
Timestamp:
06/11/14 15:15:54 (10 years ago)
Author:
tsteinre
Message:
  • Partition Ranges are not computed anymore: save the concrete values in PreprocessingData.
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs

    r10992 r10994  
    3535  public abstract class PreprocessingData : NamedItem, IPreprocessingData {
    3636
    37     protected double trainingToTestRatio;
    38     public IntRange TrainingPartition {
    39       get { return new IntRange(0, (int)(Rows * trainingToTestRatio)); }
    40     }
    41     public IntRange TestPartition {
    42       get { return new IntRange((int)(Rows * trainingToTestRatio), Rows); }
    43     }
     37    public IntRange TrainingPartition { get; set; }
     38    public IntRange TestPartition { get; set; }
    4439
    4540    protected IList<ITransformation> transformations;
     
    8681      variableValues = CopyVariableValues(original.variableValues);
    8782      variableNames = new List<string>(original.variableNames);
    88       trainingToTestRatio = original.trainingToTestRatio;
     83      TrainingPartition = (IntRange)original.TrainingPartition.Clone(cloner);
     84      TestPartition = (IntRange)original.TestPartition.Clone(cloner);
    8985      transformations = new List<ITransformation>();
     86
     87      RegisterEventHandler();
    9088    }
    9189
     
    114112      }
    115113
    116       trainingToTestRatio = (double)problemData.TrainingPartition.Size / Math.Max(problemData.Dataset.Rows, double.Epsilon);
     114      TrainingPartition = new IntRange(problemData.TrainingPartition.Start, problemData.TrainingPartition.End);
     115      TestPartition = new IntRange(problemData.TestPartition.Start, problemData.TestPartition.End);
     116     
     117      RegisterEventHandler();
     118    }
     119
     120    private void RegisterEventHandler() {
     121      Changed += (s, e) => {
     122        switch (e.Type) {
     123          case DataPreprocessingChangedEventType.DeleteRow:
     124            CheckPartitionRanges();
     125            break;
     126          case DataPreprocessingChangedEventType.Any:
     127            CheckPartitionRanges();
     128            break;
     129          case DataPreprocessingChangedEventType.Transformation:
     130            CheckPartitionRanges();
     131            break;
     132        }
     133      };
    117134    }
    118135
     
    125142    }
    126143
     144    private void CheckPartitionRanges() {
     145      int maxRowIndex = Math.Max(0, Rows - 1);
     146      TrainingPartition.Start = Math.Min(TrainingPartition.Start, maxRowIndex);
     147      TrainingPartition.End = Math.Min(TrainingPartition.End, maxRowIndex);
     148      TestPartition.Start = Math.Min(TestPartition.Start, maxRowIndex);
     149      TestPartition.End = Math.Min(TestPartition.End, maxRowIndex);
     150    }
     151
    127152    protected IList<IList> CopyVariableValues(IList<IList> original) {
    128153      var copy = new List<IList>(original);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/TransactionalPreprocessingData.cs

    r10991 r10994  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2728using HeuristicLab.Problems.DataAnalysis;
    2829using HeuristicLab.Problems.DataAnalysis.Transformations;
     
    3738      public IList<string> VariableNames { get; set; }
    3839
    39       public double TrainingToTestRatio { get; set; }
     40      public IntRange TrainingPartition { get; set; }
     41      public IntRange TestPartition { get; set; }
    4042      public IList<ITransformation> Transformations { get; set; }
    4143      public DataPreprocessingChangedEventType ChangedType { get; set; }
     
    6668        VariableValues = CopyVariableValues(variableValues),
    6769        VariableNames = new List<string>(variableNames),
    68         TrainingToTestRatio = trainingToTestRatio,
     70        TrainingPartition = new IntRange(TrainingPartition.Start, TrainingPartition.End),
     71        TestPartition = new IntRange(TestPartition.Start, TestPartition.End),
    6972        Transformations = new List<ITransformation>(transformations),
    7073        ChangedType = changedType,
     
    235238        variableValues = previousSnapshot.VariableValues;
    236239        variableNames = previousSnapshot.VariableNames;
    237         trainingToTestRatio = previousSnapshot.TrainingToTestRatio;
     240        TrainingPartition = previousSnapshot.TrainingPartition;
     241        TestPartition = previousSnapshot.TestPartition;
    238242        transformations = previousSnapshot.Transformations;
    239243        undoHistory.Remove(previousSnapshot);
Note: See TracChangeset for help on using the changeset viewer.