- Timestamp:
- 05/30/20 22:00:12 (5 years ago)
- Location:
- trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionEvaluator.cs
r17180 r17579 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 { -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionModel.cs
r17180 r17579 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")] -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionSolution.cs
r17180 r17579 22 22 23 23 24 24 25 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 25 26 [StorableType("dff1a450-e958-454f-bf8e-6b763fdcaff3")] -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r17180 r17579 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 115 97 116 98 117 [StorableConstructor] … … 118 137 estimationLimitResults.Add(new Result(TestNaNEvaluationsResultName, "", new IntValue())); 119 138 Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults)); 139 140 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) 141 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", new IntervalCollection())); 142 120 143 RecalculateResults(); 121 144 } … … 139 162 CalculateResults(); 140 163 } 164 165 if (!ContainsKey(ModelBoundsResultName)) { 166 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) { 167 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", new IntervalCollection())); 168 CalculateResults(); 169 } 170 } 141 171 } 142 172 … … 159 189 TrainingNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TrainingIndices).Count(double.IsNaN); 160 190 TestNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TestIndices).Count(double.IsNaN); 191 192 //Check if the tree contains unknown symbols for the interval calculation 193 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) 194 ModelBoundsCollection = CalculateModelIntervals(this); 195 } 196 197 private static IntervalCollection CalculateModelIntervals(ISymbolicRegressionSolution solution) { 198 var intervalEvaluation = new IntervalCollection(); 199 var interpreter = new IntervalInterpreter(); 200 var problemData = solution.ProblemData; 201 var model = solution.Model; 202 var variableRanges = problemData.VariableRanges.GetReadonlyDictionary(); 203 204 intervalEvaluation.AddInterval($"Target {problemData.TargetVariable}", new Interval(variableRanges[problemData.TargetVariable].LowerBound, variableRanges[problemData.TargetVariable].UpperBound)); 205 intervalEvaluation.AddInterval("Model", interpreter.GetSymbolicExpressionTreeInterval(model.SymbolicExpressionTree, variableRanges)); 206 207 if (DerivativeCalculator.IsCompatible(model.SymbolicExpressionTree)) { 208 foreach (var inputVariable in model.VariablesUsedForPrediction.OrderBy(v => v, new NaturalStringComparer())) { 209 var derivedModel = DerivativeCalculator.Derive(model.SymbolicExpressionTree, inputVariable); 210 var derivedResultInterval = interpreter.GetSymbolicExpressionTreeInterval(derivedModel, variableRanges); 211 212 intervalEvaluation.AddInterval(" ∂f/∂" + inputVariable, new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound)); 213 } 214 } 215 216 return intervalEvaluation; 161 217 } 162 218 }
Note: See TracChangeset
for help on using the changeset viewer.