- Timestamp:
- 03/27/18 15:46:12 (7 years ago)
- Location:
- branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.