Changeset 17391
- Timestamp:
- 12/20/19 14:00:09 (5 years ago)
- Location:
- branches/3044_variableScaling/HeuristicLab.Problems.DataAnalysis/3.4/Implementation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3044_variableScaling/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r17388 r17391 170 170 private void RegisterParameterEvents() { 171 171 TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged); 172 ScaleInputsParameter.Value.ValueChanged += new EventHandler(ScaleInputsParameter_ValueChanged); 172 173 } 173 174 private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) { 174 175 OnChanged(); 175 176 } 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 } 176 194 } 177 195 } -
branches/3044_variableScaling/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftStandardDistributionTransformation.cs
r16565 r17391 45 45 public double Mean { 46 46 get { return MeanParameter.Value.Value; } 47 set { MeanParameter.Value.Value = value; } 47 48 } 48 49 public double StandardDeviation { 49 50 get { return StandardDeviationParameter.Value.Value; } 51 set { StandardDeviationParameter.Value.Value = value; } 50 52 } 51 53 #endregion -
branches/3044_variableScaling/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/Transformation.cs
r17390 r17391 74 74 /// <param name="allowedInputVariables"></param> 75 75 /// <returns></returns> 76 public static ITransformation<double>[] CreateTransformations(ITransformation<double> transformation, IDataset dataset, int[] rows, IReadOnlyCollection<string> allowedInputVariables) {77 var trans = new ITransformation<double>[allowedInputVariables.Count ];76 public static ITransformation<double>[] CreateTransformations(ITransformation<double> transformation, IDataset dataset, IEnumerable<int> rows, IEnumerable<string> allowedInputVariables) { 77 var trans = new ITransformation<double>[allowedInputVariables.Count()]; 78 78 int i = 0; 79 79 foreach (var variable in allowedInputVariables) {
Note: See TracChangeset
for help on using the changeset viewer.