Changeset 8639


Ignore:
Timestamp:
09/13/12 09:48:24 (10 years ago)
Author:
mkommend
Message:

#1951: Changed symbolic regression evaluator and scale method in the symbolic regression model to ignore invalid (NaN & infinite) values during calculation of the scaling parameters.

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r8139 r8639  
    5050
    5151    protected override void UpdateModel(ISymbolicExpressionTree tree) {
    52       var model = new SymbolicRegressionModel(tree, Content.Model.Interpreter);
     52      var model = new SymbolicRegressionModel(tree, Content.Model.Interpreter, Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit);
    5353      SymbolicRegressionModel.Scale(model, Content.ProblemData);
    5454      Content.Model = model;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs

    r8635 r8639  
    7878        double estimated = estimatedValuesEnumerator.Current;
    7979        cache[i] = estimated;
    80         linearScalingCalculator.Add(estimated, target);
     80        if (!double.IsNaN(estimated) && !double.IsInfinity(estimated))
     81          linearScalingCalculator.Add(estimated, target);
    8182        i++;
    8283      }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs

    r8528 r8639  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Common;
     
    7677      var estimatedValues = model.Interpreter.GetSymbolicExpressionTreeValues(model.SymbolicExpressionTree, dataset, rows);
    7778      var targetValues = dataset.GetDoubleValues(targetVariable, rows);
    78       double alpha;
    79       double beta;
    80       OnlineCalculatorError errorState;
    81       OnlineLinearScalingParameterCalculator.Calculate(estimatedValues, targetValues, out alpha, out beta, out errorState);
    82       if (errorState != OnlineCalculatorError.None) return;
     79
     80      var linearScalingCalculator = new OnlineLinearScalingParameterCalculator();
     81      var targetValuesEnumerator = targetValues.GetEnumerator();
     82      var estimatedValuesEnumerator = estimatedValues.GetEnumerator();
     83      while (targetValuesEnumerator.MoveNext() & estimatedValuesEnumerator.MoveNext()) {
     84        double target = targetValuesEnumerator.Current;
     85        double estimated = estimatedValuesEnumerator.Current;
     86        if (!double.IsNaN(estimated) && !double.IsInfinity(estimated))
     87          linearScalingCalculator.Add(estimated, target);
     88      }
     89      if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None && (targetValuesEnumerator.MoveNext() || estimatedValuesEnumerator.MoveNext()))
     90        throw new ArgumentException("Number of elements in target and estimated values enumeration do not match.");
     91
     92      double alpha = linearScalingCalculator.Alpha;
     93      double beta = linearScalingCalculator.Beta;
     94      if (linearScalingCalculator.ErrorState != OnlineCalculatorError.None) return;
    8395
    8496      ConstantTreeNode alphaTreeNode = null;
Note: See TracChangeset for help on using the changeset viewer.