- Timestamp:
- 08/18/10 14:58:56 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs
r4128 r4250 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; 27 26 using HeuristicLab.Data; 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers;30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;32 27 using HeuristicLab.Optimization; 33 28 using HeuristicLab.Parameters; 34 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 35 using HeuristicLab.PluginInfrastructure;36 30 using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers; 37 using HeuristicLab.Problems.DataAnalysis.Symbolic;38 31 39 32 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic { … … 84 77 public SymbolicRegressionProblem() 85 78 : base() { 86 var evaluator = new SymbolicRegression ScaledMeanSquaredErrorEvaluator();87 Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the error of the regression model should be minimized.", (BoolValue)new BoolValue( false).AsReadOnly()));79 var evaluator = new SymbolicRegressionPearsonsRSquaredEvaluator(); 80 Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the error of the regression model should be minimized.", (BoolValue)new BoolValue(true))); 88 81 Parameters.Add(new ValueParameter<ISymbolicRegressionEvaluator>("Evaluator", "The operator which should be used to evaluate symbolic regression solutions.", evaluator)); 89 82 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The minimal error value that reached by symbolic regression solutions for the problem.")); 90 83 91 evaluator.QualityParameter.ActualName = "Training MeanSquaredError";84 evaluator.QualityParameter.ActualName = "TrainingPearsonR2"; 92 85 93 86 InitializeOperators(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblemBase.cs
r4198 r4250 113 113 public ISymbolicExpressionGrammar FunctionTreeGrammar { 114 114 get { return (ISymbolicExpressionGrammar)FunctionTreeGrammarParameter.Value; } 115 private set { FunctionTreeGrammarParameter.Value = value; } 115 116 } 116 117 public override IEnumerable<IOperator> Operators { … … 190 191 MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged); 191 192 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); 193 FunctionTreeGrammarParameter.ValueChanged += new EventHandler(FunctionTreeGrammarParameter_ValueChanged); 192 194 } 193 195 … … 211 213 UpdateGrammar(); 212 214 } 213 protected virtual void OnGrammarChanged( EventArgs e) {}215 protected virtual void OnGrammarChanged() { UpdateGrammar(); } 214 216 protected virtual void OnOperatorsChanged(EventArgs e) { RaiseOperatorsChanged(e); } 215 217 protected virtual void OnSolutionCreatorChanged(EventArgs e) { … … 231 233 232 234 #region event handlers 235 private void FunctionTreeGrammarParameter_ValueChanged(object sender, EventArgs e) { 236 if (!(FunctionTreeGrammar is GlobalSymbolicExpressionGrammar)) 237 FunctionTreeGrammar = new GlobalSymbolicExpressionGrammar(FunctionTreeGrammar); 238 OnGrammarChanged(); 239 } 240 233 241 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { 234 242 OnSolutionCreatorChanged(e); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs
r4068 r4250 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols; 28 29 29 30 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic { … … 50 51 51 52 protected override void RecalculateEstimatedValues() { 52 estimatedValues = (from x in Model.GetEstimatedValues(ProblemData, 0, ProblemData.Dataset.Rows) 53 let boundedX = Math.Min(UpperEstimationLimit, Math.Max(LowerEstimationLimit, x)) 54 select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList(); 53 int minLag = 0; 54 var laggedTreeNodes = Model.SymbolicExpressionTree.IterateNodesPrefix().OfType<LaggedVariableTreeNode>(); 55 if (laggedTreeNodes.Any()) 56 minLag = laggedTreeNodes.Min(node => node.Lag); 57 IEnumerable<double> calculatedValues = 58 from x in Model.GetEstimatedValues(ProblemData, 0 - minLag, ProblemData.Dataset.Rows) 59 let boundedX = Math.Min(UpperEstimationLimit, Math.Max(LowerEstimationLimit, x)) 60 select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX; 61 estimatedValues = Enumerable.Repeat(double.NaN, Math.Abs(minLag)).Concat(calculatedValues).ToList(); 55 62 OnEstimatedValuesChanged(); 56 63 }
Note: See TracChangeset
for help on using the changeset viewer.