Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5846


Ignore:
Timestamp:
03/28/11 17:27:00 (14 years ago)
Author:
gkronber
Message:

#1453: changed *RSquaredEvaluators to return 0.0 (worst possible value) if the result returned by the OnlinePearsonsRSquaredEvaluator is double.NaN

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5809 r5846  
    3434      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    3535      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    36       try {
    37         double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues);
    38         return new double[2] { r2, solution.Length };
    39       }
    40       catch (ArgumentException) {
    41         // if R² cannot be calcualted because of infinity or NaN values => return worst possible fitness value
    42         return new double[2] { 0.0, solution.Length };
    43       }
     36      double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues);
     37      return new double[] { double.IsNaN(r2) ? 0.0 : r2, solution.Length };
    4438    }
    4539
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectivePearsonRSquaredEvaluator.cs

    r5823 r5846  
    5555      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    57       try {
    58         return OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues);
    59       }
    60       catch (ArgumentException) {
    61         // if R² cannot be calculated because of NaN or ininity elements => return worst possible fitness value
    62         return 0.0;
    63       }
     57      double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues);
     58      return double.IsNaN(r2) ? 0.0 : r2;
    6459    }
    6560
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5809 r5846  
    5555      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    57       try {
    58         double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues);
    59         return new double[2] { r2, solution.Length };
    60       }
    61       catch (ArgumentException) {
    62         // if R² cannot be calcualted return worst possible fitness value
    63         return new double[2] { 0.0, solution.Length };
    64       }
     57      double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues);
     58      return new double[] { double.IsNaN(r2) ? 0.0 : r2, solution.Length };
    6559    }
    6660
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r5823 r5846  
    5555      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    57       try {
    58         return OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues);
    59       }
    60       catch (ArgumentException) {
    61         // if R² cannot be calculated because of NaN or ininity elements => return worst possible fitness value
    62         return 0.0;
    63       }
     57      double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues);
     58      return double.IsNaN(r2) ? 0.0 : r2;
    6459    }
    6560
Note: See TracChangeset for help on using the changeset viewer.