Changeset 12977 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective
- Timestamp:
- 10/01/15 00:12:46 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionLogResidualEvaluator.cs
r12973 r12977 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 32 [Item("Log Residual Evaluator", "Evaluator for symbolic regression models that calculates the mean of logarithmic absolute residuals avg(log( 1 + abs(y' - y)))" + 32 [Item("Log Residual Evaluator", "Evaluator for symbolic regression models that calculates the mean of logarithmic absolute residuals avg(log( 1 + abs(y' - y)))" + 33 33 "This evaluator does not perform linear scaling!" + 34 34 "This evaluator can be useful if the modeled function contains discontinuities (e.g. 1/x). " + … … 57 57 IEnumerable<int> rows = GenerateRowsToEvaluate(); 58 58 59 var problemData = ProblemDataParameter.ActualValue; 60 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 61 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray(); 62 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 63 var estimationLimits = EstimationLimitsParameter.ActualValue; 64 65 if (SaveEstimatedValuesToScope) { 66 var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray(); 67 var scope = ExecutionContext.Scope; 68 if (scope.Variables.ContainsKey("EstimatedValues")) 69 scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues); 70 else 71 scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues))); 72 } 73 74 double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper); 59 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows); 75 60 QualityParameter.ActualValue = new DoubleValue(quality); 76 61 … … 81 66 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 82 67 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 83 return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit);84 }85 86 private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit) {87 68 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 88 69 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionMeanRelativeErrorEvaluator.cs
r12973 r12977 50 50 IEnumerable<int> rows = GenerateRowsToEvaluate(); 51 51 52 var problemData = ProblemDataParameter.ActualValue; 53 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 54 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray(); 55 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 56 var estimationLimits = EstimationLimitsParameter.ActualValue; 57 58 if (SaveEstimatedValuesToScope) { 59 var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray(); 60 var scope = ExecutionContext.Scope; 61 if (scope.Variables.ContainsKey("EstimatedValues")) 62 scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues); 63 else 64 scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues))); 65 } 66 67 double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper); 52 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows); 68 53 QualityParameter.ActualValue = new DoubleValue(quality); 69 54 … … 74 59 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 75 60 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 76 return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit);77 }78 79 private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit) {80 61 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 81 62 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs
r12973 r12977 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Core; … … 27 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 28 31 [StorableClass] 29 public abstract class SymbolicRegressionSingleObjectiveEvaluator : SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionSingleObjectiveEvaluator { 30 private const string SaveEstimatedValuesToScopeParameterName = "SaveEstimatedValuesToScope"; 31 32 public IFixedValueParameter<BoolValue> SaveEstimatedValuesToScopeParameter { 33 get { return (IFixedValueParameter<BoolValue>)Parameters[SaveEstimatedValuesToScopeParameterName]; } 34 } 35 36 public bool SaveEstimatedValuesToScope { get { return SaveEstimatedValuesToScopeParameter.Value.Value; } } 37 32 public abstract class SymbolicRegressionSingleObjectiveEvaluator : SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionSingleObjectiveEvaluator { 38 33 [StorableConstructor] 39 34 protected SymbolicRegressionSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { } 40 35 protected SymbolicRegressionSingleObjectiveEvaluator(SymbolicRegressionSingleObjectiveEvaluator original, Cloner cloner) : base(original, cloner) { } 41 42 protected SymbolicRegressionSingleObjectiveEvaluator() : base() { 43 Parameters.Add(new FixedValueParameter<BoolValue>(SaveEstimatedValuesToScopeParameterName, new BoolValue(false))); 44 SaveEstimatedValuesToScopeParameter.Hidden = true; 45 } 36 protected SymbolicRegressionSingleObjectiveEvaluator(): base() {} 46 37 } 47 38 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs
r12973 r12977 21 21 22 22 using System.Collections.Generic; 23 using System.Linq;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 47 46 IEnumerable<int> rows = GenerateRowsToEvaluate(); 48 47 49 var problemData = ProblemDataParameter.ActualValue; 50 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 51 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray(); 52 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 53 var estimationLimits = EstimationLimitsParameter.ActualValue; 54 55 if (SaveEstimatedValuesToScope) { 56 var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray(); 57 var scope = ExecutionContext.Scope; 58 if (scope.Variables.ContainsKey("EstimatedValues")) 59 scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues); 60 else 61 scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues))); 62 } 63 64 double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value); 48 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value); 65 49 QualityParameter.ActualValue = new DoubleValue(quality); 66 50 … … 71 55 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 72 56 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 73 return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);74 }75 76 private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {77 57 OnlineCalculatorError errorState; 78 58 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs
r12973 r12977 21 21 22 22 using System.Collections.Generic; 23 using System.Linq;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 47 46 IEnumerable<int> rows = GenerateRowsToEvaluate(); 48 47 49 var problemData = ProblemDataParameter.ActualValue; 50 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 51 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray(); 52 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 53 var estimationLimits = EstimationLimitsParameter.ActualValue; 54 55 if (SaveEstimatedValuesToScope) { 56 var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray(); 57 var scope = ExecutionContext.Scope; 58 if (scope.Variables.ContainsKey("EstimatedValues")) 59 scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues); 60 else 61 scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues))); 62 } 63 64 double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value); 48 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value); 65 49 QualityParameter.ActualValue = new DoubleValue(quality); 66 50 … … 71 55 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 72 56 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 73 return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);74 }75 76 private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {77 57 OnlineCalculatorError errorState; 78 58 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs
r12973 r12977 21 21 22 22 using System.Collections.Generic; 23 using System.Linq;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 47 46 IEnumerable<int> rows = GenerateRowsToEvaluate(); 48 47 49 var problemData = ProblemDataParameter.ActualValue; 50 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 51 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray(); 52 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 53 var estimationLimits = EstimationLimitsParameter.ActualValue; 54 55 if (SaveEstimatedValuesToScope) { 56 var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray(); 57 var scope = ExecutionContext.Scope; 58 if (scope.Variables.ContainsKey("EstimatedValues")) 59 scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues); 60 else 61 scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues))); 62 } 63 64 double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value); 48 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value); 65 49 QualityParameter.ActualValue = new DoubleValue(quality); 66 50 … … 71 55 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 72 56 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 73 return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);74 }75 76 private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {77 57 OnlineCalculatorError errorState; 78 58 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs
r12973 r12977 21 21 22 22 using System.Collections.Generic; 23 using System.Linq;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 49 48 IEnumerable<int> rows = GenerateRowsToEvaluate(); 50 49 51 var problemData = ProblemDataParameter.ActualValue; 52 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 53 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray(); 54 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 55 var estimationLimits = EstimationLimitsParameter.ActualValue; 56 57 if (SaveEstimatedValuesToScope) { 58 var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray(); 59 var scope = ExecutionContext.Scope; 60 if (scope.Variables.ContainsKey("EstimatedValues")) 61 scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues); 62 else 63 scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues))); 64 } 65 66 double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value); 50 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value); 67 51 QualityParameter.ActualValue = new DoubleValue(quality); 68 52 … … 73 57 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 74 58 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 75 return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);76 }77 78 private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {79 59 OnlineCalculatorError errorState; 80 60 … … 90 70 } 91 71 if (errorState != OnlineCalculatorError.None) return double.NaN; 92 return r *r;72 return r*r; 93 73 } 94 74
Note: See TracChangeset
for help on using the changeset viewer.