Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/13/12 09:48:24 (12 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.