Changeset 10694


Ignore:
Timestamp:
04/02/14 11:23:44 (6 years ago)
Author:
tsteinre
Message:
  • LinearTransformation and Transformation now uses ITransformation,
  • refactoring
Location:
branches/DataPreprocessing
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj

    r10673 r10694  
    155155      <Name>HeuristicLab.Parameters-3.3</Name>
    156156    </ProjectReference>
     157    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
     158      <Project>{102bc7d3-0ef9-439c-8f6d-96ff0fdb8e1b}</Project>
     159      <Name>HeuristicLab.Persistence-3.3</Name>
     160    </ProjectReference>
    157161    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    158162      <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project>
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/Transformations/LinearTransformation.cs

    r10671 r10694  
    2020#endregion
    2121
     22
     23using System.Collections.Generic;
    2224using System.Linq;
     25using HeuristicLab.Common;
    2326using HeuristicLab.Core;
    2427using HeuristicLab.Data;
    2528using HeuristicLab.DataPreprocessing.Transformations;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2729using HeuristicLab.Parameters;
    28 
    2930namespace HeuristicLab.DataPreprocessing.Implementations.Transformations {
    3031  [Item("LinearTransformation", "Represents a linear transformation with multiplication and addition.")]
    31   public class LinearTransformation : Transformation {
     32  public class LinearTransformation : Transformation<double> {
    3233
    3334    #region Parameters
     
    4647    }
    4748
    48     public override void Transform() {
    49       PreprocessingData.InTransaction(() => {
    50         int idx = PreprocessingData.GetColumnIndex(Column);
    51         if (PreprocessingData.IsType<double>(idx)) {
    52           var column = PreprocessingData.GetValues<double>(idx);
    53           var transformedColumn = column.Select(e => e * MultiplicandParameter.Value.Value + SummandParameter.Value.Value).ToList();
    54           PreprocessingData.SetValues<double>(idx, transformedColumn);
    55         }
    56       },
    57       DataPreprocessingChangedEventType.Transformation);
     49    public override IEnumerable<double> Apply(IEnumerable<double> data) {
     50      return data.Select(e => e * MultiplicandParameter.Value.Value + SummandParameter.Value.Value).ToList();
    5851    }
    5952
    60     public override ISymbolicExpressionTree GenerateInverseTransformation() {
     53    public override IEnumerable<double> InverseApply(IEnumerable<double> data) {
    6154      throw new System.NotImplementedException();
    6255    }
    6356
    64     public override void Check() {
     57    public override IDeepCloneable Clone(Cloner cloner) {
    6558      throw new System.NotImplementedException();
    6659    }
    6760
    68     public override Common.IDeepCloneable Clone(Common.Cloner cloner) {
     61    public override void Check(IEnumerable<double> data) {
    6962      throw new System.NotImplementedException();
    7063    }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/Transformations/Transformation.cs

    r10671 r10694  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HeuristicLab.Problems.DataAnalysis;
    2527
    2628namespace HeuristicLab.DataPreprocessing.Transformations {
    2729  [Item("Transformation", "Represents the base class for a transformation.")]
    28   public abstract class Transformation : ParameterizedNamedItem {
     30  [StorableClass]
     31  public abstract class Transformation<T> : ParameterizedNamedItem, ITransformation<T> {
     32    public string Column { get; private set; }
    2933
    30     protected new ParameterCollection Parameters {
    31       get { return base.Parameters; }
     34    [StorableConstructor]
     35    protected Transformation(bool deserializing) : base(deserializing) { }
     36    protected Transformation(Transformation<T> original, Cloner cloner)
     37      : base(original, cloner) {
     38      Column = original.Column;
    3239    }
    33 
    34     protected ITransactionalPreprocessingData PreprocessingData { get; private set; }
    35 
    36     protected string Column { get; private set; }
    37 
    38     protected Transformation() {
    39     }
    40 
    41     protected Transformation(ITransactionalPreprocessingData preprocessingData, string column) {
    42       this.PreprocessingData = preprocessingData;
     40    protected Transformation() { }
     41    protected Transformation(string column) {
    4342      this.Column = column;
    4443    }
    4544
    46     protected Transformation(Transformation original, Cloner cloner)
    47       : base(original, cloner) {
    48       PreprocessingData = (ITransactionalPreprocessingData)original.PreprocessingData.Clone();
    49       Column = original.Column;
    50     }
     45    public abstract IEnumerable<T> Apply(IEnumerable<T> data);
    5146
    52     public abstract void Transform();
     47    public abstract IEnumerable<T> InverseApply(IEnumerable<T> data);
    5348
    54     public abstract ISymbolicExpressionTree GenerateInverseTransformation();
    55 
    56     public abstract void Check();
    57 
     49    public abstract void Check(IEnumerable<T> data);
    5850  }
    5951}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Plugin.cs.frame

    r10673 r10694  
    4444  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
    4545  [PluginDependency("HeuristicLab.Parameters","3.3")]
     46  [PluginDependency("HeuristicLab.Persistence","3.3")]
    4647  public class HeuristicLabDataPreprocessingPlugin : PluginBase {
    4748  }
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/ITransformation.cs

    r10689 r10694  
    2424
    2525namespace HeuristicLab.Problems.DataAnalysis {
    26   public interface ITransformation : IParameterizedItem {
     26  public interface ITransformation<T> : IParameterizedItem {
    2727    string Column { get; }
    28     IEnumerable<T> Apply<T>(IEnumerable<T> data);
    29     IEnumerable<T> InverseApply<T>(IEnumerable<T> data);
     28    IEnumerable<T> Apply(IEnumerable<T> data);
     29    IEnumerable<T> InverseApply(IEnumerable<T> data);
    3030  }
    3131}
Note: See TracChangeset for help on using the changeset viewer.