Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/27/18 15:46:12 (7 years ago)
Author:
pfleck
Message:

#2906 Added PreprocessingTransformation as a custom view-model for transformations in preprocessing.

Location:
branches/2906_Transformations
Files:
1 added
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r15847 r15865  
    202202      <DependentUpon>CheckedFilterCollectionView.cs</DependentUpon>
    203203    </Compile>
    204     <Compile Include="CheckedTransformationListView.cs">
    205       <SubType>UserControl</SubType>
    206     </Compile>
    207     <Compile Include="CheckedTransformationListView.Designer.cs">
    208       <DependentUpon>CheckedTransformationListView.cs</DependentUpon>
     204    <Compile Include="TransformationListView.cs">
     205      <SubType>UserControl</SubType>
     206    </Compile>
     207    <Compile Include="TransformationListView.Designer.cs">
     208      <DependentUpon>TransformationListView.cs</DependentUpon>
    209209    </Compile>
    210210    <Compile Include="ComparisonFilterView.cs">
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationListView.Designer.cs

    r15864 r15865  
    2121
    2222namespace HeuristicLab.DataPreprocessing.Views {
    23   partial class CheckedTransformationListView {
     23  partial class TransformationListView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationListView.cs

    r15864 r15865  
    2020#endregion
    2121
     22using System;
     23using System.Drawing;
    2224using System.Linq;
    2325using System.Windows.Forms;
     26using HeuristicLab.Collections;
    2427using HeuristicLab.Core;
    2528using HeuristicLab.Core.Views;
    2629using HeuristicLab.Data;
    2730using HeuristicLab.MainForm;
    28 using HeuristicLab.Problems.DataAnalysis;
    2931
    3032namespace HeuristicLab.DataPreprocessing.Views {
    31   [View("CheckedTransformationList View")]
    32   [Content(typeof(ICheckedItemList<IDataAnalysisTransformation>), false)]
    33   public partial class CheckedTransformationListView : CheckedItemListView<IDataAnalysisTransformation> {
     33  [View("TransformationList View")]
     34  [Content(typeof(IItemList<PreprocessingTransformation>), false)]
     35  public partial class TransformationListView : ItemListView<PreprocessingTransformation> {
    3436
    3537    internal IFilteredPreprocessingData PreprocessingData { get; set; }
    3638
    37     public CheckedTransformationListView() {
     39    public TransformationListView() {
    3840      InitializeComponent();
    3941      itemsGroupBox.Text = "Transformations";
    4042    }
    4143
    42     protected override IDataAnalysisTransformation CreateItem() {
    43       var newTransformation = new DataAnalysisTransformation(PreprocessingData.VariableNames.Select(x => new StringValue(x)));
     44    protected override PreprocessingTransformation CreateItem() {
     45      var variableNames = PreprocessingData.VariableNames.Select(x => new StringValue(x))
     46        .Concat(Content.Select(x => new StringValue(x.TransformedVariable))).Distinct();
     47
     48      var newTransformation = new PreprocessingTransformation(variableNames);
    4449      newTransformation.TransformedVariableParameter.ValidValues.Add(new StringValue("<New Variable>"));
    4550      return newTransformation;
    46       //if (typeSelectorDialog == null) {
    47       //  typeSelectorDialog = new TypeSelectorDialog();
    48       //  typeSelectorDialog.Caption = "Select Transformation";
    49       //  typeSelectorDialog.TypeSelector.Caption = "Available Transformations";
    50       //  typeSelectorDialog.TypeSelector.Configure(typeof(IDataAnalysisTransformation), showNotInstantiableTypes: true, showGenericTypes: false, typeCondition: CanInstanciateTransformation);
    51       //}
    52 
    53       //if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    54       //  try {
    55       //    // TODO: Avoid accessing parent view
    56       //    var transformationView = (TransformationView)Parent;
    57       //    var columnNames = transformationView.Content.PreprocessingData.VariableNames;
    58 
    59       //    return (IDataAnalysisTransformation)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(new[] { columnNames });
    60       //  } catch (Exception ex) {
    61       //    ErrorHandling.ShowErrorDialog(this, ex);
    62       //  }
    63       //}
    64       //return null;
    6551    }
    6652
    67     //private bool CanInstanciateTransformation(Type type) {
    68     //  foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.Instance)) {
    69     //    ParameterInfo[] parameters = ctor.GetParameters();
    70     //    if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IEnumerable<string>)) return true;
    71     //  }
    72     //  return false;
    73     //}
     53    protected override void OnContentChanged() {
     54      base.OnContentChanged();
     55
     56      if (Content == null) return;
     57
     58      int i = 0;
     59      foreach (ListViewItem item in ItemsListView.Items) {
     60        var transformation = PreprocessingData.Transformations[i];
     61
     62        item.ForeColor = transformation.IsApplied ? Color.Black : Color.Gray;
     63        i++;
     64      }
     65      UpdateButtonsState();
     66    }
     67
     68    protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<PreprocessingTransformation>> e) {
     69      base.Content_ItemsAdded(sender, e);
     70
     71      foreach (var transformation in e.Items) {
     72        UpdateListViewItemsColor(transformation.Value);
     73      }
     74    }
     75
     76    protected override void RegisterItemEvents(PreprocessingTransformation item) {
     77      base.RegisterItemEvents(item);
     78      item.PropertyChanged += Item_PropertyChanged;
     79    }
     80    protected override void DeregisterItemEvents(PreprocessingTransformation item) {
     81      item.PropertyChanged -= Item_PropertyChanged;
     82      base.DeregisterItemEvents(item);
     83    }
     84
     85    private void Item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
     86      if (sender is PreprocessingTransformation transformation)
     87        UpdateListViewItemsColor(transformation);
     88    }
     89
     90    protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
     91      base.itemsListView_SelectedIndexChanged(sender, e);
     92
     93      UpdateButtonsState();
     94    }
     95
     96    private void UpdateListViewItemsColor(PreprocessingTransformation transformation) {
     97      foreach (ListViewItem item in itemListViewItemMapping[transformation]) {
     98        item.ForeColor = transformation.IsApplied ? Color.Black : Color.Gray;
     99      }
     100    }
     101
     102    private void UpdateButtonsState() {
     103      if (itemsListView.SelectedItems.Count != 1) return;
     104      int selectedIndex = itemsListView.SelectedIndices[0];
     105
     106      // TODO: do not move/remove already applied transformations
     107      // TODO: general disalow of movement?
     108      if (Content[selectedIndex].IsApplied) {
     109        moveUpButton.Enabled = selectedIndex > 0 && Content[selectedIndex - 1].IsApplied;
     110        moveDownButton.Enabled = false;
     111        removeButton.Enabled = false;
     112      }
     113    }
    74114  }
    75115}
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.Designer.cs

    r15846 r15865  
    4747      this.applyButton = new System.Windows.Forms.Button();
    4848      this.lblFilterNotice = new System.Windows.Forms.Label();
    49       this.transformationListView = new HeuristicLab.DataPreprocessing.Views.CheckedTransformationListView();
     49      this.transformationListView = new HeuristicLab.DataPreprocessing.Views.TransformationListView();
    5050      this.SuspendLayout();
    5151      //
     
    100100
    101101    #endregion
    102     private CheckedTransformationListView transformationListView;
     102    private TransformationListView transformationListView;
    103103    private System.Windows.Forms.Button applyButton;
    104104    private System.Windows.Forms.Label lblFilterNotice;
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.cs

    r15856 r15865  
    4343      if (Content == null) {
    4444        transformationListView.Content = null;
     45        transformationListView.PreprocessingData = null;
    4546      } else {
    46         transformationListView.Content = Content.CheckedTransformationList;
     47        transformationListView.Content = Content.TransformationList;
    4748        transformationListView.PreprocessingData = Content.PreprocessingData;
    4849        CheckFilters();
     
    7879
    7980      if (success) {
    80         //Content.CheckedTransformationList.Clear();
     81        //Content.TransformationList.Clear();
    8182        MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
    8283      } else {
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Content/TransformationContent.cs

    r15846 r15865  
    2929
    3030namespace HeuristicLab.DataPreprocessing {
     31
    3132  [Item("Transformation", "Represents the transformation grid.")]
    3233  [StorableClass]
     
    3738
    3839    [Storable]
    39     public ICheckedItemList<IDataAnalysisTransformation> CheckedTransformationList { get; private set; }
     40    public IItemList<PreprocessingTransformation> TransformationList { get; private set; }
    4041
    4142    #region Constructor, Cloning & Persistence
    4243    public TransformationContent(IFilteredPreprocessingData preprocessingData)
    4344      : base(preprocessingData) {
    44       CheckedTransformationList = new CheckedItemList<IDataAnalysisTransformation>();
     45      TransformationList = new ItemList<PreprocessingTransformation>();
    4546    }
    4647
    4748    public TransformationContent(TransformationContent original, Cloner cloner)
    4849      : base(original, cloner) {
    49       CheckedTransformationList = cloner.Clone(original.CheckedTransformationList);
     50      TransformationList = cloner.Clone(original.TransformationList);
    5051    }
    5152    public override IDeepCloneable Clone(Cloner cloner) {
     
    5960
    6061    public bool ApplyTransformations(out IEnumerable<string> errorMessages) {
    61       var transformations = CheckedTransformationList.CheckedItems.Select(x => x.Value);
    62 
    6362      bool success = true;
    6463      var errors = new List<string>();
    6564      errorMessages = errors;
    6665
    67       foreach (var transformation in transformations) {
     66      foreach (var transformation in TransformationList.Where(x => !x.IsApplied)) {
    6867        var sourceVariable = transformation.OriginalVariable;
    6968        var targetVariable = transformation.TransformedVariable ?? sourceVariable + " Transformed";
     
    8685
    8786          PreprocessingData.Transformations.Add(transformation);
    88           CheckedTransformationList.SetItemCheckedState(transformation, false);
     87          transformation.IsApplied = true;
     88          // TODO: remove unused valid values in constrainedParameters
    8989        } else {
    9090          success = false;
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs

    r15846 r15865  
    204204
    205205    #region Transformations
    206     public IList<IDataAnalysisTransformation> Transformations {
     206    public IList<PreprocessingTransformation> Transformations {
    207207      get { return originalData.Transformations; }
    208208    }
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs

    r15846 r15865  
    7878
    7979    #region Transformations
    80     IList<IDataAnalysisTransformation> Transformations { get; }
     80    IList<PreprocessingTransformation> Transformations { get; }
    8181    #endregion
    8282
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs

    r15846 r15865  
    4747      Name = "Preprocessing Data";
    4848
    49       Transformations = new List<IDataAnalysisTransformation>();
     49      Transformations = new List<PreprocessingTransformation>();
    5050      selection = new Dictionary<int, IList<int>>();
    5151
     
    6161      TrainingPartition = (IntRange)original.TrainingPartition.Clone(cloner);
    6262      TestPartition = (IntRange)original.TestPartition.Clone(cloner);
    63       Transformations = new List<IDataAnalysisTransformation>(original.Transformations.Select(cloner.Clone));
     63      Transformations = new List<PreprocessingTransformation>(original.Transformations.Select(cloner.Clone));
    6464
    6565      InputVariables = new List<string>(original.InputVariables);
     
    350350    #region Transformations
    351351    [Storable]
    352     public IList<IDataAnalysisTransformation> Transformations { get; protected set; }
     352    public IList<PreprocessingTransformation> Transformations { get; protected set; }
    353353    #endregion
    354354
     
    414414      }
    415415
     416      // TODO: set fixed constrained (allowed) values
     417      foreach (var trans in problemData.Transformations) {
     418        var newTrans = new PreprocessingTransformation(variableNames.Select(x => new StringValue(x))) {
     419          OriginalVariable = trans.OriginalVariable,
     420          TransformedVariable = trans.TransformedVariable,
     421          IsApplied = true
     422        };
     423        var cloned = (ITransformation)trans.Transformation.Clone();
     424        newTrans.TransformationParameter.ValidValues.Add(cloned);
     425        newTrans.Transformation = cloned;
     426        Transformations.Add(newTrans);
     427      }
     428
    416429      TrainingPartition = new IntRange(problemData.TrainingPartition.Start, problemData.TrainingPartition.End);
    417430      TestPartition = new IntRange(problemData.TestPartition.Start, problemData.TestPartition.End);
     
    459472      public IntRange TrainingPartition { get; set; }
    460473      public IntRange TestPartition { get; set; }
    461       public IList<IDataAnalysisTransformation> Transformations { get; set; }
     474      public IList<PreprocessingTransformation> Transformations { get; set; }
    462475      public DataPreprocessingChangedEventType ChangedType { get; set; }
    463476
     
    487500        TrainingPartition = new IntRange(TrainingPartition.Start, TrainingPartition.End),
    488501        TestPartition = new IntRange(TestPartition.Start, TestPartition.End),
    489         Transformations = new List<IDataAnalysisTransformation>(Transformations),
     502        Transformations = new List<PreprocessingTransformation>(Transformations),
    490503        ChangedType = changedType,
    491504        ChangedColumn = column,
     
    682695      l = 0;
    683696      ir = n - 1;
    684       for (;;) {
     697      for (; ; ) {
    685698        if (ir <= l + 1) {
    686699          // Active partition contains 1 or 2 elements.
     
    707720          j = ir;
    708721          a = arr[l + 1]; // Partitioning element.
    709           for (;;) { // Beginning of innermost loop.
     722          for (; ; ) { // Beginning of innermost loop.
    710723            do i++; while (arr[i].CompareTo(a) < 0); // Scan up to find element > a.
    711724            do j--; while (arr[j].CompareTo(a) > 0); // Scan down to find element < a.
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj

    r15846 r15865  
    107107      <Private>False</Private>
    108108    </Reference>
     109    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     110      <SpecificVersion>False</SpecificVersion>
     111      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     112    </Reference>
    109113    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    110114      <SpecificVersion>False</SpecificVersion>
     
    134138    <Compile Include="Content\MultiScatterPlotContent.cs" />
    135139    <Compile Include="Content\PreprocessingContent.cs" />
     140    <Compile Include="Data\PreprocessingTransformation.cs" />
    136141    <Compile Include="Content\SingleScatterPlotContent.cs" />
    137142    <Compile Include="Content\ScatterPlotContent.cs" />
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r15856 r15865  
    3434    }
    3535
    36     private IList<IDataAnalysisTransformation> Transformations {
     36    private IList<PreprocessingTransformation> Transformations {
    3737      get { return context.Data.Transformations; }
    3838    }
     
    7676        targetVariable = context.Data.VariableNames.First();
    7777      var inputVariables = GetDoubleInputVariables(targetVariable);
    78       var newProblemData = new TimeSeriesPrognosisProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {
     78      var newProblemData = new TimeSeriesPrognosisProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation()) {
    7979        TrainingHorizon = oldProblemData.TrainingHorizon,
    8080        TestHorizon = oldProblemData.TestHorizon
     
    8585    private IDataAnalysisProblemData CreateRegressionData(RegressionProblemData oldProblemData) {
    8686      // TODO: transformations (additional inputs, target changed)
    87       var targetVariable = RegressionProblemData.GetTransformedTragetVariable(oldProblemData.TargetVariable, Transformations);
     87      var targetVariable = RegressionProblemData.GetTransformedTragetVariable(oldProblemData.TargetVariable, CreateDataAnalysisTransformation());
    8888      if (!context.Data.VariableNames.Contains(targetVariable))
    8989        targetVariable = context.Data.VariableNames.First();
    9090      var inputVariables = GetDoubleInputVariables(targetVariable);
    91       var newProblemData = new RegressionProblemData(ExportedDataset, inputVariables, targetVariable, Transformations);
     91      var newProblemData = new RegressionProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation());
    9292      return newProblemData;
    9393    }
     
    9898        targetVariable = context.Data.VariableNames.First();
    9999      var inputVariables = GetDoubleInputVariables(targetVariable);
    100       var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {
     100      var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation()) {
    101101        PositiveClass = oldProblemData.PositiveClass
    102102      };
     
    105105
    106106    private IDataAnalysisProblemData CreateClusteringData(ClusteringProblemData oldProblemData) {
    107       return new ClusteringProblemData(ExportedDataset, GetDoubleInputVariables(String.Empty), Transformations);
     107      return new ClusteringProblemData(ExportedDataset, GetDoubleInputVariables(String.Empty), CreateDataAnalysisTransformation());
    108108    }
    109109
     
    117117    }
    118118
    119      void SetAllowedInputVariables(IDataAnalysisProblemData problemData, IEnumerable<string> oldInputVariables) {
    120        var inputs = DataAnalysisProblemData.ExtendInputVariables(oldInputVariables, Transformations);
     119    void SetAllowedInputVariables(IDataAnalysisProblemData problemData, IEnumerable<string> oldInputVariables) {
     120      var inputs = DataAnalysisProblemData.ExtendInputVariables(oldInputVariables, problemData.Transformations);
    121121
    122122      foreach (var input in problemData.InputVariables) {
     
    142142      return context.Data.TrainingPartition.End - context.Data.TrainingPartition.Start > 1 || list.Range() > 0;
    143143    }
     144
     145    private IEnumerable<IDataAnalysisTransformation> CreateDataAnalysisTransformation() {
     146      return Transformations.Select(x => new DataAnalysisTransformation(x.OriginalVariable, x.TransformedVariable, (ITransformation)x.Transformation.Clone()));
     147    }
    144148  }
    145149}
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisTransformation.cs

    r15858 r15865  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Runtime.CompilerServices;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    3431  [StorableClass]
    3532  public class DataAnalysisTransformation : ParameterizedNamedItem, IDataAnalysisTransformation {
    36     #region Parameters
    37     public IConstrainedValueParameter<StringValue> OriginalVariableParameter {
    38       get { return (IConstrainedValueParameter<StringValue>)Parameters["Original Variable"]; }
     33    #region Parameter Properties
     34    private IFixedValueParameter<StringValue> OriginalVariableParameter {
     35      get { return (IFixedValueParameter<StringValue>)Parameters["Original Variable"]; }
    3936    }
    4037
    41     public IConstrainedValueParameter<StringValue> TransformedVariableParameter {
    42       get { return (IConstrainedValueParameter<StringValue>)Parameters["Transformed Variable"]; }
     38    private IFixedValueParameter<StringValue> TransformedVariableParameter {
     39      get { return (IFixedValueParameter<StringValue>)Parameters["Transformed Variable"]; }
    4340    }
    4441
    45     public IValueParameter<ITransformation> TransformationParameter {
     42    private IValueParameter<ITransformation> TransformationParameter {
    4643      get { return (IValueParameter<ITransformation>)Parameters["Transformation"]; }
    4744    }
     
    5148    public string OriginalVariable {
    5249      get { return OriginalVariableParameter.Value.Value; }
    53       set { SetConstrainedValue(OriginalVariableParameter, value); }
     50      set { OriginalVariableParameter.Value.Value = value; }
    5451    }
    5552
    5653    public string TransformedVariable {
    5754      get { return TransformedVariableParameter.Value.Value; }
    58       set { SetConstrainedValue(TransformedVariableParameter, value); }
     55      set { TransformedVariableParameter.Value.Value = value; }
    5956    }
    6057
     
    6360      set { TransformationParameter.Value = value; }
    6461    }
    65 
    66     private static void SetConstrainedValue(IConstrainedValueParameter<StringValue> parameter, string value, [CallerMemberName] string caller = null) {
    67       if (value == null) throw new ArgumentNullException(caller);
    68       if (value == parameter.Value.Value) return;
    69 
    70       var matchingValue = parameter.ValidValues.SingleOrDefault(v => v.Value == value);
    71       if (matchingValue == null) throw new ArgumentException("The provided value is not valid.", caller);
    72       parameter.Value = matchingValue;
    73     }
    7462    #endregion
    7563
    7664    #region Constructor, Cloning & Persistence
    77     public DataAnalysisTransformation(IEnumerable<StringValue> variableNames)
     65    public DataAnalysisTransformation()
     66      : this("", "", new IdentityTransformation()) {
     67    }
     68    public DataAnalysisTransformation(string originalVariable, string transformedVariable, ITransformation transformation)
    7869      : base() {
    79       var originalVariables = new ItemSet<StringValue>(variableNames.Select(x => x.AsReadOnly()));
    80       var transformedVariables = new ItemSet<StringValue>(variableNames.Select(x => x.AsReadOnly()));
    81       Parameters.Add(new ConstrainedValueParameter<StringValue>("Original Variable", new ItemSet<StringValue>(originalVariables), originalVariables.FirstOrDefault()));
    82       Parameters.Add(new ConstrainedValueParameter<StringValue>("Transformed Variable", new ItemSet<StringValue>(transformedVariables), transformedVariables.FirstOrDefault()));
    83 
    84       //var transformations = new ItemSet<ITransformation>(ApplicationManager.Manager.GetInstances<ITransformation>());
    85       Parameters.Add(new ValueParameter<ITransformation>("Transformation", new IdentityTransformation()));
     70      Parameters.Add(new FixedValueParameter<StringValue>("Original Variable", new StringValue(originalVariable)));
     71      Parameters.Add(new FixedValueParameter<StringValue>("Transformed Variable", new StringValue(transformedVariable)));
     72      Parameters.Add(new ValueParameter<ITransformation>("Transformation", transformation));
    8673
    8774      RegisterEventHandlers();
     
    10996    #region Event-Handling
    11097    private void RegisterEventHandlers() {
    111       OriginalVariableParameter.ValueChanged += OriginalVariableParameter_ValueChanged;
    112       TransformedVariableParameter.ValueChanged += TransformedVariableParameter_ValueChanged;
     98      OriginalVariableParameter.Value.ValueChanged += OriginalVariableParameterValue_ValueChanged;
     99      TransformedVariableParameter.Value.ValueChanged += TransformedVariableParameterValue_ValueChanged;
    113100      TransformationParameter.ValueChanged += TransformationParameter_ValueChanged;
    114101    }
    115102
    116     private void OriginalVariableParameter_ValueChanged(object sender, EventArgs e) {
    117       OriginalVariableParameter.Value.ValueChanged += OriginalVariableParameterValue_ValueChanged;
    118       OnToStringChanged();
    119     }
    120103    private void OriginalVariableParameterValue_ValueChanged(object sender, EventArgs e) {
    121       OnToStringChanged();
    122     }
    123 
    124     private void TransformedVariableParameter_ValueChanged(object sender, EventArgs e) {
    125       TransformedVariableParameter.Value.ValueChanged += TransformedVariableParameterValue_ValueChanged;
    126104      OnToStringChanged();
    127105    }
     
    129107      OnToStringChanged();
    130108    }
    131 
    132109    private void TransformationParameter_ValueChanged(object sender, EventArgs e) {
    133110      OnToStringChanged();
    134111    }
    135112    #endregion
    136 
    137113
    138114    public override string ToString() {
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ExponentialTransformation.cs

    r15847 r15865  
    4949    public ExponentialTransformation()
    5050      : base() {
    51       Parameters.Add(new FixedValueParameter<DoubleValue>("Base", "Base the logarithm", new DoubleValue(Math.E)));
     51      Parameters.Add(new FixedValueParameter<DoubleValue>("Base", "", new DoubleValue(Math.E)));
    5252    }
    5353
     
    6565    #endregion
    6666
    67     public override bool Check(IEnumerable<double> data, out string errorMessage) {
    68       if (data.Any(x => x <= 0)) {
    69         errorMessage = "Log is not available for zero or negative values";
    70         return false;
    71       }
    72       return base.Check(data, out errorMessage);
    73     }
    74 
    7567    public override IEnumerable<double> Apply(IEnumerable<double> data) {
    7668      return Apply(data, Base);
     
    8072      return InverseApply(data, Base);
    8173    }
     74
    8275
    8376    public static IEnumerable<double> Apply(IEnumerable<double> data, double @base = Math.E) {
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs

    r15847 r15865  
    4646    public double Slope {
    4747      get { return SlopeParameter.Value.Value; }
    48       set { SlopeParameter.Value.Value = value; }
     48      set { SlopeParameter.Value.Value = value; } //TODO: check for != 0?
    4949    }
    5050
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmTransformation.cs

    r15846 r15865  
    8181    }
    8282
     83
    8384    public static IEnumerable<double> Apply(IEnumerable<double> data, double @base = Math.E) {
    8485      return data.Select(x => Math.Log(x, @base));
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ZNormalizationTransformation.cs

    r15846 r15865  
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis {
    31   [Item("Z-Score Normalization", "Z-Score normalization transformation to standardize (target_mu = 0, target_sigma = 1) the values")]
     31  [Item("Z-Score Normalization", "Z-Score normalization transformation to standardize the values to a Target Mean and Target Standard Deviation.")]
    3232  [StorableClass]
    3333  public class ZNormalizationTransformation : Transformation<double> {
     
    5858    public double OriginalMean {
    5959      get { return OriginalMeanParameter.Value.Value; }
    60       set { OriginalMeanParameter.Value.Value = value; }
     60      private set { OriginalMeanParameter.Value.Value = value; }
    6161    }
    6262    public double OriginalStandardDeviation {
    6363      get { return OriginalStandardDeviationParameter.Value.Value; }
    64       set { OriginalStandardDeviationParameter.Value.Value = value; }
     64      private set { OriginalStandardDeviationParameter.Value.Value = value; }
    6565    }
    6666    #endregion
     
    103103
    104104    public override IEnumerable<double> Apply(IEnumerable<double> data) {
    105       if (double.IsNaN(OriginalMean) || double.IsNaN(OriginalStandardDeviation))
     105      if (double.IsNaN(OriginalMean) || double.IsNaN(OriginalStandardDeviation)) //TODO isConfigured field?
    106106        Configure(data);
    107107
     
    112112      return InverseApply(data, TargetMean, TargetStandardDeviation, OriginalMean, OriginalStandardDeviation);
    113113    }
     114
    114115
    115116    public static IEnumerable<double> Apply(IEnumerable<double> data, double targetMean, double targetStandardDeviation, double originalMean = double.NaN, double originalStandardDeviation = double.NaN) {
Note: See TracChangeset for help on using the changeset viewer.