Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/14 19:29:00 (10 years ago)
Author:
mkommend
Message:

#2143: Merged r10368, r10375, r10378, r10414, r10417, r10418, r10428, r10469, r10470, r11013, r11025, r11026, r11027 into stable.

Location:
stable
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj

    r9288 r11145  
    120120    <Compile Include="ModelCreators\NormalDistributedThresholdsModelCreator.cs" />
    121121    <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer.cs" />
     122    <Compile Include="SymbolicClassificationPruningAnalyzer.cs" />
    122123    <Compile Include="SymbolicClassificationSolutionImpactValuesCalculator.cs" />
    123124    <Compile Include="SymbolicNearestNeighbourClassificationModel.cs" />
     
    149150      <SubType>Code</SubType>
    150151    </Compile>
     152    <Compile Include="SymbolicClassificationPruningOperator.cs" />
    151153    <None Include="HeuristicLab.snk" />
    152154    <None Include="Plugin.cs.frame" />
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningAnalyzer.cs

    r10368 r11145  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    222using HeuristicLab.Common;
    323using HeuristicLab.Core;
    4 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    524using HeuristicLab.Parameters;
    625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    1029  [StorableClass]
    1130  public sealed class SymbolicClassificationPruningAnalyzer : SymbolicDataAnalysisSingleObjectivePruningAnalyzer {
    12     private const string ModelCreatorParameterName = "ModelCreator";
    13     #region parameter properties
    14     public ILookupParameter<ISymbolicClassificationModelCreator> ModelCreatorParameter {
    15       get { return (ILookupParameter<ISymbolicClassificationModelCreator>)Parameters[ModelCreatorParameterName]; }
    16     }
    17     #endregion
    18     #region properties
    19     private ISymbolicClassificationModelCreator ModelCreator {
    20       get { return ModelCreatorParameter.ActualValue; }
    21       set { ModelCreatorParameter.ActualValue = value; }
    22     }
    23     #endregion
    24 
    25     protected SymbolicClassificationPruningAnalyzer(SymbolicClassificationPruningAnalyzer original, Cloner cloner)
     31    private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator";
     32    private const string PruningOperatorParameterName = "PruningOperator";
     33    private SymbolicClassificationPruningAnalyzer(SymbolicClassificationPruningAnalyzer original, Cloner cloner)
    2634      : base(original, cloner) {
    2735    }
     
    3038    }
    3139
     40    [StorableConstructor]
     41    private SymbolicClassificationPruningAnalyzer(bool deserializing) : base(deserializing) { }
     42
    3243    public SymbolicClassificationPruningAnalyzer() {
    33       // pruning parameters
    34       Parameters.Add(new LookupParameter<ISymbolicClassificationModelCreator>(ModelCreatorParameterName));
    35       impactValuesCalculator = new SymbolicClassificationSolutionImpactValuesCalculator();
    36     }
    37 
    38     protected override ISymbolicDataAnalysisModel CreateModel(ISymbolicExpressionTree tree,
    39       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, double lowerEstimationLimit = Double.MinValue,
    40       double upperEstimationLimit = Double.MaxValue) {
    41       var model = ModelCreator.CreateSymbolicClassificationModel(tree, Interpreter, lowerEstimationLimit, upperEstimationLimit);
    42       model.RecalculateModelParameters((IClassificationProblemData)ProblemData, ProblemData.TrainingIndices);
    43       return model;
     44      Parameters.Add(new ValueParameter<SymbolicDataAnalysisSolutionImpactValuesCalculator>(ImpactValuesCalculatorParameterName, "The impact values calculator", new SymbolicClassificationSolutionImpactValuesCalculator()));
     45      Parameters.Add(new ValueParameter<SymbolicDataAnalysisExpressionPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicClassificationPruningOperator()));
    4446    }
    4547  }
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningOperator.cs

    r10470 r11145  
    1 using System.Linq;
     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
     24using System.Linq;
    225using HeuristicLab.Common;
    326using HeuristicLab.Core;
    4 using HeuristicLab.Data;
    527using HeuristicLab.Parameters;
    628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    1234    private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator";
    1335    private const string ModelCreatorParameterName = "ModelCreator";
    14     private const string ApplyLinearScalingParmameterName = "ApplyLinearScaling";
    1536
    1637    #region parameter properties
     
    1839      get { return (ILookupParameter<ISymbolicClassificationModelCreator>)Parameters[ModelCreatorParameterName]; }
    1940    }
    20 
    21     public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
    22       get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParmameterName]; }
    23     }
    24     #endregion
    25     #region properties
    26     private ISymbolicClassificationModelCreator ModelCreator { get { return ModelCreatorParameter.ActualValue; } }
    27     private BoolValue ApplyLinearScaling { get { return ApplyLinearScalingParameter.ActualValue; } }
    2841    #endregion
    2942
     
    3144      : base(original, cloner) {
    3245    }
     46
    3347    public override IDeepCloneable Clone(Cloner cloner) {
    3448      return new SymbolicClassificationPruningOperator(this, cloner);
     
    4458
    4559    protected override ISymbolicDataAnalysisModel CreateModel() {
    46       var model = ModelCreator.CreateSymbolicClassificationModel(SymbolicExpressionTree, Interpreter, EstimationLimits.Lower, EstimationLimits.Upper);
    47       var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size);
     60      var model = ModelCreatorParameter.ActualValue.CreateSymbolicClassificationModel(SymbolicExpressionTree, Interpreter, EstimationLimits.Lower, EstimationLimits.Upper);
    4861      var problemData = (IClassificationProblemData)ProblemData;
     62      var rows = problemData.TrainingIndices;
    4963      model.RecalculateModelParameters(problemData, rows);
    5064      return model;
     
    5468      var classificationModel = (IClassificationModel)model;
    5569      var classificationProblemData = (IClassificationProblemData)ProblemData;
    56       var trainingIndices = ProblemData.TrainingIndices.ToList();
     70      var trainingIndices = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size);
    5771      var estimatedValues = classificationModel.GetEstimatedClassValues(ProblemData.Dataset, trainingIndices);
    5872      var targetValues = ProblemData.Dataset.GetDoubleValues(classificationProblemData.TargetVariable, trainingIndices);
    5973      OnlineCalculatorError errorState;
    60       var quality = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);
     74      var quality = OnlineAccuracyCalculator.Calculate(targetValues, estimatedValues, out errorState);
    6175      if (errorState != OnlineCalculatorError.None) return double.NaN;
    6276      return quality;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolutionImpactValuesCalculator.cs

    r10281 r11145  
    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.Classification {
     30  [StorableClass]
     31  [Item("SymbolicClassificationSolutionImpactValuesCalculator", "Calculate symbolic expression tree node impact values for classification problems.")]
    2732  public class SymbolicClassificationSolutionImpactValuesCalculator : SymbolicDataAnalysisSolutionImpactValuesCalculator {
     33    public SymbolicClassificationSolutionImpactValuesCalculator() { }
     34    protected SymbolicClassificationSolutionImpactValuesCalculator(SymbolicClassificationSolutionImpactValuesCalculator original, Cloner cloner)
     35      : base(original, cloner) { }
     36    public override IDeepCloneable Clone(Cloner cloner) {
     37      return new SymbolicClassificationSolutionImpactValuesCalculator(this, cloner);
     38    }
     39    [StorableConstructor]
     40    protected SymbolicClassificationSolutionImpactValuesCalculator(bool deserializing) : base(deserializing) { }
     41
    2842    public override double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows) {
    2943      var classificationModel = (ISymbolicClassificationModel)model;
     
    3448
    3549    public override double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN) {
     50      double impactValue, replacementValue;
     51      CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, originalQuality);
     52      return impactValue;
     53    }
     54
     55    public override void CalculateImpactAndReplacementValues(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node,
     56      IDataAnalysisProblemData problemData, IEnumerable<int> rows, out double impactValue, out double replacementValue,
     57      double originalQuality = Double.NaN) {
    3658      var classificationModel = (ISymbolicClassificationModel)model;
    3759      var classificationProblemData = (IClassificationProblemData)problemData;
     
    4769      }
    4870
    49       var replacementValue = CalculateReplacementValue(classificationModel, node, classificationProblemData, rows);
     71      replacementValue = CalculateReplacementValue(classificationModel, node, classificationProblemData, rows);
    5072      var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue };
    5173
     
    6385      if (errorState != OnlineCalculatorError.None) newQuality = 0.0;
    6486
    65       return originalQuality - newQuality;
     87      impactValue = originalQuality - newQuality;
    6688    }
    67 
    6889  }
    6990}
Note: See TracChangeset for help on using the changeset viewer.