Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/28/18 17:17:31 (5 years ago)
Author:
pfleck
Message:

#2906

  • Implemented for classification, clustering, etc.
  • Simplified Transformation interfaces (read-only, ...).
  • Started moving transformation logic out of ProblemData.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r15858 r15870  
    243243
    244244    public virtual IDataAnalysisProblemData Transform() {
    245       var newDataset = Transform(Dataset, Transformations);
     245      var newDataset = DataAnalysisTransformationModel.Transform(Dataset, Transformations);
    246246
    247247      var extendedInputs = ExtendInputVariables(AllowedInputVariables, Transformations);
     
    253253      cloner.RegisterClonedObject(Dataset, newDataset);
    254254      cloner.RegisterClonedObject(InputVariables, checkedInputs.AsReadOnly());
    255       //cloner.RegisterClonedObject(TransformationsParameter.Value, new ItemList<IDataAnalysisTransformation>(transformations).AsReadOnly());
     255      // TODO: valid values for target are not extended
    256256
    257257      return cloner.Clone(this);
     
    268268      cloner.RegisterClonedObject(Dataset, newDataset);
    269269      cloner.RegisterClonedObject(InputVariables, checkedInputs.AsReadOnly());
    270       //cloner.RegisterClonedObject(TransformationsParameter.Value, new ItemList<IDataAnalysisTransformation>().AsReadOnly());
     270      // TODO: check valid target values
    271271
    272272      return cloner.Clone(this);
    273     }
    274 
    275     public static IDataset Transform(IDataset dataset, IEnumerable<IDataAnalysisTransformation> transformations) {
    276       var modifiableDataset = ((Dataset)dataset).ToModifiable();
    277 
    278       foreach (var transformation in transformations) {
    279         var trans = (ITransformation<double>)transformation.Transformation;
    280 
    281         var originalData = modifiableDataset.GetDoubleValues(transformation.OriginalVariable);
    282         if (!trans.Check(originalData, out string errorMessage))
    283           throw new InvalidOperationException($"Cannot estimate Values, Transformation is invalid: {errorMessage}");
    284 
    285         var transformedData = trans.Apply(originalData).ToList();
    286         if (modifiableDataset.VariableNames.Contains(transformation.TransformedVariable))
    287           modifiableDataset.ReplaceVariable(transformation.TransformedVariable, transformedData);
    288         else
    289           modifiableDataset.AddVariable(transformation.TransformedVariable, transformedData);
    290       }
    291 
    292       return modifiableDataset;
    293273    }
    294274
Note: See TracChangeset for help on using the changeset viewer.