Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12378


Ignore:
Timestamp:
05/04/15 13:08:49 (10 years ago)
Author:
gkronber
Message:

Merged revision(s) 12333-12365 from trunk/sources:
#2373: Corrected typo in RandomBinaryVectorCreator by implementing an after-deserialization-hook.

........
#2359: Refactored pruning operators and analyzers.

........
#2359: Removed commented code from pruning analyzer.

........
#2378: Vertex.cs: Fixed bug in Label setter.
........
#2359: The changes in r12358 look fine to me. Added total number of pruned nodes in the analyzer's data table. Removed unused parameter names in the SymbolicDataAnalysisSingleObjectivePruningAnalyzer.
........
#2345: Fixed x-axis maximum in error characteristics curve.

........

Location:
branches/GBT
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • branches/GBT

  • branches/GBT/HeuristicLab.Core

  • branches/GBT/HeuristicLab.Core/3.3/Collections/DirectedGraph/Vertex.cs

    r12012 r12378  
    3535      get { return label; }
    3636      set {
    37         if (label.Equals(value)) return;
     37        if (String.Equals(Label, value)) return;
    3838        label = value;
    3939        OnChanged(this, EventArgs.Empty);
  • branches/GBT/HeuristicLab.Encodings.BinaryVectorEncoding

  • branches/GBT/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Creators/RandomBinaryVectorCreator.cs

    r12012 r12378  
    3434  [StorableClass]
    3535  public sealed class RandomBinaryVectorCreator : BinaryVectorCreator {
    36     private const string TrueProbabilityParameterName = "TruePropability";
     36    private const string TrueProbabilityParameterName = "TrueProbability";
    3737
    3838    private IValueLookupParameter<DoubleValue> TrueProbabilityParameter {
     
    5959      #region Backwards compatible code, remove with 3.4
    6060      var defaultValue = 0.5;
    61       if (Parameters.ContainsKey(TrueProbabilityParameterName) && Parameters[TrueProbabilityParameterName] is IFixedValueParameter<DoubleValue>) {
    62         defaultValue = ((IFixedValueParameter<DoubleValue>)Parameters[TrueProbabilityParameterName]).Value.Value;
    63         Parameters.Remove(TrueProbabilityParameterName);
     61      const string parameterNameWithTypo = "TruePropability";
     62      if (Parameters.ContainsKey(parameterNameWithTypo) && Parameters[parameterNameWithTypo] is IValueParameter<DoubleValue>) {
     63        defaultValue = ((IValueParameter<DoubleValue>)Parameters[parameterNameWithTypo]).Value.Value;
     64        Parameters.Remove(parameterNameWithTypo);
    6465      }
    6566      if (!Parameters.ContainsKey(TrueProbabilityParameterName))
  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification

  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningAnalyzer.cs

    r12189 r12378  
    2929  [StorableClass]
    3030  public sealed class SymbolicClassificationPruningAnalyzer : SymbolicDataAnalysisSingleObjectivePruningAnalyzer {
    31     private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator";
    3231    private const string PruningOperatorParameterName = "PruningOperator";
    33     private SymbolicClassificationPruningAnalyzer(SymbolicClassificationPruningAnalyzer original, Cloner cloner)
    34       : base(original, cloner) {
     32    public IValueParameter<SymbolicClassificationPruningOperator> PruningOperatorParameter {
     33      get { return (IValueParameter<SymbolicClassificationPruningOperator>)Parameters[PruningOperatorParameterName]; }
    3534    }
    36     public override IDeepCloneable Clone(Cloner cloner) {
    37       return new SymbolicClassificationPruningAnalyzer(this, cloner);
     35
     36    protected override SymbolicDataAnalysisExpressionPruningOperator PruningOperator {
     37      get { return PruningOperatorParameter.Value; }
    3838    }
     39
     40    private SymbolicClassificationPruningAnalyzer(SymbolicClassificationPruningAnalyzer original, Cloner cloner) : base(original, cloner) { }
     41    public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicClassificationPruningAnalyzer(this, cloner); }
    3942
    4043    [StorableConstructor]
     
    4245
    4346    public SymbolicClassificationPruningAnalyzer() {
    44       Parameters.Add(new ValueParameter<SymbolicDataAnalysisSolutionImpactValuesCalculator>(ImpactValuesCalculatorParameterName, "The impact values calculator", new SymbolicClassificationSolutionImpactValuesCalculator()));
    4547      Parameters.Add(new ValueParameter<SymbolicDataAnalysisExpressionPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicClassificationPruningOperator(new SymbolicClassificationSolutionImpactValuesCalculator())));
    4648    }
  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningOperator.cs

    r12189 r12378  
    4242    #endregion
    4343
    44     protected SymbolicClassificationPruningOperator(SymbolicClassificationPruningOperator original, Cloner cloner)
    45       : base(original, cloner) {
    46     }
    47 
    48     public override IDeepCloneable Clone(Cloner cloner) {
    49       return new SymbolicClassificationPruningOperator(this, cloner);
    50     }
     44    protected SymbolicClassificationPruningOperator(SymbolicClassificationPruningOperator original, Cloner cloner) : base(original, cloner) { }
     45    public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicClassificationPruningOperator(this, cloner); }
    5146
    5247    [StorableConstructor]
     
    6863    protected override double Evaluate(IDataAnalysisModel model) {
    6964      var classificationModel = (IClassificationModel)model;
    70       var classificationProblemData = (IClassificationProblemData)ProblemData;
    71       var trainingIndices = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size);
     65      var classificationProblemData = (IClassificationProblemData)ProblemDataParameter.ActualValue;
     66      var rows = Enumerable.Range(FitnessCalculationPartitionParameter.ActualValue.Start, FitnessCalculationPartitionParameter.ActualValue.Size);
    7267
    73       return Evaluate(classificationModel, classificationProblemData, trainingIndices);
     68      return Evaluate(classificationModel, classificationProblemData, rows);
    7469    }
    7570
     
    10095        impactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, quality);
    10196
    102         if (pruneOnlyZeroImpactNodes) {
    103           if (!impactValue.IsAlmost(0.0)) continue;
    104         } else if (nodeImpactThreshold < impactValue) {
    105           continue;
    106         }
     97        if (pruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue;
     98        if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue;
    10799
    108100        var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningAnalyzer.cs

    r12189 r12378  
    3131  [StorableClass]
    3232  public sealed class SymbolicRegressionPruningAnalyzer : SymbolicDataAnalysisSingleObjectivePruningAnalyzer {
    33     private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator";
    3433    private const string PruningOperatorParameterName = "PruningOperator";
    35     private SymbolicRegressionPruningAnalyzer(SymbolicRegressionPruningAnalyzer original, Cloner cloner)
    36       : base(original, cloner) {
     34    public IValueParameter<SymbolicRegressionPruningOperator> PruningOperatorParameter {
     35      get { return (IValueParameter<SymbolicRegressionPruningOperator>)Parameters[PruningOperatorParameterName]; }
    3736    }
    38     public override IDeepCloneable Clone(Cloner cloner) {
    39       return new SymbolicRegressionPruningAnalyzer(this, cloner);
     37
     38    protected override SymbolicDataAnalysisExpressionPruningOperator PruningOperator {
     39      get { return PruningOperatorParameter.Value; }
    4040    }
     41
     42    private SymbolicRegressionPruningAnalyzer(SymbolicRegressionPruningAnalyzer original, Cloner cloner) : base(original, cloner) { }
     43    public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicRegressionPruningAnalyzer(this, cloner); }
    4144
    4245    [StorableConstructor]
     
    4447
    4548    public SymbolicRegressionPruningAnalyzer() {
    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(new SymbolicRegressionSolutionImpactValuesCalculator())));
     49      Parameters.Add(new ValueParameter<SymbolicRegressionPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicRegressionPruningOperator(new SymbolicRegressionSolutionImpactValuesCalculator())));
    4850    }
    4951  }
  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs

    r12189 r12378  
    5353    protected override double Evaluate(IDataAnalysisModel model) {
    5454      var regressionModel = (IRegressionModel)model;
    55       var regressionProblemData = (IRegressionProblemData)ProblemData;
    56       var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size);
     55      var regressionProblemData = (IRegressionProblemData)ProblemDataParameter.ActualValue;
     56      var rows = Enumerable.Range(FitnessCalculationPartitionParameter.ActualValue.Start, FitnessCalculationPartitionParameter.ActualValue.Size);
    5757      return Evaluate(regressionModel, regressionProblemData, rows);
    5858    }
     
    8181        impactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, quality);
    8282
    83         if (pruneOnlyZeroImpactNodes) {
    84           if (!impactValue.IsAlmost(0.0)) continue;
    85         } else if (nodeImpactThreshold < impactValue) {
    86           continue;
    87         }
     83        if (pruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue;
     84        if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue;
    8885
    8986        var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs

    r12012 r12378  
    4545    private const string TotalNumberOfPrunedSubtreesParameterName = "Number of pruned subtrees";
    4646    private const string TotalNumberOfPrunedTreesParameterName = "Number of pruned trees";
     47    private const string TotalNumberOfPrunedNodesParameterName = "Number of pruned nodes";
    4748    private const string RandomParameterName = "Random";
    48     private const string PruneOnlyZeroImpactNodesParameterName = "PruneOnlyZeroImpactNodes";
    49     private const string NodeImpactThresholdParameterName = "ImpactThreshold";
    50     private const string PruningOperatorParameterName = "PruningOperator";
    5149    private const string ResultsParameterName = "Results";
    5250    private const string PopulationSizeParameterName = "PopulationSize";
     
    5452
    5553    #region private members
     54    private DataReducer prunedNodesReducer;
    5655    private DataReducer prunedSubtreesReducer;
    5756    private DataReducer prunedTreesReducer;
     
    6160
    6261    #region parameter properties
    63     public IValueParameter<SymbolicDataAnalysisExpressionPruningOperator> PruningOperatorParameter {
    64       get { return (IValueParameter<SymbolicDataAnalysisExpressionPruningOperator>)Parameters[PruningOperatorParameterName]; }
    65     }
    66     public IFixedValueParameter<BoolValue> PruneOnlyZeroImpactNodesParameter {
    67       get { return (IFixedValueParameter<BoolValue>)Parameters[PruneOnlyZeroImpactNodesParameterName]; }
    68     }
    69     public IFixedValueParameter<DoubleValue> NodeImpactThresholdParameter {
    70       get { return (IFixedValueParameter<DoubleValue>)Parameters[NodeImpactThresholdParameterName]; }
    71     }
    7262    public ILookupParameter<IRandom> RandomParameter {
    7363      get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; }
     
    9181
    9282    #region properties
    93     protected SymbolicDataAnalysisExpressionPruningOperator PruningOperator { get { return PruningOperatorParameter.Value; } }
     83    protected abstract SymbolicDataAnalysisExpressionPruningOperator PruningOperator { get; }
    9484    protected int UpdateInterval { get { return UpdateIntervalParameter.Value.Value; } }
    9585
     
    112102      get { return PruningProbabilityParameter.Value.Value; }
    113103      set { PruningProbabilityParameter.Value.Value = value; }
    114     }
    115 
    116     protected bool PruneOnlyZeroImpactNodes {
    117       get { return PruneOnlyZeroImpactNodesParameter.Value.Value; }
    118       set { PruneOnlyZeroImpactNodesParameter.Value.Value = value; }
    119     }
    120     protected double NodeImpactThreshold {
    121       get { return NodeImpactThresholdParameter.Value.Value; }
    122       set { NodeImpactThresholdParameter.Value.Value = value; }
    123104    }
    124105    #endregion
     
    140121    protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner)
    141122      : base(original, cloner) {
     123      if (original.prunedNodesReducer != null)
     124        this.prunedNodesReducer = (DataReducer)original.prunedNodesReducer.Clone();
    142125      if (original.prunedSubtreesReducer != null)
    143126        this.prunedSubtreesReducer = (DataReducer)original.prunedSubtreesReducer.Clone();
     
    197180      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random number generator."));
    198181      Parameters.Add(new LookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The problem data."));
    199       Parameters.Add(new FixedValueParameter<DoubleValue>(NodeImpactThresholdParameterName, "The impact threshold  below which an individual should be pruned.", new DoubleValue(0.0)));
    200       Parameters.Add(new FixedValueParameter<BoolValue>(PruneOnlyZeroImpactNodesParameterName, "Switch to determine of only zero impact individuals should be pruned.", new BoolValue(false)));
    201182      Parameters.Add(new LookupParameter<IntValue>(PopulationSizeParameterName, "The population of individuals."));
    202183      #endregion
     
    250231      UpdateCounter = 0;
    251232
    252       if (prunedSubtreesReducer == null || prunedTreesReducer == null || valuesCollector == null || resultsCollector == null) { InitializeOperators(); }
     233      if (prunedNodesReducer == null || prunedSubtreesReducer == null || prunedTreesReducer == null || valuesCollector == null || resultsCollector == null) { InitializeOperators(); }
    253234
    254235      var prune = CreatePruningOperation();
     236      var reducePrunedNodes = ExecutionContext.CreateChildOperation(prunedNodesReducer);
    255237      var reducePrunedSubtrees = ExecutionContext.CreateChildOperation(prunedSubtreesReducer);
    256238      var reducePrunedTrees = ExecutionContext.CreateChildOperation(prunedTreesReducer);
     
    258240      var collectResults = ExecutionContext.CreateChildOperation(resultsCollector);
    259241
    260       return new OperationCollection { prune, reducePrunedSubtrees, reducePrunedTrees, collectValues, collectResults, base.Apply() };
     242      return new OperationCollection { prune, reducePrunedNodes, reducePrunedSubtrees, reducePrunedTrees, collectValues, collectResults, base.Apply() };
    261243    }
    262244
    263245    private void InitializeOperators() {
     246      prunedNodesReducer = new DataReducer();
     247      prunedNodesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedNodesParameter.ActualName;
     248      prunedNodesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); // sum all the pruned subtrees parameter values
     249      prunedNodesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
     250      prunedNodesReducer.TargetParameter.ActualName = TotalNumberOfPrunedNodesParameterName;
     251
    264252      prunedSubtreesReducer = new DataReducer();
    265253      prunedSubtreesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedSubtreesParameter.ActualName;
     
    275263
    276264      valuesCollector = new DataTableValuesCollector();
     265      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedNodesParameterName));
    277266      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedSubtreesParameterName));
    278267      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedTreesParameterName));
  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs

    r12189 r12378  
    3434  [StorableClass]
    3535  [Item("SymbolicExpressionTreePruningOperator", "An operator that replaces introns with constant values in a symbolic expression tree.")]
    36   public abstract class SymbolicDataAnalysisExpressionPruningOperator : SingleSuccessorOperator {
     36  public abstract class SymbolicDataAnalysisExpressionPruningOperator : SingleSuccessorOperator, ISymbolicExpressionTreeOperator {
    3737    #region parameter names
    3838    private const string ProblemDataParameterName = "ProblemData";
     
    4141    private const string PrunedSubtreesParameterName = "PrunedSubtrees";
    4242    private const string PrunedTreesParameterName = "PrunedTrees";
     43    private const string PrunedNodesParameterName = "PrunedNodes";
    4344    private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
    4445    private const string NodeImpactThresholdParameterName = "ImpactThreshold";
     
    7273      get { return (ILookupParameter<IntValue>)Parameters[PrunedTreesParameterName]; }
    7374    }
     75    public ILookupParameter<IntValue> PrunedNodesParameter {
     76      get { return (ILookupParameter<IntValue>)Parameters[PrunedNodesParameterName]; }
     77    }
    7478    public IFixedValueParameter<DoubleValue> NodeImpactThresholdParameter {
    7579      get { return (IFixedValueParameter<DoubleValue>)Parameters[NodeImpactThresholdParameterName]; }
     
    8791
    8892    #region properties
    89     protected IDataAnalysisProblemData ProblemData { get { return ProblemDataParameter.ActualValue; } }
    90     protected ISymbolicDataAnalysisSolutionImpactValuesCalculator ImpactValuesCalculator { get { return ImpactValuesCalculatorParameter.Value; } }
    91     protected IntRange FitnessCalculationPartition { get { return FitnessCalculationPartitionParameter.ActualValue; } }
    92     protected bool PruneOnlyZeroImpactNodes {
     93    public ISymbolicDataAnalysisSolutionImpactValuesCalculator ImpactValuesCalculator {
     94      get { return ImpactValuesCalculatorParameter.Value; }
     95      set { ImpactValuesCalculatorParameter.Value = value; }
     96    }
     97    public bool PruneOnlyZeroImpactNodes {
    9398      get { return PruneOnlyZeroImpactNodesParameter.Value.Value; }
    9499      set { PruneOnlyZeroImpactNodesParameter.Value.Value = value; }
    95100    }
    96     protected double NodeImpactThreshold {
     101    public double NodeImpactThreshold {
    97102      get { return NodeImpactThresholdParameter.Value.Value; }
    98103      set { NodeImpactThresholdParameter.Value.Value = value; }
    99104    }
    100     protected ISymbolicExpressionTree SymbolicExpressionTree { get { return SymbolicExpressionTreeParameter.ActualValue; } }
    101     protected DoubleValue Quality { get { return QualityParameter.ActualValue; } }
    102     protected DoubleLimit EstimationLimits { get { return EstimationLimitsParameter.ActualValue; } }
    103     protected ISymbolicDataAnalysisExpressionTreeInterpreter Interpreter { get { return InterpreterParameter.ActualValue; } }
    104105    #endregion
    105106
     
    114115      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisModel>(SymbolicDataAnalysisModelParameterName));
    115116      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName));
     117      Parameters.Add(new LookupParameter<IntValue>(PrunedNodesParameterName, "A counter of how many nodes were pruned."));
    116118      Parameters.Add(new LookupParameter<IntValue>(PrunedSubtreesParameterName, "A counter of how many subtrees were replaced."));
    117119      Parameters.Add(new LookupParameter<IntValue>(PrunedTreesParameterName, "A counter of how many trees were pruned."));
     
    131133
    132134    public override IOperation Apply() {
    133       var model = CreateModel(SymbolicExpressionTree, Interpreter, ProblemData, EstimationLimits);
    134       var nodes = SymbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList();
    135       var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size);
     135      var tree = SymbolicExpressionTreeParameter.ActualValue;
     136      var problemData = ProblemDataParameter.ActualValue;
     137      var fitnessCalculationPartition = FitnessCalculationPartitionParameter.ActualValue;
     138      var estimationLimits = EstimationLimitsParameter.ActualValue;
     139      var interpreter = InterpreterParameter.ActualValue;
     140
     141      var model = CreateModel(tree, interpreter, problemData, estimationLimits);
     142      var nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList();
     143      var rows = Enumerable.Range(fitnessCalculationPartition.Start, fitnessCalculationPartition.Size);
    136144      var prunedSubtrees = 0;
    137145      var prunedTrees = 0;
     146      var prunedNodes = 0;
    138147
    139148      double quality = Evaluate(model);
     
    144153
    145154        double impactValue, replacementValue;
    146         ImpactValuesCalculator.CalculateImpactAndReplacementValues(model, node, ProblemData, rows, out impactValue, out replacementValue, quality);
     155        ImpactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, quality);
    147156
    148         if (PruneOnlyZeroImpactNodes) {
    149           if (!impactValue.IsAlmost(0.0)) continue;
    150         } else if (NodeImpactThreshold < impactValue) {
    151           continue;
    152         }
     157        if (PruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue;
     158        if (!PruneOnlyZeroImpactNodes && impactValue > NodeImpactThreshold) continue;
    153159
    154160        var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
    155161        constantNode.Value = replacementValue;
    156162
     163        var length = node.GetLength();
    157164        ReplaceWithConstant(node, constantNode);
    158         i += node.GetLength() - 1; // skip subtrees under the node that was folded
     165        i += length - 1; // skip subtrees under the node that was folded
    159166
    160167        quality -= impactValue;
    161 
    162168        prunedSubtrees++;
     169        prunedNodes += length;
    163170      }
    164171
     
    166173      PrunedSubtreesParameter.ActualValue = new IntValue(prunedSubtrees);
    167174      PrunedTreesParameter.ActualValue = new IntValue(prunedTrees);
     175      PrunedNodesParameter.ActualValue = new IntValue(prunedNodes);
     176      QualityParameter.ActualValue.Value = quality;
    168177
    169178      return base.Apply();
    170     }
    171 
    172     public ISymbolicExpressionTree Prune(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IDataAnalysisProblemData problemData, DoubleLimit estimationLimits) {
    173       var model = CreateModel((ISymbolicExpressionTree)tree.Clone(), Interpreter, ProblemData, EstimationLimits);
    174       var nodes = SymbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList();
    175       var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size);
    176 
    177       double quality = Evaluate(model);
    178 
    179       for (int i = 0; i < nodes.Count; ++i) {
    180         var node = nodes[i];
    181         if (node is ConstantTreeNode) continue;
    182 
    183         double impactValue, replacementValue;
    184         ImpactValuesCalculator.CalculateImpactAndReplacementValues(model, node, ProblemData, rows, out impactValue, out replacementValue, quality);
    185 
    186         if (PruneOnlyZeroImpactNodes) {
    187           if (!impactValue.IsAlmost(0.0)) continue;
    188         } else if (NodeImpactThreshold < impactValue) {
    189           continue;
    190         }
    191 
    192         var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
    193         constantNode.Value = replacementValue;
    194 
    195         ReplaceWithConstant(node, constantNode);
    196         i += node.GetLength() - 1; // skip subtrees under the node that was folded
    197 
    198         quality -= impactValue;
    199       }
    200       return model.SymbolicExpressionTree;
    201179    }
    202180
  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Views

  • branches/GBT/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r12012 r12378  
    4848      chart.ChartAreas[0].AxisX.Title = "Absolute Error";
    4949      chart.ChartAreas[0].AxisX.Minimum = 0.0;
    50       chart.ChartAreas[0].AxisX.Maximum = 1.0;
     50      chart.ChartAreas[0].AxisX.Maximum = 0.0;
    5151      chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
    5252      chart.ChartAreas[0].CursorX.Interval = 0.01;
     
    118118      solutionSeries.ChartType = SeriesChartType.FastLine;
    119119      var residuals = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution));
    120      
    121       chart.ChartAreas[0].AxisX.Maximum = Math.Ceiling(residuals.Max());
     120
     121
     122      var maxValue = residuals.Max();
     123      if (maxValue >= chart.ChartAreas[0].AxisX.Maximum) {
     124        double scale = Math.Pow(10, Math.Floor(Math.Log10(maxValue)));
     125        var maximum = scale * (1 + (int)(maxValue / scale));
     126        chart.ChartAreas[0].AxisX.Maximum = maximum;
     127      }
    122128      chart.ChartAreas[0].CursorX.Interval = residuals.Min() / 100;
    123129
Note: See TracChangeset for help on using the changeset viewer.