Changeset 8954 for branches/SlaveShutdown/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views
- Timestamp:
- 11/27/12 20:09:33 (11 years ago)
- Location:
- branches/SlaveShutdown
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SlaveShutdown
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 8946-8948,8950,8952
- Property svn:mergeinfo changed
-
branches/SlaveShutdown/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views merged eligible /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views merged eligible /branches/Algorithms.GradientDescent/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5516-5520 /branches/Benchmarking/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 6917-7005 /branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5815-6180 /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 4458-4459,4462,4464 /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5060 /branches/NET40/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5138-5162 /branches/ParallelEngine/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 6828 /branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 7787-8333 /branches/SuccessProgressAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5370-5682 /branches/Trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 6829-6865 /branches/VNS/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5594-5752 /branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/SlaveShutdown/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierView.cs
r8636 r8954 30 30 } 31 31 32 public InteractiveSymbolicClassificationSolutionSimplifierView() : base() { } 32 public InteractiveSymbolicClassificationSolutionSimplifierView() 33 : base() { 34 InitializeComponent(); 35 this.Caption = "Interactive Classification Solution Simplifier"; 36 } 33 37 34 38 protected override void UpdateModel(ISymbolicExpressionTree tree) { -
branches/SlaveShutdown/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierViewBase.cs
r8727 r8954 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views { 30 30 public abstract partial class InteractiveSymbolicClassificationSolutionSimplifierViewBase : InteractiveSymbolicDataAnalysisSolutionSimplifierView { 31 private readonly ConstantTreeNode constantNode; 32 private readonly SymbolicExpressionTree tempTree; 31 private readonly SymbolicClassificationSolutionImpactValuesCalculator calculator; 33 32 34 33 public new ISymbolicClassificationSolution Content { … … 42 41 this.Caption = "Interactive Classification Solution Simplifier"; 43 42 44 constantNode = ((ConstantTreeNode)new Constant().CreateTreeNode()); 45 ISymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode(); 46 ISymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode(); 47 root.AddSubtree(start); 48 tempTree = new SymbolicExpressionTree(root); 43 calculator = new SymbolicClassificationSolutionImpactValuesCalculator(); 49 44 } 50 45 … … 66 61 67 62 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) { 68 Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>(); 69 foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) { 70 replacementValues[node] = CalculateReplacementValue(node, tree); 71 } 72 return replacementValues; 63 return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary( 64 n => n, 65 n => calculator.CalculateReplacementValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices) 66 ); 73 67 } 74 68 75 69 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) { 76 var model = Content.Model; 77 var dataset = Content.ProblemData.Dataset; 78 var rows = Content.ProblemData.TrainingIndices; 79 string targetVariable = Content.ProblemData.TargetVariable; 80 Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>(); 81 List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList(); 82 83 var targetClassValues = dataset.GetDoubleValues(targetVariable, rows); 84 var originalClassValues = model.GetEstimatedClassValues(dataset, rows); 85 OnlineCalculatorError errorState; 86 double originalAccuracy = OnlineAccuracyCalculator.Calculate(targetClassValues, originalClassValues, out errorState); 87 if (errorState != OnlineCalculatorError.None) originalAccuracy = 0.0; 88 89 foreach (ISymbolicExpressionTreeNode node in nodes) { 90 var parent = node.Parent; 91 constantNode.Value = CalculateReplacementValue(node, tree); 92 ISymbolicExpressionTreeNode replacementNode = constantNode; 93 SwitchNode(parent, node, replacementNode); 94 var newModel = CreateModel(tree); 95 var newClassValues = newModel.GetEstimatedClassValues(dataset, rows); 96 double newAccuracy = OnlineAccuracyCalculator.Calculate(targetClassValues, newClassValues, out errorState); 97 if (errorState != OnlineCalculatorError.None) newAccuracy = 0.0; 98 99 // impact = 0 if no change 100 // impact < 0 if new solution is better 101 // impact > 0 if new solution is worse 102 impactValues[node] = originalAccuracy - newAccuracy; 103 SwitchNode(parent, replacementNode, node); 104 } 105 return impactValues; 106 } 107 108 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) { 109 // remove old ADFs 110 while (tempTree.Root.SubtreeCount > 1) tempTree.Root.RemoveSubtree(1); 111 // clone ADFs of source tree 112 for (int i = 1; i < sourceTree.Root.SubtreeCount; i++) { 113 tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone()); 114 } 115 var start = tempTree.Root.GetSubtree(0); 116 while (start.SubtreeCount > 0) start.RemoveSubtree(0); 117 start.AddSubtree((ISymbolicExpressionTreeNode)node.Clone()); 118 var interpreter = Content.Model.Interpreter; 119 var rows = Content.ProblemData.TrainingIndices; 120 return interpreter.GetSymbolicExpressionTreeValues(tempTree, Content.ProblemData.Dataset, rows) 121 .LimitToRange(Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit).Median(); 122 } 123 124 125 private void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) { 126 for (int i = 0; i < root.SubtreeCount; i++) { 127 if (root.GetSubtree(i) == oldBranch) { 128 root.RemoveSubtree(i); 129 root.InsertSubtree(i, newBranch); 130 return; 131 } 132 } 70 return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary( 71 n => n, 72 n => calculator.CalculateImpactValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices, Content.TrainingAccuracy) 73 ); 133 74 } 134 75 -
branches/SlaveShutdown/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs
r8636 r8954 24 24 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views { 25 25 public partial class InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView : InteractiveSymbolicClassificationSolutionSimplifierViewBase { 26 27 26 public new SymbolicDiscriminantFunctionClassificationSolution Content { 28 27 get { return (SymbolicDiscriminantFunctionClassificationSolution)base.Content; } … … 30 29 } 31 30 32 public InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView() : base() { } 31 public InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView() 32 : base() { 33 InitializeComponent(); 34 this.Caption = "Interactive Classification Solution Simplifier"; 35 } 33 36 34 37 protected override void UpdateModel(ISymbolicExpressionTree tree) { 35 38 var model = CreateModel(tree); 36 model.RecalculateModelParameters(Content.ProblemData, Content.ProblemData.TrainingIndices);37 39 Content.Model = (ISymbolicDiscriminantFunctionClassificationModel)model; 38 40 }
Note: See TracChangeset
for help on using the changeset viewer.