Ignore:
Timestamp:
12/20/19 14:00:09 (21 months ago)
Author:
djoedick
Message:

#3044: Added transformation of input variables to problem data and created scaled dataset.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3044_variableScaling/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r17388 r17391  
    170170    private void RegisterParameterEvents() {
    171171      TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged);
     172      ScaleInputsParameter.Value.ValueChanged += new EventHandler(ScaleInputsParameter_ValueChanged);
    172173    }
    173174    private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) {
    174175      OnChanged();
    175176    }
     177
     178    private void ScaleInputsParameter_ValueChanged(object sender, EventArgs e) {
     179      var transformations = new ShiftStandardDistributionTransformation(Dataset.DoubleVariables);
     180      transformations.Mean = 0;
     181      transformations.StandardDeviation = 1;
     182      var scaling = Transformation.CreateTransformations(transformations, Dataset, TrainingIndices, AllowedInputVariables);
     183
     184      var scaledVariables = AllowedInputVariables.Select((var, i) => new { Variable = var, Data = scaling[i].Apply(Dataset.GetDoubleValues(var)).ToArray() });
     185      var newDataset = ((Dataset)Dataset).ToModifiable();
     186
     187      foreach (var v in scaledVariables) {
     188        newDataset.ReplaceVariable(v.Variable, v.Data);
     189      }
     190
     191      if (!Parameters.ContainsKey("Scaled Dataset"))
     192        Parameters.Add(new FixedValueParameter<Dataset>("Scaled Dataset", newDataset.ToDataset()));
     193    }
    176194  }
    177195}
Note: See TracChangeset for help on using the changeset viewer.