Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/14 14:04:03 (11 years ago)
Author:
bburlacu
Message:

#2143: Refactored pruning analyzer and operators as per review.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r10368 r10469  
    120120    <Compile Include="Plugin.cs" />
    121121    <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" />
    122     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" />   
    123   <Compile Include="SymbolicRegressionPruningAnalyzer.cs" />   
    124   <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer.cs" />
     122    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" />
     123    <Compile Include="SymbolicRegressionPruningAnalyzer.cs" />
     124    <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer.cs" />
    125125    <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer.cs" />
    126126    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs" />
     
    145145    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs" />
    146146    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs" />
     147    <Compile Include="SymbolicRegressionPruningOperator.cs" />
    147148    <Compile Include="SymbolicRegressionSolution.cs" />
    148149    <Compile Include="SymbolicRegressionSolutionImpactValuesCalculator.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningAnalyzer.cs

    r10378 r10469  
    1 using System;
     1#region License Information
     2
     3/* HeuristicLab
     4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     5 *
     6 * This file is part of HeuristicLab.
     7 *
     8 * HeuristicLab is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * (at your option) any later version.
     12 *
     13 * HeuristicLab is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     20 */
     21
     22#endregion
     23
    224using HeuristicLab.Common;
    325using HeuristicLab.Core;
    4 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     26using HeuristicLab.Parameters;
    527using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    628
     
    931  [StorableClass]
    1032  public sealed class SymbolicRegressionPruningAnalyzer : SymbolicDataAnalysisSingleObjectivePruningAnalyzer {
     33    private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator";
     34    private const string PruningOperatorParameterName = "PruningOperator";
    1135    private SymbolicRegressionPruningAnalyzer(SymbolicRegressionPruningAnalyzer original, Cloner cloner)
    1236      : base(original, cloner) {
     
    2044
    2145    public SymbolicRegressionPruningAnalyzer() {
    22       impactValuesCalculator = new SymbolicRegressionSolutionImpactValuesCalculator();
    23     }
    24 
    25     protected override ISymbolicDataAnalysisModel CreateModel(ISymbolicExpressionTree tree,
    26       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, double lowerEstimationLimit = Double.MinValue,
    27       double upperEstimationLimit = Double.MaxValue) {
    28       return new SymbolicRegressionModel(tree, interpreter, lowerEstimationLimit, upperEstimationLimit);
     46      Parameters.Add(new ValueParameter<SymbolicDataAnalysisSolutionImpactValuesCalculator>(ImpactValuesCalculatorParameterName, "The impact values calculator", new SymbolicRegressionSolutionImpactValuesCalculator()));
     47      Parameters.Add(new ValueParameter<SymbolicDataAnalysisExpressionPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicRegressionPruningOperator()));
    2948    }
    3049  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs

    r9840 r10469  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Common;
     25using HeuristicLab.Core;
    2426using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2528
    2629namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     30  [StorableClass]
     31  [Item("SymbolicRegressionSolutionImpactValuesCalculator", "Calculate symbolic expression tree node impact values for regression problems.")]
    2732  public class SymbolicRegressionSolutionImpactValuesCalculator : SymbolicDataAnalysisSolutionImpactValuesCalculator {
     33    public SymbolicRegressionSolutionImpactValuesCalculator() { }
     34
     35    protected SymbolicRegressionSolutionImpactValuesCalculator(SymbolicRegressionSolutionImpactValuesCalculator original, Cloner cloner)
     36      : base(original, cloner) { }
     37    public override IDeepCloneable Clone(Cloner cloner) {
     38      return new SymbolicRegressionSolutionImpactValuesCalculator(this, cloner);
     39    }
     40
     41    [StorableConstructor]
     42    protected SymbolicRegressionSolutionImpactValuesCalculator(bool deserializing) : base(deserializing) { }
    2843    public override double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows) {
    2944      var regressionModel = (ISymbolicRegressionModel)model;
     
    3449
    3550    public override double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN) {
     51      double impactValue, replacementValue;
     52      CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, originalQuality);
     53      return impactValue;
     54    }
     55
     56    public override void CalculateImpactAndReplacementValues(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node,
     57      IDataAnalysisProblemData problemData, IEnumerable<int> rows, out double impactValue, out double replacementValue,
     58      double originalQuality = Double.NaN) {
    3659      var regressionModel = (ISymbolicRegressionModel)model;
    3760      var regressionProblemData = (IRegressionProblemData)problemData;
     
    4770      }
    4871
    49       var replacementValue = CalculateReplacementValue(regressionModel, node, regressionProblemData, rows);
     72      replacementValue = CalculateReplacementValue(regressionModel, node, regressionProblemData, rows);
    5073      var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue };
    5174
     
    6386      if (errorState != OnlineCalculatorError.None) newQuality = 0.0;
    6487
    65       return originalQuality - newQuality;
     88      impactValue = originalQuality - newQuality;
    6689    }
    67 
    6890  }
    6991}
Note: See TracChangeset for help on using the changeset viewer.