Changeset 15880


Ignore:
Timestamp:
03/30/18 15:49:51 (3 years ago)
Author:
pfleck
Message:

#2906 forgot to commit file

Location:
branches/2906_Transformations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r15870 r15880  
    118118
    119119    void SetAllowedInputVariables(IDataAnalysisProblemData problemData, IEnumerable<string> oldInputVariables) {
    120       var inputs = DataAnalysisProblemData.ExtendInputVariables(oldInputVariables, problemData.Transformations);
     120      var inputs = DataAnalysisTransformationModel.ExtendInputVariables(oldInputVariables, problemData.Transformations);
    121121
    122122      foreach (var input in problemData.InputVariables) {
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisTransformationModel.cs

    r15870 r15880  
    8080    #endregion
    8181
     82    // extended -> include originals
    8283    public static ISet<string> CalculateTransitiveVariables(IEnumerable<string> inputVariables, IEnumerable<IDataAnalysisTransformation> transformations) {
    8384      var transitiveInputs = new HashSet<string>(inputVariables);
     
    9091
    9192      return transitiveInputs;
     93    }
     94    // originals => include extended
     95    public static IEnumerable<string> ExtendInputVariables(IEnumerable<string> oldInputVariables, IEnumerable<IDataAnalysisTransformation> transformations) {
     96      var inputs = new HashSet<string>(oldInputVariables);
     97
     98      foreach (var transformation in transformations) {
     99        if (inputs.Contains(transformation.OriginalVariable))
     100          inputs.Add(transformation.TransformedVariable);
     101      }
     102
     103      return inputs;
     104    }
     105    [Obsolete]
     106    public static IEnumerable<string> RemoveVirtualVariables(IEnumerable<string> variables, IEnumerable<IDataAnalysisTransformation> transformations) {
     107      var remainingVariables = new HashSet<string>(variables);
     108
     109      var transformationsStack = new Stack<IDataAnalysisTransformation>(transformations);
     110
     111      while (transformationsStack.Any()) {
     112        var transformation = transformationsStack.Pop();
     113
     114
     115        bool transformedVariablePending = transformationsStack.Any(x => x.OriginalVariable == transformation.TransformedVariable);
     116        if (!transformedVariablePending)
     117          remainingVariables.Remove(transformation.TransformedVariable);
     118      }
     119
     120      return remainingVariables;
    92121    }
    93122
     
    112141    }
    113142
    114 
    115 
    116143    #region Events
    117144    public event EventHandler TargetVariableChanged;
     
    122149    }
    123150    #endregion
    124 
    125 
    126 
    127 
    128 
    129 
    130     /*
    131     // dataset in original data range
    132     public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    133       var transformedDataset = Transform(dataset, Transformations);
    134 
    135       var estimates = OriginalModel.GetEstimatedValues(transformedDataset, rows);
    136 
    137       return InverseTransform(estimates, Transformations, OriginalModel.TargetVariable);
    138     }
    139 
    140     // problemData in original data range
    141     public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    142       // TODO: specialized views for the original solution type are lost (RandomForestSolutionView, ...)
    143       return new RegressionSolution(this, new RegressionProblemData(problemData));
    144     } */
    145151  }
    146152}
Note: See TracChangeset for help on using the changeset viewer.