Changeset 12302


Ignore:
Timestamp:
04/13/15 11:59:52 (5 years ago)
Author:
ehopf
Message:

#2361: Added a NotSupported-Exception for the case that the user activates the applyLinearScaling-option. Additionally made some execution time measurements with and without invocation of the ToArray-Extension-Method after the calculation of the bounded estimated values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveWeightedPerformanceMeasuresEvaluator.cs

    r12218 r12302  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    101102                IEnumerable<int> rows, bool applyLinearScaling, ISymbolicClassificationModelCreator modelCreator, double normalizedMeanSquaredErrorWeightingFactor, double falseNegativeRateWeightingFactor, double falsePositiveRateWeightingFactor) {
    102103      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    103       IEnumerable<double> targetClassValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    104       IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
     104      var targetClassValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows).ToArray();
     105      var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit).ToArray();
    105106      OnlineCalculatorError errorState;
    106107      double nmse;
     
    115116      var estimatedClassValues = model.GetEstimatedClassValues(boundedEstimatedValues);
    116117      performanceCalculator.Calculate(targetClassValues, estimatedClassValues);
    117       if (performanceCalculator.ErrorState != OnlineCalculatorError.None) 
     118      if (performanceCalculator.ErrorState != OnlineCalculatorError.None)
    118119        return Double.NaN;
    119120      double falseNegativeRate = 1 - performanceCalculator.TruePositiveRate;
     
    121122
    122123      if (applyLinearScaling) {
    123         var nmseCalculator = new OnlineNormalizedMeanSquaredErrorCalculator();
    124         CalculateWithScaling(targetClassValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, nmseCalculator, problemData.Dataset.Rows);
    125         errorState = nmseCalculator.ErrorState;
    126         nmse = nmseCalculator.NormalizedMeanSquaredError;
    127       } else {
    128         nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetClassValues, boundedEstimatedValues, out errorState);
     124        throw new NotSupportedException("The Weighted Performance Measures Evaluator does not suppport linear scaling!");
    129125      }
     126      nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetClassValues, boundedEstimatedValues, out errorState);
    130127      if (errorState != OnlineCalculatorError.None) return Double.NaN;
    131 
    132128      return normalizedMeanSquaredErrorWeightingFactor * nmse + falseNegativeRateWeightingFactor * falseNegativeRate + falsePositiveRateWeightingFactor * falsePositiveRate;
    133129    }
Note: See TracChangeset for help on using the changeset viewer.