- Timestamp:
- 03/16/11 16:34:31 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring
- Files:
-
- 4 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj
r5694 r5717 128 128 <DependentUpon>SupportVectorMachineModelView.cs</DependentUpon> 129 129 </Compile> 130 <Compile Include="SupportVectorRegressionSolutionView.cs" /> 130 <Compile Include="SupportVectorRegressionSolutionView.cs"> 131 <SubType>UserControl</SubType> 132 </Compile> 131 133 <Compile Include="SupportVectorRegressionSolutionView.Designer.cs"> 132 134 <DependentUpon>SupportVectorRegressionSolutionView.cs</DependentUpon> -
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/ISupportVectorMachineModel.cs
r5694 r5717 29 29 /// Interface to represent a support vector machine model 30 30 /// </summary> 31 public interface ISupportVectorMachineModel : IDataAnalysisModel {31 public interface ISupportVectorMachineModel : IDataAnalysisModel, IRegressionModel, IClassificationModel { 32 32 SVM.Model Model { get; } 33 33 SVM.RangeTransform RangeTransform { get; } -
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/ISupportVectorMachineSolution.cs
r5694 r5717 29 29 /// </summary> 30 30 public interface ISupportVectorMachineSolution : IDataAnalysisSolution { 31 ISupportVectorMachineModel Model { get; }31 new ISupportVectorMachineModel Model { get; } 32 32 } 33 33 } -
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorClassificationSolution.cs
r5694 r5717 39 39 public new ISupportVectorMachineModel Model { 40 40 get { return (ISupportVectorMachineModel)base.Model; } 41 set { base.Model = value; } 41 42 } 42 43 -
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs
r5694 r5717 38 38 [StorableClass] 39 39 [Item("SupportVectorMachineModel", "Represents a support vector machine model.")] 40 public sealed class SupportVectorMachineModel : NamedItem, ISupportVectorMachineModel , IRegressionModel, IClassificationModel{40 public sealed class SupportVectorMachineModel : NamedItem, ISupportVectorMachineModel { 41 41 42 42 private SVM.Model model; -
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegressionSolution.cs
r5694 r5717 39 39 public new ISupportVectorMachineModel Model { 40 40 get { return (ISupportVectorMachineModel)base.Model; } 41 set { base.Model = value; } 41 42 } 42 43 -
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClusteringSolution.cs
r5651 r5717 42 42 public new KMeansClusteringModel Model { 43 43 get { return (KMeansClusteringModel)base.Model; } 44 set { base.Model = value; } 44 45 } 45 46 -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.csproj
r5699 r5717 110 110 </ItemGroup> 111 111 <ItemGroup> 112 <Compile Include="SymbolicDiscriminantFunctionClassificationSolutionView.cs"> 113 <SubType>UserControl</SubType> 114 </Compile> 115 <Compile Include="SymbolicDiscriminantFunctionClassificationSolutionView.Designer.cs"> 116 <DependentUpon>SymbolicDiscriminantFunctionClassificationSolutionView.cs</DependentUpon> 117 </Compile> 112 118 <None Include="HeuristicLab.snk" /> 113 119 <None Include="HeuristicLabProblemsDataAnalysisSymbolicClassificationViewsPlugin.cs.frame" /> 114 120 <None Include="Properties\AssemblyInfo.frame" /> 115 121 <Compile Include="HeuristicLabProblemsDataAnalysisSymbolicClassificationViewsPlugin.cs" /> 122 <Compile Include="InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs"> 123 <SubType>UserControl</SubType> 124 </Compile> 125 <Compile Include="InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.Designer.cs"> 126 <DependentUpon>InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs</DependentUpon> 127 </Compile> 116 128 <Compile Include="Properties\AssemblyInfo.cs" /> 117 129 </ItemGroup> … … 141 153 <Name>HeuristicLab.Data-3.3</Name> 142 154 </ProjectReference> 155 <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj"> 156 <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project> 157 <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name> 158 </ProjectReference> 143 159 <ProjectReference Include="..\..\HeuristicLab.ExtLibs\HeuristicLab.ALGLIB\3.1.0\ALGLIB-3.1.0\ALGLIB-3.1.0.csproj"> 144 160 <Project>{FC841674-62A7-4055-BE91-E41944B6C606}</Project> … … 176 192 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 177 193 <Name>HeuristicLab.PluginInfrastructure-3.3</Name> 194 </ProjectReference> 195 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj"> 196 <Project>{05BAE4E1-A9FA-4644-AA77-42558720159E}</Project> 197 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4</Name> 198 </ProjectReference> 199 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj"> 200 <Project>{7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086}</Project> 201 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4</Name> 202 </ProjectReference> 203 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj"> 204 <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project> 205 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name> 206 </ProjectReference> 207 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Views\3.4\HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj"> 208 <Project>{3E9E8944-44FF-40BB-A622-3A4A7DD0F198}</Project> 209 <Name>HeuristicLab.Problems.DataAnalysis.Views-3.4</Name> 178 210 </ProjectReference> 179 211 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj"> -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj
r5685 r5717 112 112 <Compile Include="SingleObjective\SymbolicClassificationSingleObjectiveValidationBestSolutionAnalyzer.cs" /> 113 113 <Compile Include="SymbolicDiscriminantFunctionClassificationModel.cs" /> 114 <Compile Include="SymbolicDiscriminantFunctionClassificationSolution.cs" />115 114 <Compile Include="Interfaces\ISymbolicClassificationModel.cs" /> 116 115 <Compile Include="Interfaces\ISymbolicClassificationSolution.cs" /> … … 130 129 </Compile> 131 130 <Compile Include="SymbolicClassificationSolution.cs" /> 131 <Compile Include="SymbolicDiscriminantFunctionClassificationSolution.cs"> 132 <SubType>Code</SubType> 133 </Compile> 132 134 <None Include="HeuristicLab.snk" /> 133 135 <None Include="HeuristicLabProblemsDataAnalysisSymbolicClassificationPlugin.cs.frame" /> -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/Interfaces/ISymbolicDiscriminantFunctionClassificationModel.cs
r5649 r5717 22 22 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 23 23 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { 24 public interface ISymbolicDiscriminantFunctionClassificationModel : IDiscriminantFunctionClassificationModel, ISymbolic DataAnalysisModel {24 public interface ISymbolicDiscriminantFunctionClassificationModel : IDiscriminantFunctionClassificationModel, ISymbolicClassificationModel { 25 25 } 26 26 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolution.cs
r5624 r5717 38 38 [StorableClass] 39 39 [Item(Name = "SymbolicClassificationSolution", Description = "Represents a symbolic classification solution (model + data) and attributes of the solution like accuracy and complexity.")] 40 public class SymbolicClassificationSolution : ClassificationSolution, ISymbolicClassificationSolution {40 public sealed class SymbolicClassificationSolution : ClassificationSolution, ISymbolicClassificationSolution { 41 41 #region ISymbolicClassificationSolution Members 42 42 43 43 public new ISymbolicClassificationModel Model { 44 44 get { return (ISymbolicClassificationModel)base.Model; } 45 set { base.Model = value; } 45 46 } 46 47 … … 51 52 #endregion 52 53 [StorableConstructor] 53 pr otectedSymbolicClassificationSolution(bool deserializing) : base(deserializing) { }54 pr otectedSymbolicClassificationSolution(SymbolicClassificationSolution original, Cloner cloner)54 private SymbolicClassificationSolution(bool deserializing) : base(deserializing) { } 55 private SymbolicClassificationSolution(SymbolicClassificationSolution original, Cloner cloner) 55 56 : base(original, cloner) { 56 57 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationSolution.cs
r5678 r5717 38 38 [StorableClass] 39 39 [Item(Name = "SymbolicDiscriminantFunctionClassificationSolution", Description = "Represents a symbolic classification solution (model + data) and attributes of the solution like accuracy and complexity.")] 40 public class SymbolicDiscriminantFunctionClassificationSolution : DiscriminantFunctionClassificationSolution, ISymbolicClassificationSolution { 41 #region ISymbolicClassificationSolution Members 40 public sealed class SymbolicDiscriminantFunctionClassificationSolution : DiscriminantFunctionClassificationSolution, ISymbolicClassificationSolution { 42 41 43 public new IDiscriminantFunctionClassificationModel Model { 44 get { return (IDiscriminantFunctionClassificationModel)base.Model; } 42 public new ISymbolicDiscriminantFunctionClassificationModel Model { 43 get { return (ISymbolicDiscriminantFunctionClassificationModel)base.Model; } 44 set { base.Model = value; } 45 45 } 46 46 47 47 ISymbolicClassificationModel ISymbolicClassificationSolution.Model { 48 get { return (ISymbolicClassificationModel)Model; }48 get { return Model; } 49 49 } 50 50 51 51 ISymbolicDataAnalysisModel ISymbolicDataAnalysisSolution.Model { 52 get { return (ISymbolicDataAnalysisModel)Model; }52 get { return Model; } 53 53 } 54 54 55 #endregion56 55 [StorableConstructor] 57 pr otectedSymbolicDiscriminantFunctionClassificationSolution(bool deserializing) : base(deserializing) { }58 pr otectedSymbolicDiscriminantFunctionClassificationSolution(SymbolicDiscriminantFunctionClassificationSolution original, Cloner cloner)56 private SymbolicDiscriminantFunctionClassificationSolution(bool deserializing) : base(deserializing) { } 57 private SymbolicDiscriminantFunctionClassificationSolution(SymbolicDiscriminantFunctionClassificationSolution original, Cloner cloner) 59 58 : base(original, cloner) { 60 59 } 61 public SymbolicDiscriminantFunctionClassificationSolution(I DiscriminantFunctionClassificationModel model, IClassificationProblemData problemData)60 public SymbolicDiscriminantFunctionClassificationSolution(ISymbolicDiscriminantFunctionClassificationModel model, IClassificationProblemData problemData) 62 61 : base(model, problemData) { 63 62 } … … 65 64 public override IDeepCloneable Clone(Cloner cloner) { 66 65 return new SymbolicDiscriminantFunctionClassificationSolution(this, cloner); 67 } 66 } 68 67 } 69 68 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r5699 r5717 34 34 private readonly ConstantTreeNode constantNode; 35 35 private readonly SymbolicExpressionTree tempTree; 36 37 public new SymbolicRegressionSolution Content { 38 get { return (SymbolicRegressionSolution)base.Content; } 39 set { base.Content = value; } 40 } 41 36 42 public InteractiveSymbolicRegressionSolutionSimplifierView() 37 43 : base() { … … 46 52 } 47 53 48 public new ISymbolicRegressionSolution Content { 49 get { return (ISymbolicRegressionSolution)base.Content; } 50 set { base.Content = value; } 54 protected override void UpdateModel(ISymbolicExpressionTree tree) { 55 Content.Model = new SymbolicRegressionModel(tree, Content.Model.Interpreter); 51 56 } 52 57 53 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolic DataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) {58 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) { 54 59 Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>(); 55 60 foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) { 56 61 if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) { 57 replacementValues[node] = CalculateReplacementValue(node , interpreter, dataset, rows);62 replacementValues[node] = CalculateReplacementValue(node); 58 63 } 59 64 } … … 61 66 } 62 67 63 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) { 68 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) { 69 var interpreter = Content.Model.Interpreter; 70 var dataset = Content.ProblemData.Dataset; 71 var rows = Content.ProblemData.TrainingIndizes; 72 string targetVariable = Content.ProblemData.TargetVariable; 64 73 Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>(); 65 74 List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubTree(0).GetSubTree(0).IterateNodesPostfix().ToList(); 66 75 var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows) 67 76 .ToArray(); 77 var targetValues = dataset.GetEnumeratedVariableValues(targetVariable, rows); 78 79 double originalR2 = OnlinePearsonsRSquaredEvaluator.Calculate(targetValues, originalOutput); 68 80 69 81 foreach (ISymbolicExpressionTreeNode node in nodes) { 70 82 var parent = node.Parent; 71 constantNode.Value = CalculateReplacementValue(node , interpreter, dataset, rows);83 constantNode.Value = CalculateReplacementValue(node); 72 84 ISymbolicExpressionTreeNode replacementNode = constantNode; 73 85 SwitchNode(parent, node, replacementNode); 74 var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).ToArray(); 86 var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows); 87 double newR2 = OnlinePearsonsRSquaredEvaluator.Calculate(targetValues, newOutput); 75 88 76 impactValues[node] = 1 - OnlinePearsonsRSquaredEvaluator.Calculate(originalOutput, newOutput); 89 // impact = 0 if no change 90 // impact < 0 if new solution is better 91 // impact > 0 if new solution is worse 92 impactValues[node] = originalR2 - newR2; 77 93 SwitchNode(parent, replacementNode, node); 78 94 } … … 80 96 } 81 97 82 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node , ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, Dataset dataset, IEnumerable<int> rows) {98 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node) { 83 99 var start = tempTree.Root.GetSubTree(0); 84 100 while (start.SubTrees.Count() > 0) start.RemoveSubTree(0); 85 101 start.AddSubTree((ISymbolicExpressionTreeNode)node.Clone()); 102 var interpreter = Content.Model.Interpreter; 103 var rows = Content.ProblemData.TrainingIndizes; 86 104 return interpreter.GetSymbolicExpressionTreeValues(tempTree, Content.ProblemData.Dataset, rows).Median(); 87 105 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs
r5699 r5717 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 28 [Content(typeof( ISymbolicRegressionSolution))]28 [Content(typeof(SymbolicRegressionSolution))] 29 29 [View("Symbolic Regression Solution View")] 30 30 public partial class SymbolicRegressionSolutionView : DataAnalysisSolutionView { … … 33 33 } 34 34 35 protected new ISymbolicRegressionSolution Content {36 get { return ( ISymbolicRegressionSolution)base.Content; }35 protected new SymbolicRegressionSolution Content { 36 get { return (SymbolicRegressionSolution)base.Content; } 37 37 set { base.Content = value; } 38 38 } … … 40 40 private void btn_SimplifyModel_Click(object sender, EventArgs e) { 41 41 InteractiveSymbolicRegressionSolutionSimplifierView view = new InteractiveSymbolicRegressionSolutionSimplifierView(); 42 view.Content = ( ISymbolicRegressionSolution)this.Content.Clone();42 view.Content = (SymbolicRegressionSolution)this.Content.Clone(); 43 43 view.Show(); 44 44 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r5624 r5717 38 38 [StorableClass] 39 39 [Item(Name = "SymbolicRegressionSolution", Description = "Represents a symbolic regression solution (model + data) and attributes of the solution like accuracy and complexity.")] 40 public class SymbolicRegressionSolution : RegressionSolution, ISymbolicRegressionSolution {40 public sealed class SymbolicRegressionSolution : RegressionSolution, ISymbolicRegressionSolution { 41 41 #region ISymbolicRegressionSolution Members 42 42 43 43 public new ISymbolicRegressionModel Model { 44 44 get { return (ISymbolicRegressionModel)base.Model; } 45 set { base.Model = value; } 45 46 } 46 47 ISymbolicDataAnalysisModel ISymbolicDataAnalysisSolution.Model { … … 51 52 52 53 [StorableConstructor] 53 pr otectedSymbolicRegressionSolution(bool deserializing) : base(deserializing) { }54 pr otectedSymbolicRegressionSolution(SymbolicRegressionSolution original, Cloner cloner)54 private SymbolicRegressionSolution(bool deserializing) : base(deserializing) { } 55 private SymbolicRegressionSolution(SymbolicRegressionSolution original, Cloner cloner) 55 56 : base(original, cloner) { 56 57 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r5699 r5717 88 88 simplifiedExpressionTree = simplifier.Simplify(Content.Model.SymbolicExpressionTree); 89 89 90 var replacementValues = CalculateReplacementValues( Content.Model.Interpreter, simplifiedExpressionTree, Content.ProblemData.Dataset, Content.ProblemData.TrainingIndizes);90 var replacementValues = CalculateReplacementValues(simplifiedExpressionTree); 91 91 foreach (var pair in replacementValues) { 92 92 replacementNodes.Add(pair.Key, MakeConstantTreeNode(pair.Value)); 93 93 } 94 nodeImpacts = CalculateImpactValues( Content.Model.Interpreter, simplifiedExpressionTree, Content.ProblemData.Dataset, Content.ProblemData.TrainingIndizes);94 nodeImpacts = CalculateImpactValues(simplifiedExpressionTree); 95 95 96 96 // automatically fold all branches with impact = 1 … … 110 110 } 111 111 112 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows); 113 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows); 112 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree); 113 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree); 114 protected abstract void UpdateModel(ISymbolicExpressionTree tree); 114 115 115 116 private ConstantTreeNode MakeConstantTreeNode(double value) { … … 137 138 138 139 SymbolicExpressionTree tree = (SymbolicExpressionTree)simplifiedExpressionTree.Clone(); 139 140 //this.Content.ModelChanged -= new EventHandler(Content_ModelChanged); 141 //this.Content.Model = new SymbolicRegressionModel(Content.Model.Interpreter, tree); 142 //this.Content.ModelChanged += new EventHandler(Content_ModelChanged); 143 140 UpdateModel(tree); 144 141 this.PaintNodeImpacts(); 145 142 } … … 166 163 VisualSymbolicExpressionTreeNode visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode); 167 164 168 //if (impact < 1.0) { 169 // visualTree.FillColor = Color.FromArgb((int)((1.0 - impact) * 255), Color.Red); 170 //} else { 171 visualTree.FillColor = Color.FromArgb((int)((impact - 1.0) / max * 255), Color.Green); 172 //} 165 // impact = 0 if no change 166 // impact < 0 if new solution is better 167 // impact > 0 if new solution is worse 168 if (impact < 0.0) { 169 visualTree.FillColor = Color.FromArgb((int)(impact / min * 255), Color.Red); 170 } else { 171 visualTree.FillColor = Color.FromArgb((int)(impact / max * 255), Color.Green); 172 } 173 173 visualTree.ToolTip += Environment.NewLine + "Node impact: " + impact; 174 174 visualTree.ToolTip += Environment.NewLine + "Replacement value: " + replacementValue; -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModel.cs
r5649 r5717 35 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 36 36 /// <summary> 37 /// Abstract base class symbolic data analysis models37 /// Abstract base class for symbolic data analysis models 38 38 /// </summary> 39 39 [StorableClass] -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionView.cs
r5664 r5717 87 87 Content.ModelChanged += new EventHandler(Content_ModelChanged); 88 88 Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged); 89 Content.ThresholdsChanged += new EventHandler(Content_ThresholdsChanged);90 89 } 91 90 protected override void DeregisterContentEvents() { … … 93 92 Content.ModelChanged -= new EventHandler(Content_ModelChanged); 94 93 Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged); 95 Content.ThresholdsChanged -= new EventHandler(Content_ThresholdsChanged);96 94 } 97 95 … … 168 166 chart.Annotations.Clear(); 169 167 int classIndex = 1; 170 foreach (double threshold in Content. Thresholds) {168 foreach (double threshold in Content.Model.Thresholds) { 171 169 if (!double.IsInfinity(threshold)) { 172 170 HorizontalLineAnnotation annotation = new HorizontalLineAnnotation(); … … 235 233 private void chart_AnnotationPositionChanging(object sender, AnnotationPositionChangingEventArgs e) { 236 234 int classIndex = (int)e.Annotation.Tag; 237 double[] thresholds = Content. Thresholds.ToArray();235 double[] thresholds = Content.Model.Thresholds.ToArray(); 238 236 double max = thresholds[classIndex + 1]; 239 237 double min = thresholds[classIndex - 1]; … … 246 244 247 245 thresholds[classIndex] = e.NewLocationY; 248 Content. Thresholds = thresholds;246 Content.Model.Thresholds = thresholds; 249 247 } 250 248 -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClassificationEnsembleModel.cs
r5662 r5717 54 54 this.name = ItemName; 55 55 this.description = ItemDescription; 56 this.models = new List<IClassificationModel>(models); 56 this.models = new List<IClassificationModel>(models); 57 57 } 58 58 -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClassificationSolution.cs
r5649 r5717 39 39 private const string TrainingAccuracyResultName = "Accuracy (training)"; 40 40 private const string TestAccuracyResultName = "Accuracy (test)"; 41 42 public new IClassificationModel Model { 43 get { return (IClassificationModel)base.Model; } 44 protected set { base.Model = value; } 45 } 46 47 public new IClassificationProblemData ProblemData { 48 get { return (IClassificationProblemData)base.ProblemData; } 49 protected set { base.ProblemData = value; } 50 } 51 52 public double TrainingAccuracy { 53 get { return ((DoubleValue)this[TrainingAccuracyResultName].Value).Value; } 54 private set { ((DoubleValue)this[TrainingAccuracyResultName].Value).Value = value; } 55 } 56 57 public double TestAccuracy { 58 get { return ((DoubleValue)this[TestAccuracyResultName].Value).Value; } 59 private set { ((DoubleValue)this[TestAccuracyResultName].Value).Value = value; } 60 } 61 41 62 [StorableConstructor] 42 63 protected ClassificationSolution(bool deserializing) : base(deserializing) { } … … 46 67 public ClassificationSolution(IClassificationModel model, IClassificationProblemData problemData) 47 68 : base(model, problemData) { 69 Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue())); 70 Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue())); 71 RecalculateResults(); 72 } 73 74 protected override void OnProblemDataChanged(EventArgs e) { 75 base.OnProblemDataChanged(e); 76 RecalculateResults(); 77 } 78 79 protected override void OnModelChanged(EventArgs e) { 80 base.OnModelChanged(e); 81 RecalculateResults(); 82 } 83 84 private void RecalculateResults() { 48 85 double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values 49 86 IEnumerable<double> originalTrainingClassValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); … … 54 91 double testAccuracy = OnlineAccuracyEvaluator.Calculate(estimatedTestClassValues, originalTestClassValues); 55 92 56 Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue(trainingAccuracy))); 57 Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue(testAccuracy))); 58 } 59 60 #region IClassificationSolution Members 61 62 public new IClassificationModel Model { 63 get { return (IClassificationModel)base.Model; } 64 } 65 66 public new IClassificationProblemData ProblemData { 67 get { return (IClassificationProblemData)base.ProblemData; } 93 TrainingAccuracy = trainingAccuracy; 94 TestAccuracy = testAccuracy; 68 95 } 69 96 … … 89 116 return Model.GetEstimatedClassValues(ProblemData.Dataset, rows); 90 117 } 91 #endregion92 118 } 93 119 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClusteringSolution.cs
r5649 r5717 51 51 public new IClusteringModel Model { 52 52 get { return (IClusteringModel)base.Model; } 53 set { base.Model = value; } 53 54 } 54 55 55 56 public new IClusteringProblemData ProblemData { 56 57 get { return (IClusteringProblemData)base.ProblemData; } 58 set { base.ProblemData = value; } 57 59 } 58 60 -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/DataAnalysisSolution.cs
r5649 r5717 48 48 public IDataAnalysisModel Model { 49 49 get { return (IDataAnalysisModel)this[ModelResultName].Value; } 50 //set {51 //if (this[ModelResultName].Value != value) {52 //if (value != null) {53 //this[ModelResultName].Value = value;54 //OnModelChanged(EventArgs.Empty);55 //}56 //}57 //}50 protected set { 51 if (this[ModelResultName].Value != value) { 52 if (value != null) { 53 this[ModelResultName].Value = value; 54 OnModelChanged(EventArgs.Empty); 55 } 56 } 57 } 58 58 } 59 59 60 60 public IDataAnalysisProblemData ProblemData { 61 61 get { return (IDataAnalysisProblemData)this[ProblemDataResultName].Value; } 62 //set {63 //if (this[ProblemDataResultName].Value != value) {64 //if (value != null) {65 //ProblemData.Changed -= new EventHandler(ProblemData_Changed);66 //this[ProblemDataResultName].Value = value;67 //ProblemData.Changed += new EventHandler(ProblemData_Changed);68 //OnProblemDataChanged(EventArgs.Empty);69 //}70 //}71 //}62 protected set { 63 if (this[ProblemDataResultName].Value != value) { 64 if (value != null) { 65 ProblemData.Changed -= new EventHandler(ProblemData_Changed); 66 this[ProblemDataResultName].Value = value; 67 ProblemData.Changed += new EventHandler(ProblemData_Changed); 68 OnProblemDataChanged(EventArgs.Empty); 69 } 70 } 71 } 72 72 } 73 73 #endregion -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/DiscriminantFunctionClassificationSolution.cs
r5681 r5717 38 38 [Item("DiscriminantFunctionClassificationSolution", "Represents a classification solution that uses a discriminant function and classification thresholds.")] 39 39 public class DiscriminantFunctionClassificationSolution : ClassificationSolution, IDiscriminantFunctionClassificationSolution { 40 public new IDiscriminantFunctionClassificationModel Model { 41 get { return (IDiscriminantFunctionClassificationModel)base.Model; } 42 protected set { base.Model = value; } 43 } 44 40 45 [StorableConstructor] 41 46 protected DiscriminantFunctionClassificationSolution(bool deserializing) : base(deserializing) { } … … 48 53 public DiscriminantFunctionClassificationSolution(IDiscriminantFunctionClassificationModel model, IClassificationProblemData problemData) 49 54 : base(model, problemData) { 50 Model.ThresholdsChanged += new EventHandler(Model_ThresholdsChanged);51 }52 53 #region IDiscriminantFunctionClassificationSolution Members54 55 public new IDiscriminantFunctionClassificationModel Model {56 get { return (IDiscriminantFunctionClassificationModel)base.Model; }57 55 } 58 56 … … 72 70 return Model.GetEstimatedValues(ProblemData.Dataset, rows); 73 71 } 74 75 public IEnumerable<double> Thresholds {76 get {77 return Model.Thresholds;78 }79 set { Model.Thresholds = new List<double>(value); }80 }81 82 public event EventHandler ThresholdsChanged;83 84 private void Model_ThresholdsChanged(object sender, EventArgs e) {85 OnThresholdsChanged(e);86 }87 88 protected virtual void OnThresholdsChanged(EventArgs e) {89 var listener = ThresholdsChanged;90 if (listener != null) listener(this, e);91 }92 #endregion93 72 } 94 73 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationSolution.cs
r5649 r5717 31 31 IEnumerable<double> EstimatedTestClassValues { get; } 32 32 IEnumerable<double> GetEstimatedClassValues(IEnumerable<int> rows); 33 34 double TrainingAccuracy { get; } 35 double TestAccuracy { get; } 33 36 } 34 37 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionClassificationModel.cs
r5678 r5717 26 26 IEnumerable<double> Thresholds { get; set; } 27 27 IEnumerable<double> ClassValues { get; set; } 28 IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows); 29 28 30 event EventHandler ThresholdsChanged; 29 IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows);30 31 } 31 32 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionClassificationSolution.cs
r5664 r5717 30 30 IEnumerable<double> EstimatedTestValues { get; } 31 31 IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows); 32 33 IEnumerable<double> Thresholds { get; set; }34 35 event EventHandler ThresholdsChanged;36 32 } 37 33 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionSolution.cs
r5530 r5717 30 30 IEnumerable<double> EstimatedTestValues { get; } 31 31 IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows); 32 33 double TrainingMeanSquaredError { get; } 34 double TestMeanSquaredError { get; } 35 double TrainingRSquared { get; } 36 double TestRSquared { get; } 32 37 } 33 38 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/RegressionSolution.cs
r5649 r5717 44 44 private const string TestRelativeErrorResultName = "Average relative error (test)"; 45 45 46 public new IRegressionModel Model { 47 get { return (IRegressionModel)base.Model; } 48 protected set { base.Model = value; } 49 } 50 51 public new IRegressionProblemData ProblemData { 52 get { return (IRegressionProblemData)base.ProblemData; } 53 protected set { base.ProblemData = value; } 54 } 55 56 public double TrainingMeanSquaredError { 57 get { return ((DoubleValue)this[TrainingMeanSquaredErrorResultName].Value).Value; } 58 private set { ((DoubleValue)this[TrainingMeanSquaredErrorResultName].Value).Value = value; } 59 } 60 61 public double TestMeanSquaredError { 62 get { return ((DoubleValue)this[TestMeanSquaredErrorResultName].Value).Value; } 63 private set { ((DoubleValue)this[TestMeanSquaredErrorResultName].Value).Value = value; } 64 } 65 66 public double TrainingRSquared { 67 get { return ((DoubleValue)this[TrainingSquaredCorrelationResultName].Value).Value; } 68 private set { ((DoubleValue)this[TrainingSquaredCorrelationResultName].Value).Value = value; } 69 } 70 71 public double TestRSquared { 72 get { return ((DoubleValue)this[TestSquaredCorrelationResultName].Value).Value; } 73 private set { ((DoubleValue)this[TestSquaredCorrelationResultName].Value).Value = value; } 74 } 75 76 public double TrainingRelativeError { 77 get { return ((DoubleValue)this[TrainingRelativeErrorResultName].Value).Value; } 78 private set { ((DoubleValue)this[TrainingRelativeErrorResultName].Value).Value = value; } 79 } 80 81 public double TestRelativeError { 82 get { return ((DoubleValue)this[TestRelativeErrorResultName].Value).Value; } 83 private set { ((DoubleValue)this[TestRelativeErrorResultName].Value).Value = value; } 84 } 85 86 46 87 [StorableConstructor] 47 88 protected RegressionSolution(bool deserializing) : base(deserializing) { } … … 51 92 public RegressionSolution(IRegressionModel model, IRegressionProblemData problemData) 52 93 : base(model, problemData) { 94 Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue())); 95 Add(new Result(TestMeanSquaredErrorResultName, "Mean of squared errors of the model on the test partition", new DoubleValue())); 96 Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue())); 97 Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue())); 98 Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue())); 99 Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue())); 100 101 RecalculateResults(); 102 } 103 104 protected override void OnProblemDataChanged(EventArgs e) { 105 base.OnProblemDataChanged(e); 106 RecalculateResults(); 107 } 108 protected override void OnModelChanged(EventArgs e) { 109 base.OnModelChanged(e); 110 RecalculateResults(); 111 } 112 113 private void RecalculateResults() { 53 114 double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values 54 115 IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); … … 63 124 double testRelError = OnlineMeanAbsolutePercentageErrorEvaluator.Calculate(estimatedTestValues, originalTestValues); 64 125 65 Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue(trainingMSE))); 66 Add(new Result(TestMeanSquaredErrorResultName, "Mean of squared errors of the model on the test partition", new DoubleValue(testMSE))); 67 Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue(trainingR2))); 68 Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue(testR2))); 69 Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue(trainingRelError))); 70 Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue(testRelError))); 71 } 72 73 protected override void OnProblemDataChanged(EventArgs e) { 74 base.OnProblemDataChanged(e); 75 throw new NotImplementedException(); // need to recalculate results 76 } 77 protected override void OnModelChanged(EventArgs e) { 78 base.OnModelChanged(e); 79 throw new NotImplementedException(); // need to recalculate results 80 } 81 #region IRegressionSolution Members 82 83 public new IRegressionModel Model { 84 get { return (IRegressionModel)base.Model; } 85 } 86 87 public new IRegressionProblemData ProblemData { 88 get { return (IRegressionProblemData)base.ProblemData; } 126 TrainingMeanSquaredError = trainingMSE; 127 TestMeanSquaredError = testMSE; 128 TrainingRSquared = trainingR2; 129 TestRSquared = testR2; 130 TrainingRelativeError = trainingRelError; 131 TestRelativeError = testRelError; 89 132 } 90 133 … … 110 153 return Model.GetEstimatedValues(ProblemData.Dataset, rows); 111 154 } 112 #endregion113 155 } 114 156 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ThresholdCalculators/AccuracyMaximizationThresholdCalculator.cs
r5681 r5717 76 76 int[,] confusionMatrix = new int[nClasses, nClasses]; 77 77 78 // one threshold is always treated as binary separation of the remaining classes79 78 for (int i = 1; i < thresholds.Length - 1; i++) { 80 79 double lowerThreshold = thresholds[i - 1];
Note: See TracChangeset
for help on using the changeset viewer.