Changeset 17928 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Timestamp:
- 04/06/21 13:13:32 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 10 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
r16658 r17928 119 119 </ItemGroup> 120 120 <ItemGroup> 121 <Compile Include="MultiObjective\NMSEConstraintsEvaluator.cs" /> 121 122 <Compile Include="MultiObjective\PearsonRSquaredNestedTreeSizeEvaluator.cs" /> 122 123 <Compile Include="MultiObjective\PearsonRSquaredNumberOfVariablesEvaluator.cs" /> … … 125 126 <Compile Include="MultiObjective\SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer.cs" /> 126 127 <Compile Include="Plugin.cs" /> 128 <Compile Include="ShapeConstraintsAnalyzer.cs" /> 127 129 <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" /> 130 <Compile Include="SingleObjective\Evaluators\NMSEConstraintsEvaluator.cs" /> 128 131 <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" /> 129 132 <Compile Include="SingleObjective\SymbolicRegressionSolutionsAnalyzer.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionEvaluator.cs
r17180 r17928 1 using HEAL.Attic; 2 #region License Information 1 #region License Information 3 2 /* HeuristicLab 4 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 20 19 */ 21 20 #endregion 22 21 using HEAL.Attic; 23 22 24 23 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionModel.cs
r17180 r17928 1 using HEAL.Attic; 2 #region License Information 1 #region License Information 3 2 /* HeuristicLab 4 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 21 20 #endregion 22 21 22 using HEAL.Attic; 23 23 24 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 24 25 [StorableType("a411e2b5-f926-41a6-b55b-1aef862db2fb")] -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionSolution.cs
r17180 r17928 22 22 23 23 24 24 25 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 25 26 [StorableType("dff1a450-e958-454f-bf8e-6b763fdcaff3")] -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
r17180 r17928 209 209 bool updateConstantsInTree = true, Action<double[], double, object> iterationCallback = null, EvaluationsCounter counter = null) { 210 210 211 // numeric constants in the tree become variables for constant opt212 // variables in the tree become parameters (fixed values) for constant opt213 // for each parameter (variable in the original tree) we store the211 // Numeric constants in the tree become variables for parameter optimization. 212 // Variables in the tree become parameters (fixed values) for parameter optimization. 213 // For each parameter (variable in the original tree) we store the 214 214 // variable name, variable value (for factor vars) and lag as a DataForVariable object. 215 215 // A dictionary is used to find parameters … … 221 221 if (!TreeToAutoDiffTermConverter.TryConvertToAutoDiff(tree, updateVariableWeights, applyLinearScaling, out parameters, out initialConstants, out func, out func_grad)) 222 222 throw new NotSupportedException("Could not optimize constants of symbolic expression tree due to not supported symbols used in the tree."); 223 if (parameters.Count == 0) return 0.0; // gkronber:constant expressions always have a R² of 0.0223 if (parameters.Count == 0) return 0.0; // constant expressions always have a R² of 0.0 224 224 var parameterEntries = parameters.ToArray(); // order of entries must be the same for x 225 225 226 // extract inital constants226 // extract inital constants 227 227 double[] c; 228 228 if (applyLinearScaling) { … … 309 309 VariableTreeNodeBase variableTreeNodeBase = node as VariableTreeNodeBase; 310 310 FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode; 311 if (constantTreeNode != null) 311 if (constantTreeNode != null) { 312 if (constantTreeNode.Parent.Symbol is Power 313 && constantTreeNode.Parent.GetSubtree(1) == constantTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter) 312 314 constantTreeNode.Value = constants[i++]; 313 else if (updateVariableWeights && variableTreeNodeBase != null)315 } else if (updateVariableWeights && variableTreeNodeBase != null) 314 316 variableTreeNodeBase.Weight = constants[i++]; 315 317 else if (factorVarTreeNode != null) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
r17180 r17928 91 91 changed = true; 92 92 } 93 94 if (!Operators.OfType<ShapeConstraintsAnalyzer>().Any()) { 95 Operators.Add(new ShapeConstraintsAnalyzer()); 96 changed = true; 97 } 93 98 if (changed) { 94 99 ParameterizeOperators(); … … 113 118 Operators.Add(new SymbolicRegressionSolutionsAnalyzer()); 114 119 Operators.Add(new SymbolicExpressionTreePhenotypicSimilarityCalculator()); 120 Operators.Add(new ShapeConstraintsAnalyzer()); 115 121 Operators.Add(new SymbolicRegressionPhenotypicDiversityAnalyzer(Operators.OfType<SymbolicExpressionTreePhenotypicSimilarityCalculator>()) { DiversityResultName = "Phenotypic Diversity" }); 116 122 ParameterizeOperators(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r17180 r17928 1 #region License Information1 #region License Information 2 2 /* HeuristicLab 3 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 21 21 22 22 using System.Linq; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 26 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 28 using HeuristicLab.Optimization; 28 using HEAL.Attic;29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { … … 47 47 private const string TestNaNEvaluationsResultName = "Test NaN Evaluations"; 48 48 49 private const string ModelBoundsResultName = "Model Bounds"; 50 49 51 public new ISymbolicRegressionModel Model { 50 52 get { return (ISymbolicRegressionModel)base.Model; } … … 95 97 private set { ((IntValue)EstimationLimitsResultCollection[TestNaNEvaluationsResultName].Value).Value = value; } 96 98 } 99 100 public IntervalCollection ModelBoundsCollection { 101 get { 102 if (!ContainsKey(ModelBoundsResultName)) return null; 103 return (IntervalCollection)this[ModelBoundsResultName].Value; 104 } 105 private set { 106 if (ContainsKey(ModelBoundsResultName)) { 107 this[ModelBoundsResultName].Value = value; 108 } else { 109 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", value)); 110 } 111 } 112 } 113 114 97 115 98 116 [StorableConstructor] … … 118 136 estimationLimitResults.Add(new Result(TestNaNEvaluationsResultName, "", new IntValue())); 119 137 Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults)); 138 139 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) 140 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", new IntervalCollection())); 141 120 142 RecalculateResults(); 121 143 } … … 139 161 CalculateResults(); 140 162 } 163 164 if (!ContainsKey(ModelBoundsResultName)) { 165 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) { 166 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", new IntervalCollection())); 167 CalculateResults(); 168 } 169 } 141 170 } 142 171 … … 159 188 TrainingNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TrainingIndices).Count(double.IsNaN); 160 189 TestNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TestIndices).Count(double.IsNaN); 190 191 //Check if the tree contains unknown symbols for the interval calculation 192 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) 193 ModelBoundsCollection = CalculateModelIntervals(this); 194 } 195 196 private static IntervalCollection CalculateModelIntervals(ISymbolicRegressionSolution solution) { 197 var intervalEvaluation = new IntervalCollection(); 198 var interpreter = new IntervalInterpreter(); 199 var problemData = solution.ProblemData; 200 var model = solution.Model; 201 var variableRanges = problemData.VariableRanges.GetReadonlyDictionary(); 202 203 intervalEvaluation.AddInterval($"Target {problemData.TargetVariable}", new Interval(variableRanges[problemData.TargetVariable].LowerBound, variableRanges[problemData.TargetVariable].UpperBound)); 204 intervalEvaluation.AddInterval("Model", interpreter.GetSymbolicExpressionTreeInterval(model.SymbolicExpressionTree, variableRanges)); 205 206 if (DerivativeCalculator.IsCompatible(model.SymbolicExpressionTree)) { 207 foreach (var inputVariable in model.VariablesUsedForPrediction.OrderBy(v => v, new NaturalStringComparer())) { 208 var derivedModel = DerivativeCalculator.Derive(model.SymbolicExpressionTree, inputVariable); 209 var derivedResultInterval = interpreter.GetSymbolicExpressionTreeInterval(derivedModel, variableRanges); 210 211 intervalEvaluation.AddInterval(" ∂f/∂" + inputVariable, new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound)); 212 } 213 } 214 215 return intervalEvaluation; 161 216 } 162 217 }
Note: See TracChangeset
for help on using the changeset viewer.