Changeset 13310 for stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective
- Timestamp:
- 11/19/15 19:39:07 (9 years ago)
- Location:
- stable
- Files:
-
- 7 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13241,13300,13307
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression merged eligible /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 merged eligible /branches/Benchmarking/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 6917-7005 /branches/Benchmarking/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 6917-7005 /branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 4656-4721 /branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5471-5473 /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5471-5473 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5815-6180 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5815-6180 /branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 10750-13239 /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 4458-4459,4462,4464 /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 10085-11101 /branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 10085-11101 /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 6284-6795 /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5060 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5060 /branches/HLScript/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 10331-10358 /branches/HLScript/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 10331-10358 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 11570-12508 /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 11130-12721 /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 8388-8942 /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 8388-8942 /branches/LogResidualEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 10202-10483 /branches/LogResidualEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 10202-10483 /branches/NET40/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5138-5162 /branches/NET40/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5138-5162 /branches/ParallelEngine/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5175-5192 /branches/ParallelEngine/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 7748-7810 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 7748-7810 /branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 6350-6627 /branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 6828 /branches/Restructure trunk solution/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 6828 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 10204-10479 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5370-5682 /branches/SuccessProgressAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5370-5682 /branches/SymbolicExpressionTreeDiversityAnalyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 12029-12100 /branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 12336-12421 /branches/Trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 6829-6865 /branches/Trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 6829-6865 /branches/VNS/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5594-5752 /branches/VNS/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5594-5752 /branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression 5959-6341 /branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs
r13241 r13310 44 44 public PearsonRSquaredNestedTreeSizeEvaluator() : base() { } 45 45 46 public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } 46 public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } // maximize R² & minimize nested tree size 47 47 48 48 public override IOperation InstrumentedApply() { … … 67 67 if (decimalPlaces >= 0) 68 68 r2 = Math.Round(r2, decimalPlaces); 69 return new double[2] { r2, solution.IterateNodesPostfix().Sum(n => n.GetLength()) }; 69 return new double[2] { r2, solution.IterateNodesPostfix().Sum(n => n.GetLength()) }; // sum of the length of the whole sub-tree for each node 70 70 } 71 71 … … 74 74 EstimationLimitsParameter.ExecutionContext = context; 75 75 ApplyLinearScalingParameter.ExecutionContext = context; 76 // DecimalPlaces parameter is a FixedValueParameter and doesn't need the context. 76 77 77 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); 78 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); 78 79 79 80 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs
r13241 r13310 44 44 public PearsonRSquaredNumberOfVariablesEvaluator() : base() { } 45 45 46 public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } 46 public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } // maximize R² and minimize the number of variables 47 47 48 48 public override IOperation InstrumentedApply() { … … 66 66 if (decimalPlaces >= 0) 67 67 r2 = Math.Round(r2, decimalPlaces); 68 return new double[2] { r2, solution.IterateNodesPostfix().OfType<VariableTreeNode>().Count() }; 68 return new double[2] { r2, solution.IterateNodesPostfix().OfType<VariableTreeNode>().Count() }; // count the number of variables 69 69 } 70 70 … … 73 73 EstimationLimitsParameter.ExecutionContext = context; 74 74 ApplyLinearScalingParameter.ExecutionContext = context; 75 // DecimalPlaces parameter is a FixedValueParameter and doesn't need the context. 75 76 76 77 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs
r13241 r13310 43 43 public PearsonRSquaredTreeComplexityEvaluator() : base() { } 44 44 45 public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } 45 public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } // maximize R² and minimize model complexity 46 46 47 47 public override IOperation InstrumentedApply() { … … 72 72 EstimationLimitsParameter.ExecutionContext = context; 73 73 ApplyLinearScalingParameter.ExecutionContext = context; 74 // DecimalPlaces parameter is a FixedValueParameter and doesn't need the context. 74 75 75 76 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveEvaluator.cs
r12009 r13310 22 22 23 23 using HeuristicLab.Common; 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 26 using HeuristicLab.Parameters; 24 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 25 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 30 [StorableClass] 26 31 public abstract class SymbolicRegressionMultiObjectiveEvaluator : SymbolicDataAnalysisMultiObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionMultiObjectiveEvaluator { 32 private const string DecimalPlacesParameterName = "Decimal Places"; 33 private const string UseConstantOptimizationParameterName = "Use constant optimization"; 34 private const string ConstantOptimizationIterationsParameterName = "Constant optimization iterations"; 35 36 public IFixedValueParameter<IntValue> DecimalPlacesParameter { 37 get { return (IFixedValueParameter<IntValue>)Parameters[DecimalPlacesParameterName]; } 38 } 39 public IFixedValueParameter<BoolValue> UseConstantOptimizationParameter { 40 get { return (IFixedValueParameter<BoolValue>)Parameters[UseConstantOptimizationParameterName]; } 41 } 42 43 public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter { 44 get { return (IFixedValueParameter<IntValue>)Parameters[ConstantOptimizationIterationsParameterName]; } 45 } 46 47 48 public int DecimalPlaces { 49 get { return DecimalPlacesParameter.Value.Value; } 50 set { DecimalPlacesParameter.Value.Value = value; } 51 } 52 public bool UseConstantOptimization { 53 get { return UseConstantOptimizationParameter.Value.Value; } 54 set { UseConstantOptimizationParameter.Value.Value = value; } 55 } 56 public int ConstantOptimizationIterations { 57 get { return ConstantOptimizationIterationsParameter.Value.Value; } 58 set { ConstantOptimizationIterationsParameter.Value.Value = value; } 59 } 60 27 61 [StorableConstructor] 28 62 protected SymbolicRegressionMultiObjectiveEvaluator(bool deserializing) : base(deserializing) { } … … 31 65 } 32 66 33 protected SymbolicRegressionMultiObjectiveEvaluator() : base() { } 67 protected SymbolicRegressionMultiObjectiveEvaluator() 68 : base() { 69 Parameters.Add(new FixedValueParameter<IntValue>(DecimalPlacesParameterName, "The number of decimal places used for rounding the quality values.", new IntValue(5)) { Hidden = true }); 70 Parameters.Add(new FixedValueParameter<BoolValue>(UseConstantOptimizationParameterName, "", new BoolValue(false))); 71 Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, "The number of iterations constant optimization should be applied.", new IntValue(5))); 72 } 73 74 [StorableHook(HookType.AfterDeserialization)] 75 private void AfterDeserialization() { 76 if (!Parameters.ContainsKey(UseConstantOptimizationParameterName)) { 77 Parameters.Add(new FixedValueParameter<BoolValue>(UseConstantOptimizationParameterName, "", new BoolValue(false))); 78 } 79 if (!Parameters.ContainsKey(DecimalPlacesParameterName)) { 80 Parameters.Add(new FixedValueParameter<IntValue>(DecimalPlacesParameterName, "The number of decimal places used for rounding the quality values.", new IntValue(-1)) { Hidden = true }); 81 } 82 if (!Parameters.ContainsKey(ConstantOptimizationIterationsParameterName)) { 83 Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, "The number of iterations constant optimization should be applied.", new IntValue(5))); 84 } 85 } 34 86 } 35 87 } -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs
r12009 r13310 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; … … 47 48 IEnumerable<int> rows = GenerateRowsToEvaluate(); 48 49 var solution = SymbolicExpressionTreeParameter.ActualValue; 49 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value); 50 var problemData = ProblemDataParameter.ActualValue; 51 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 52 var estimationLimits = EstimationLimitsParameter.ActualValue; 53 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 54 55 if (UseConstantOptimization) { 56 SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, estimationLimits.Upper, estimationLimits.Lower); 57 } 58 59 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); 50 60 QualitiesParameter.ActualValue = new DoubleArray(qualities); 51 61 return base.InstrumentedApply(); 52 62 } 53 63 54 public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) { 55 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 56 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 57 OnlineCalculatorError errorState; 64 public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) { 65 var mse = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, 66 upperEstimationLimit, problemData, rows, applyLinearScaling); 58 67 59 double mse; 60 if (applyLinearScaling) { 61 var mseCalculator = new OnlineMeanSquaredErrorCalculator(); 62 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, mseCalculator, problemData.Dataset.Rows); 63 errorState = mseCalculator.ErrorState; 64 mse = mseCalculator.MeanSquaredError; 65 } else { 66 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 67 mse = OnlineMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 68 } 69 if (errorState != OnlineCalculatorError.None) mse = double.NaN; 68 if (decimalPlaces >= 0) 69 mse = Math.Round(mse, decimalPlaces); 70 70 71 return new double[2] { mse, solution.Length }; 71 72 } … … 76 77 ApplyLinearScalingParameter.ExecutionContext = context; 77 78 78 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value );79 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); 79 80 80 81 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
r12669 r13310 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; … … 47 48 IEnumerable<int> rows = GenerateRowsToEvaluate(); 48 49 var solution = SymbolicExpressionTreeParameter.ActualValue; 49 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value); 50 var problemData = ProblemDataParameter.ActualValue; 51 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 52 var estimationLimits = EstimationLimitsParameter.ActualValue; 53 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 54 55 if (UseConstantOptimization) { 56 SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, estimationLimits.Upper, estimationLimits.Lower); 57 } 58 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); 50 59 QualitiesParameter.ActualValue = new DoubleArray(qualities); 51 60 return base.InstrumentedApply(); 52 61 } 53 62 54 public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) { 55 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 56 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 57 OnlineCalculatorError errorState; 58 59 double r; 60 if (applyLinearScaling) { 61 var rCalculator = new OnlinePearsonsRCalculator(); 62 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, rCalculator, problemData.Dataset.Rows); 63 errorState = rCalculator.ErrorState; 64 r = rCalculator.R; 65 } else { 66 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 67 r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 68 } 69 70 if (errorState != OnlineCalculatorError.None) r = double.NaN; 71 return new double[2] { r*r, solution.Length }; 63 public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) { 64 double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling); 65 if (decimalPlaces >= 0) 66 r2 = Math.Round(r2, decimalPlaces); 67 return new double[2] { r2, solution.Length }; 72 68 } 73 69 … … 77 73 ApplyLinearScalingParameter.ExecutionContext = context; 78 74 79 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value );75 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); 80 76 81 77 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer.cs
r12009 r13310 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 24 using HeuristicLab.Analysis; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 24 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 using HeuristicLab.Optimization; 25 30 using HeuristicLab.Parameters; 26 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 37 42 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 38 43 private const string EstimationLimitsParameterName = "EstimationLimits"; 44 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; 45 private const string ValidationPartitionParameterName = "ValidationPartition"; 46 39 47 #region parameter properties 40 48 public ILookupParameter<IRegressionProblemData> ProblemDataParameter { … … 47 55 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 48 56 } 57 public ILookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter { 58 get { return (ILookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; } 59 } 60 61 public IValueLookupParameter<IntRange> ValidationPartitionParameter { 62 get { return (IValueLookupParameter<IntRange>)Parameters[ValidationPartitionParameterName]; } 63 } 49 64 #endregion 50 65 … … 54 69 public SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer() 55 70 : base() { 56 Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.")); 57 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 58 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model.")); 71 Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.") { Hidden = true }); 72 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.") { Hidden = true }); 73 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model.") { Hidden = true }); 74 Parameters.Add(new LookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "Maximal length of the symbolic expression.") { Hidden = true }); 75 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition.")); 76 } 77 78 [StorableHook(HookType.AfterDeserialization)] 79 private void AfterDeserialization() { 80 if (!Parameters.ContainsKey(MaximumSymbolicExpressionTreeLengthParameterName)) 81 Parameters.Add(new LookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "Maximal length of the symbolic expression.") { Hidden = true }); 82 if (!Parameters.ContainsKey(ValidationPartitionParameterName)) 83 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition.")); 59 84 } 60 85 … … 68 93 return new SymbolicRegressionSolution(model, (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone()); 69 94 } 95 96 public override IOperation Apply() { 97 var operation = base.Apply(); 98 var paretoFront = TrainingBestSolutionsParameter.ActualValue; 99 100 IResult result; 101 ScatterPlot qualityToTreeSize; 102 if (!ResultCollection.TryGetValue("Pareto Front Analysis", out result)) { 103 qualityToTreeSize = new ScatterPlot("Quality vs Tree Size", ""); 104 qualityToTreeSize.VisualProperties.XAxisMinimumAuto = false; 105 qualityToTreeSize.VisualProperties.XAxisMaximumAuto = false; 106 qualityToTreeSize.VisualProperties.YAxisMinimumAuto = false; 107 qualityToTreeSize.VisualProperties.YAxisMaximumAuto = false; 108 109 qualityToTreeSize.VisualProperties.XAxisMinimumFixedValue = 0; 110 qualityToTreeSize.VisualProperties.XAxisMaximumFixedValue = MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value; 111 qualityToTreeSize.VisualProperties.YAxisMinimumFixedValue = 0; 112 qualityToTreeSize.VisualProperties.YAxisMaximumFixedValue = 2; 113 ResultCollection.Add(new Result("Pareto Front Analysis", qualityToTreeSize)); 114 } else { 115 qualityToTreeSize = (ScatterPlot)result.Value; 116 } 117 118 119 int previousTreeLength = -1; 120 var sizeParetoFront = new LinkedList<ISymbolicRegressionSolution>(); 121 foreach (var solution in paretoFront.OrderBy(s => s.Model.SymbolicExpressionTree.Length)) { 122 int treeLength = solution.Model.SymbolicExpressionTree.Length; 123 if (!sizeParetoFront.Any()) sizeParetoFront.AddLast(solution); 124 if (solution.TrainingNormalizedMeanSquaredError < sizeParetoFront.Last.Value.TrainingNormalizedMeanSquaredError) { 125 if (treeLength == previousTreeLength) 126 sizeParetoFront.RemoveLast(); 127 sizeParetoFront.AddLast(solution); 128 } 129 previousTreeLength = treeLength; 130 } 131 132 qualityToTreeSize.Rows.Clear(); 133 var trainingRow = new ScatterPlotDataRow("Training NMSE", "", sizeParetoFront.Select(x => new Point2D<double>(x.Model.SymbolicExpressionTree.Length, x.TrainingNormalizedMeanSquaredError))); 134 trainingRow.VisualProperties.PointSize = 8; 135 qualityToTreeSize.Rows.Add(trainingRow); 136 137 var validationPartition = ValidationPartitionParameter.ActualValue; 138 if (validationPartition.Size != 0) { 139 var problemData = ProblemDataParameter.ActualValue; 140 var validationIndizes = Enumerable.Range(validationPartition.Start, validationPartition.Size).ToList(); 141 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, validationIndizes).ToList(); 142 OnlineCalculatorError error; 143 var validationRow = new ScatterPlotDataRow("Validation NMSE", "", 144 sizeParetoFront.Select(x => new Point2D<double>(x.Model.SymbolicExpressionTree.Length, 145 OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, x.GetEstimatedValues(validationIndizes), out error)))); 146 validationRow.VisualProperties.PointSize = 7; 147 qualityToTreeSize.Rows.Add(validationRow); 148 } 149 150 return operation; 151 } 152 70 153 } 71 154 }
Note: See TracChangeset
for help on using the changeset viewer.