Changeset 15865 for branches/2906_Transformations
- Timestamp:
- 03/27/18 15:46:12 (7 years ago)
- 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 202 202 <DependentUpon>CheckedFilterCollectionView.cs</DependentUpon> 203 203 </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> 209 209 </Compile> 210 210 <Compile Include="ComparisonFilterView.cs"> -
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationListView.Designer.cs
r15864 r15865 21 21 22 22 namespace HeuristicLab.DataPreprocessing.Views { 23 partial class CheckedTransformationListView {23 partial class TransformationListView { 24 24 /// <summary> 25 25 /// Required designer variable. -
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationListView.cs
r15864 r15865 20 20 #endregion 21 21 22 using System; 23 using System.Drawing; 22 24 using System.Linq; 23 25 using System.Windows.Forms; 26 using HeuristicLab.Collections; 24 27 using HeuristicLab.Core; 25 28 using HeuristicLab.Core.Views; 26 29 using HeuristicLab.Data; 27 30 using HeuristicLab.MainForm; 28 using HeuristicLab.Problems.DataAnalysis;29 31 30 32 namespace HeuristicLab.DataPreprocessing.Views { 31 [View(" CheckedTransformationList View")]32 [Content(typeof(I CheckedItemList<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> { 34 36 35 37 internal IFilteredPreprocessingData PreprocessingData { get; set; } 36 38 37 public CheckedTransformationListView() {39 public TransformationListView() { 38 40 InitializeComponent(); 39 41 itemsGroupBox.Text = "Transformations"; 40 42 } 41 43 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); 44 49 newTransformation.TransformedVariableParameter.ValidValues.Add(new StringValue("<New Variable>")); 45 50 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 view56 // 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;65 51 } 66 52 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 } 74 114 } 75 115 } -
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.Designer.cs
r15846 r15865 47 47 this.applyButton = new System.Windows.Forms.Button(); 48 48 this.lblFilterNotice = new System.Windows.Forms.Label(); 49 this.transformationListView = new HeuristicLab.DataPreprocessing.Views. CheckedTransformationListView();49 this.transformationListView = new HeuristicLab.DataPreprocessing.Views.TransformationListView(); 50 50 this.SuspendLayout(); 51 51 // … … 100 100 101 101 #endregion 102 private CheckedTransformationListView transformationListView;102 private TransformationListView transformationListView; 103 103 private System.Windows.Forms.Button applyButton; 104 104 private System.Windows.Forms.Label lblFilterNotice; -
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.cs
r15856 r15865 43 43 if (Content == null) { 44 44 transformationListView.Content = null; 45 transformationListView.PreprocessingData = null; 45 46 } else { 46 transformationListView.Content = Content. CheckedTransformationList;47 transformationListView.Content = Content.TransformationList; 47 48 transformationListView.PreprocessingData = Content.PreprocessingData; 48 49 CheckFilters(); … … 78 79 79 80 if (success) { 80 //Content. CheckedTransformationList.Clear();81 //Content.TransformationList.Clear(); 81 82 MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); 82 83 } else { -
branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Content/TransformationContent.cs
r15846 r15865 29 29 30 30 namespace HeuristicLab.DataPreprocessing { 31 31 32 [Item("Transformation", "Represents the transformation grid.")] 32 33 [StorableClass] … … 37 38 38 39 [Storable] 39 public I CheckedItemList<IDataAnalysisTransformation> CheckedTransformationList { get; private set; }40 public IItemList<PreprocessingTransformation> TransformationList { get; private set; } 40 41 41 42 #region Constructor, Cloning & Persistence 42 43 public TransformationContent(IFilteredPreprocessingData preprocessingData) 43 44 : base(preprocessingData) { 44 CheckedTransformationList = new CheckedItemList<IDataAnalysisTransformation>();45 TransformationList = new ItemList<PreprocessingTransformation>(); 45 46 } 46 47 47 48 public TransformationContent(TransformationContent original, Cloner cloner) 48 49 : base(original, cloner) { 49 CheckedTransformationList = cloner.Clone(original.CheckedTransformationList);50 TransformationList = cloner.Clone(original.TransformationList); 50 51 } 51 52 public override IDeepCloneable Clone(Cloner cloner) { … … 59 60 60 61 public bool ApplyTransformations(out IEnumerable<string> errorMessages) { 61 var transformations = CheckedTransformationList.CheckedItems.Select(x => x.Value);62 63 62 bool success = true; 64 63 var errors = new List<string>(); 65 64 errorMessages = errors; 66 65 67 foreach (var transformation in transformations) {66 foreach (var transformation in TransformationList.Where(x => !x.IsApplied)) { 68 67 var sourceVariable = transformation.OriginalVariable; 69 68 var targetVariable = transformation.TransformedVariable ?? sourceVariable + " Transformed"; … … 86 85 87 86 PreprocessingData.Transformations.Add(transformation); 88 CheckedTransformationList.SetItemCheckedState(transformation, false); 87 transformation.IsApplied = true; 88 // TODO: remove unused valid values in constrainedParameters 89 89 } else { 90 90 success = false; -
branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs
r15846 r15865 204 204 205 205 #region Transformations 206 public IList< IDataAnalysisTransformation> Transformations {206 public IList<PreprocessingTransformation> Transformations { 207 207 get { return originalData.Transformations; } 208 208 } -
branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs
r15846 r15865 78 78 79 79 #region Transformations 80 IList< IDataAnalysisTransformation> Transformations { get; }80 IList<PreprocessingTransformation> Transformations { get; } 81 81 #endregion 82 82 -
branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs
r15846 r15865 47 47 Name = "Preprocessing Data"; 48 48 49 Transformations = new List< IDataAnalysisTransformation>();49 Transformations = new List<PreprocessingTransformation>(); 50 50 selection = new Dictionary<int, IList<int>>(); 51 51 … … 61 61 TrainingPartition = (IntRange)original.TrainingPartition.Clone(cloner); 62 62 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)); 64 64 65 65 InputVariables = new List<string>(original.InputVariables); … … 350 350 #region Transformations 351 351 [Storable] 352 public IList< IDataAnalysisTransformation> Transformations { get; protected set; }352 public IList<PreprocessingTransformation> Transformations { get; protected set; } 353 353 #endregion 354 354 … … 414 414 } 415 415 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 416 429 TrainingPartition = new IntRange(problemData.TrainingPartition.Start, problemData.TrainingPartition.End); 417 430 TestPartition = new IntRange(problemData.TestPartition.Start, problemData.TestPartition.End); … … 459 472 public IntRange TrainingPartition { get; set; } 460 473 public IntRange TestPartition { get; set; } 461 public IList< IDataAnalysisTransformation> Transformations { get; set; }474 public IList<PreprocessingTransformation> Transformations { get; set; } 462 475 public DataPreprocessingChangedEventType ChangedType { get; set; } 463 476 … … 487 500 TrainingPartition = new IntRange(TrainingPartition.Start, TrainingPartition.End), 488 501 TestPartition = new IntRange(TestPartition.Start, TestPartition.End), 489 Transformations = new List< IDataAnalysisTransformation>(Transformations),502 Transformations = new List<PreprocessingTransformation>(Transformations), 490 503 ChangedType = changedType, 491 504 ChangedColumn = column, … … 682 695 l = 0; 683 696 ir = n - 1; 684 for (; ;) {697 for (; ; ) { 685 698 if (ir <= l + 1) { 686 699 // Active partition contains 1 or 2 elements. … … 707 720 j = ir; 708 721 a = arr[l + 1]; // Partitioning element. 709 for (; ;) { // Beginning of innermost loop.722 for (; ; ) { // Beginning of innermost loop. 710 723 do i++; while (arr[i].CompareTo(a) < 0); // Scan up to find element > a. 711 724 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 107 107 <Private>False</Private> 108 108 </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> 109 113 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 110 114 <SpecificVersion>False</SpecificVersion> … … 134 138 <Compile Include="Content\MultiScatterPlotContent.cs" /> 135 139 <Compile Include="Content\PreprocessingContent.cs" /> 140 <Compile Include="Data\PreprocessingTransformation.cs" /> 136 141 <Compile Include="Content\SingleScatterPlotContent.cs" /> 137 142 <Compile Include="Content\ScatterPlotContent.cs" /> -
branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs
r15856 r15865 34 34 } 35 35 36 private IList< IDataAnalysisTransformation> Transformations {36 private IList<PreprocessingTransformation> Transformations { 37 37 get { return context.Data.Transformations; } 38 38 } … … 76 76 targetVariable = context.Data.VariableNames.First(); 77 77 var inputVariables = GetDoubleInputVariables(targetVariable); 78 var newProblemData = new TimeSeriesPrognosisProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {78 var newProblemData = new TimeSeriesPrognosisProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation()) { 79 79 TrainingHorizon = oldProblemData.TrainingHorizon, 80 80 TestHorizon = oldProblemData.TestHorizon … … 85 85 private IDataAnalysisProblemData CreateRegressionData(RegressionProblemData oldProblemData) { 86 86 // TODO: transformations (additional inputs, target changed) 87 var targetVariable = RegressionProblemData.GetTransformedTragetVariable(oldProblemData.TargetVariable, Transformations);87 var targetVariable = RegressionProblemData.GetTransformedTragetVariable(oldProblemData.TargetVariable, CreateDataAnalysisTransformation()); 88 88 if (!context.Data.VariableNames.Contains(targetVariable)) 89 89 targetVariable = context.Data.VariableNames.First(); 90 90 var inputVariables = GetDoubleInputVariables(targetVariable); 91 var newProblemData = new RegressionProblemData(ExportedDataset, inputVariables, targetVariable, Transformations);91 var newProblemData = new RegressionProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation()); 92 92 return newProblemData; 93 93 } … … 98 98 targetVariable = context.Data.VariableNames.First(); 99 99 var inputVariables = GetDoubleInputVariables(targetVariable); 100 var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {100 var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation()) { 101 101 PositiveClass = oldProblemData.PositiveClass 102 102 }; … … 105 105 106 106 private IDataAnalysisProblemData CreateClusteringData(ClusteringProblemData oldProblemData) { 107 return new ClusteringProblemData(ExportedDataset, GetDoubleInputVariables(String.Empty), Transformations);107 return new ClusteringProblemData(ExportedDataset, GetDoubleInputVariables(String.Empty), CreateDataAnalysisTransformation()); 108 108 } 109 109 … … 117 117 } 118 118 119 120 var inputs = DataAnalysisProblemData.ExtendInputVariables(oldInputVariables,Transformations);119 void SetAllowedInputVariables(IDataAnalysisProblemData problemData, IEnumerable<string> oldInputVariables) { 120 var inputs = DataAnalysisProblemData.ExtendInputVariables(oldInputVariables, problemData.Transformations); 121 121 122 122 foreach (var input in problemData.InputVariables) { … … 142 142 return context.Data.TrainingPartition.End - context.Data.TrainingPartition.Start > 1 || list.Range() > 0; 143 143 } 144 145 private IEnumerable<IDataAnalysisTransformation> CreateDataAnalysisTransformation() { 146 return Transformations.Select(x => new DataAnalysisTransformation(x.OriginalVariable, x.TransformedVariable, (ITransformation)x.Transformation.Clone())); 147 } 144 148 } 145 149 } -
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisTransformation.cs
r15858 r15865 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Linq;25 using System.Runtime.CompilerServices;26 23 using HeuristicLab.Common; 27 24 using HeuristicLab.Core; … … 34 31 [StorableClass] 35 32 public class DataAnalysisTransformation : ParameterizedNamedItem, IDataAnalysisTransformation { 36 #region Parameter s37 p ublic IConstrainedValueParameter<StringValue> OriginalVariableParameter {38 get { return (I ConstrainedValueParameter<StringValue>)Parameters["Original Variable"]; }33 #region Parameter Properties 34 private IFixedValueParameter<StringValue> OriginalVariableParameter { 35 get { return (IFixedValueParameter<StringValue>)Parameters["Original Variable"]; } 39 36 } 40 37 41 p ublic IConstrainedValueParameter<StringValue> TransformedVariableParameter {42 get { return (I ConstrainedValueParameter<StringValue>)Parameters["Transformed Variable"]; }38 private IFixedValueParameter<StringValue> TransformedVariableParameter { 39 get { return (IFixedValueParameter<StringValue>)Parameters["Transformed Variable"]; } 43 40 } 44 41 45 p ublicIValueParameter<ITransformation> TransformationParameter {42 private IValueParameter<ITransformation> TransformationParameter { 46 43 get { return (IValueParameter<ITransformation>)Parameters["Transformation"]; } 47 44 } … … 51 48 public string OriginalVariable { 52 49 get { return OriginalVariableParameter.Value.Value; } 53 set { SetConstrainedValue(OriginalVariableParameter, value); }50 set { OriginalVariableParameter.Value.Value = value; } 54 51 } 55 52 56 53 public string TransformedVariable { 57 54 get { return TransformedVariableParameter.Value.Value; } 58 set { SetConstrainedValue(TransformedVariableParameter, value); }55 set { TransformedVariableParameter.Value.Value = value; } 59 56 } 60 57 … … 63 60 set { TransformationParameter.Value = value; } 64 61 } 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 }74 62 #endregion 75 63 76 64 #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) 78 69 : 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)); 86 73 87 74 RegisterEventHandlers(); … … 109 96 #region Event-Handling 110 97 private void RegisterEventHandlers() { 111 OriginalVariableParameter.Value Changed += OriginalVariableParameter_ValueChanged;112 TransformedVariableParameter.Value Changed += TransformedVariableParameter_ValueChanged;98 OriginalVariableParameter.Value.ValueChanged += OriginalVariableParameterValue_ValueChanged; 99 TransformedVariableParameter.Value.ValueChanged += TransformedVariableParameterValue_ValueChanged; 113 100 TransformationParameter.ValueChanged += TransformationParameter_ValueChanged; 114 101 } 115 102 116 private void OriginalVariableParameter_ValueChanged(object sender, EventArgs e) {117 OriginalVariableParameter.Value.ValueChanged += OriginalVariableParameterValue_ValueChanged;118 OnToStringChanged();119 }120 103 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;126 104 OnToStringChanged(); 127 105 } … … 129 107 OnToStringChanged(); 130 108 } 131 132 109 private void TransformationParameter_ValueChanged(object sender, EventArgs e) { 133 110 OnToStringChanged(); 134 111 } 135 112 #endregion 136 137 113 138 114 public override string ToString() { -
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ExponentialTransformation.cs
r15847 r15865 49 49 public ExponentialTransformation() 50 50 : 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))); 52 52 } 53 53 … … 65 65 #endregion 66 66 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 75 67 public override IEnumerable<double> Apply(IEnumerable<double> data) { 76 68 return Apply(data, Base); … … 80 72 return InverseApply(data, Base); 81 73 } 74 82 75 83 76 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 46 46 public double Slope { 47 47 get { return SlopeParameter.Value.Value; } 48 set { SlopeParameter.Value.Value = value; } 48 set { SlopeParameter.Value.Value = value; } //TODO: check for != 0? 49 49 } 50 50 -
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmTransformation.cs
r15846 r15865 81 81 } 82 82 83 83 84 public static IEnumerable<double> Apply(IEnumerable<double> data, double @base = Math.E) { 84 85 return data.Select(x => Math.Log(x, @base)); -
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ZNormalizationTransformation.cs
r15846 r15865 29 29 30 30 namespace 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.")] 32 32 [StorableClass] 33 33 public class ZNormalizationTransformation : Transformation<double> { … … 58 58 public double OriginalMean { 59 59 get { return OriginalMeanParameter.Value.Value; } 60 set { OriginalMeanParameter.Value.Value = value; }60 private set { OriginalMeanParameter.Value.Value = value; } 61 61 } 62 62 public double OriginalStandardDeviation { 63 63 get { return OriginalStandardDeviationParameter.Value.Value; } 64 set { OriginalStandardDeviationParameter.Value.Value = value; }64 private set { OriginalStandardDeviationParameter.Value.Value = value; } 65 65 } 66 66 #endregion … … 103 103 104 104 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? 106 106 Configure(data); 107 107 … … 112 112 return InverseApply(data, TargetMean, TargetStandardDeviation, OriginalMean, OriginalStandardDeviation); 113 113 } 114 114 115 115 116 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.