- Timestamp:
- 07/08/14 19:29:00 (10 years ago)
- Location:
- stable
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 10368,10375,10378,10414,10417-10418,10428,10469-10470,11013,11025-11027
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification merged: 10368,10375,10378,10418,10469,11025-11026
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj
r9288 r11145 120 120 <Compile Include="ModelCreators\NormalDistributedThresholdsModelCreator.cs" /> 121 121 <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer.cs" /> 122 <Compile Include="SymbolicClassificationPruningAnalyzer.cs" /> 122 123 <Compile Include="SymbolicClassificationSolutionImpactValuesCalculator.cs" /> 123 124 <Compile Include="SymbolicNearestNeighbourClassificationModel.cs" /> … … 149 150 <SubType>Code</SubType> 150 151 </Compile> 152 <Compile Include="SymbolicClassificationPruningOperator.cs" /> 151 153 <None Include="HeuristicLab.snk" /> 152 154 <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 2 22 using HeuristicLab.Common; 3 23 using HeuristicLab.Core; 4 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;5 24 using HeuristicLab.Parameters; 6 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 10 29 [StorableClass] 11 30 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) 26 34 : base(original, cloner) { 27 35 } … … 30 38 } 31 39 40 [StorableConstructor] 41 private SymbolicClassificationPruningAnalyzer(bool deserializing) : base(deserializing) { } 42 32 43 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())); 44 46 } 45 47 } -
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 24 using System.Linq; 2 25 using HeuristicLab.Common; 3 26 using HeuristicLab.Core; 4 using HeuristicLab.Data;5 27 using HeuristicLab.Parameters; 6 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 12 34 private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator"; 13 35 private const string ModelCreatorParameterName = "ModelCreator"; 14 private const string ApplyLinearScalingParmameterName = "ApplyLinearScaling";15 36 16 37 #region parameter properties … … 18 39 get { return (ILookupParameter<ISymbolicClassificationModelCreator>)Parameters[ModelCreatorParameterName]; } 19 40 } 20 21 public ILookupParameter<BoolValue> ApplyLinearScalingParameter {22 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParmameterName]; }23 }24 #endregion25 #region properties26 private ISymbolicClassificationModelCreator ModelCreator { get { return ModelCreatorParameter.ActualValue; } }27 private BoolValue ApplyLinearScaling { get { return ApplyLinearScalingParameter.ActualValue; } }28 41 #endregion 29 42 … … 31 44 : base(original, cloner) { 32 45 } 46 33 47 public override IDeepCloneable Clone(Cloner cloner) { 34 48 return new SymbolicClassificationPruningOperator(this, cloner); … … 44 58 45 59 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); 48 61 var problemData = (IClassificationProblemData)ProblemData; 62 var rows = problemData.TrainingIndices; 49 63 model.RecalculateModelParameters(problemData, rows); 50 64 return model; … … 54 68 var classificationModel = (IClassificationModel)model; 55 69 var classificationProblemData = (IClassificationProblemData)ProblemData; 56 var trainingIndices = ProblemData.TrainingIndices.ToList();70 var trainingIndices = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size); 57 71 var estimatedValues = classificationModel.GetEstimatedClassValues(ProblemData.Dataset, trainingIndices); 58 72 var targetValues = ProblemData.Dataset.GetDoubleValues(classificationProblemData.TargetVariable, trainingIndices); 59 73 OnlineCalculatorError errorState; 60 var quality = Online PearsonsRSquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);74 var quality = OnlineAccuracyCalculator.Calculate(targetValues, estimatedValues, out errorState); 61 75 if (errorState != OnlineCalculatorError.None) return double.NaN; 62 76 return quality; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolutionImpactValuesCalculator.cs
r10281 r11145 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 28 26 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { 30 [StorableClass] 31 [Item("SymbolicClassificationSolutionImpactValuesCalculator", "Calculate symbolic expression tree node impact values for classification problems.")] 27 32 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 28 42 public override double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows) { 29 43 var classificationModel = (ISymbolicClassificationModel)model; … … 34 48 35 49 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) { 36 58 var classificationModel = (ISymbolicClassificationModel)model; 37 59 var classificationProblemData = (IClassificationProblemData)problemData; … … 47 69 } 48 70 49 varreplacementValue = CalculateReplacementValue(classificationModel, node, classificationProblemData, rows);71 replacementValue = CalculateReplacementValue(classificationModel, node, classificationProblemData, rows); 50 72 var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue }; 51 73 … … 63 85 if (errorState != OnlineCalculatorError.None) newQuality = 0.0; 64 86 65 returnoriginalQuality - newQuality;87 impactValue = originalQuality - newQuality; 66 88 } 67 68 89 } 69 90 }
Note: See TracChangeset
for help on using the changeset viewer.