- Timestamp:
- 11/21/11 19:08:06 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.csproj
r6866 r7028 117 117 </Compile> 118 118 <Compile Include="Plugin.cs" /> 119 <Compile Include="SymbolicDataAnalysisSolutionResponseFunctionView.cs"> 120 <SubType>UserControl</SubType> 121 </Compile> 122 <Compile Include="SymbolicDataAnalysisSolutionResponseFunctionView.Designer.cs"> 123 <DependentUpon>SymbolicDataAnalysisSolutionResponseFunctionView.cs</DependentUpon> 124 </Compile> 119 125 <Compile Include="SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs"> 120 126 <SubType>UserControl</SubType> … … 128 134 <Compile Include="SymbolicRegressionSolutionView.Designer.cs"> 129 135 <DependentUpon>SymbolicRegressionSolutionView.cs</DependentUpon> 136 </Compile> 137 <Compile Include="VariableTrackbar.cs"> 138 <SubType>UserControl</SubType> 139 </Compile> 140 <Compile Include="VariableTrackbar.Designer.cs"> 141 <DependentUpon>VariableTrackbar.cs</DependentUpon> 130 142 </Compile> 131 143 <None Include="HeuristicLab.snk" /> … … 262 274 <Install>true</Install> 263 275 </BootstrapperPackage> 276 </ItemGroup> 277 <ItemGroup> 278 <EmbeddedResource Include="SymbolicDataAnalysisSolutionResponseFunctionView.resx"> 279 <DependentUpon>SymbolicDataAnalysisSolutionResponseFunctionView.cs</DependentUpon> 280 </EmbeddedResource> 264 281 </ItemGroup> 265 282 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicDataAnalysisSolutionResponseFunctionView.Designer.cs
r7020 r7028 20 20 #endregion 21 21 22 namespace HeuristicLab.Problems.DataAnalysis.Symbolic. Views {22 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 23 23 partial class SymbolicDataAnalysisSolutionResponseFunctionView { 24 24 /// <summary> … … 48 48 System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); 49 49 System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); 50 System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); 51 System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); 52 System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series(); 53 System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series(); 50 54 this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); 51 55 this.responseChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); … … 80 84 this.responseChart.Name = "responseChart"; 81 85 series1.ChartArea = "ChartArea"; 82 series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Fast Line;86 series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint; 83 87 series1.Legend = "Legend"; 88 series1.MarkerColor = System.Drawing.Color.Gold; 84 89 series1.MarkerSize = 3; 85 series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Cross; 86 series1.Name = "Model Response"; 90 series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Diamond; 91 series1.Name = "Training Data (edge)"; 92 series2.ChartArea = "ChartArea"; 93 series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint; 94 series2.Legend = "Legend"; 95 series2.MarkerColor = System.Drawing.Color.OrangeRed; 96 series2.MarkerSize = 3; 97 series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Diamond; 98 series2.Name = "Test Data (edge)"; 99 series3.ChartArea = "ChartArea"; 100 series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint; 101 series3.Legend = "Legend"; 102 series3.MarkerColor = System.Drawing.Color.Gold; 103 series3.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Diamond; 104 series3.Name = "Training Data"; 105 series4.ChartArea = "ChartArea"; 106 series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint; 107 series4.Legend = "Legend"; 108 series4.MarkerColor = System.Drawing.Color.OrangeRed; 109 series4.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Diamond; 110 series4.Name = "Test Data"; 111 series5.BorderWidth = 3; 112 series5.ChartArea = "ChartArea"; 113 series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine; 114 series5.Color = System.Drawing.Color.DodgerBlue; 115 series5.Legend = "Legend"; 116 series5.MarkerSize = 1; 117 series5.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Cross; 118 series5.Name = "Model Response"; 119 series5.ShadowColor = System.Drawing.Color.DodgerBlue; 87 120 this.responseChart.Series.Add(series1); 121 this.responseChart.Series.Add(series2); 122 this.responseChart.Series.Add(series3); 123 this.responseChart.Series.Add(series4); 124 this.responseChart.Series.Add(series5); 88 125 this.responseChart.Size = new System.Drawing.Size(258, 166); 89 126 this.responseChart.TabIndex = 3; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicDataAnalysisSolutionResponseFunctionView.cs
r7020 r7028 30 30 using HeuristicLab.MainForm.WindowsForms; 31 31 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic. Views {32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 33 33 [View("Response Function View")] 34 [Content(typeof( RegressionSolutionBase), false)]34 [Content(typeof(ISymbolicRegressionSolution), false)] 35 35 public partial class SymbolicDataAnalysisSolutionResponseFunctionView : AsynchronousContentView { 36 36 private Dictionary<string, List<ISymbolicExpressionTreeNode>> variableNodes; … … 44 44 } 45 45 46 public new ISymbolic DataAnalysisSolution Content {47 get { return (ISymbolic DataAnalysisSolution)base.Content; }46 public new ISymbolicRegressionSolution Content { 47 get { return (ISymbolicRegressionSolution)base.Content; } 48 48 set { base.Content = value; } 49 49 } … … 122 122 constNode.Value = value; 123 123 124 Update Chart();125 } 126 127 private void Update Chart() {124 UpdateResponseSeries(); 125 } 126 127 private void UpdateScatterPlot() { 128 128 string freeVariable = (string)comboBox.SelectedItem; 129 129 IEnumerable<string> fixedVariables = comboBox.Items.OfType<string>() 130 130 .Except(new string[] { freeVariable }); 131 132 // scatter plots for subset of samples that have values near the median values for all variables 133 Func<int, bool> NearMedianValue = (r) => { 134 foreach (var fixedVar in fixedVariables) { 135 double med = medianValues[fixedVar]; 136 if (!(Content.ProblemData.Dataset.GetDoubleValue(fixedVar, r) < med + 0.1 * Math.Abs(med) && 137 Content.ProblemData.Dataset.GetDoubleValue(fixedVar, r) > med - 0.1 * Math.Abs(med))) 138 return false; 139 } 140 return true; 141 }; 142 143 var mainTrainingIndizes = (from row in Content.ProblemData.TrainingIndizes 144 where NearMedianValue(row) 145 select row) 146 .ToArray(); 147 var mainTestIndizes = (from row in Content.ProblemData.TestIndizes 148 where NearMedianValue(row) 149 select row) 150 .ToArray(); 151 152 var freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, mainTrainingIndizes).ToArray(); 153 var trainingValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, 154 mainTrainingIndizes).ToArray(); 155 Array.Sort(freeVariableValues, trainingValues); 156 responseChart.Series["Training Data"].Points.DataBindXY(freeVariableValues, trainingValues); 157 158 freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, mainTestIndizes).ToArray(); 159 var testValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, 160 mainTestIndizes).ToArray(); 161 Array.Sort(freeVariableValues, testValues); 162 responseChart.Series["Test Data"].Points.DataBindXY(freeVariableValues, testValues); 163 164 // draw scatter plots of remaining values 165 freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TrainingIndizes).ToArray(); 166 trainingValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, 167 Content.ProblemData.TrainingIndizes).ToArray(); 168 Array.Sort(freeVariableValues, trainingValues); 169 responseChart.Series["Training Data (edge)"].Points.DataBindXY(freeVariableValues, trainingValues); 170 171 freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TestIndizes).ToArray(); 172 testValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, 173 Content.ProblemData.TestIndizes).ToArray(); 174 Array.Sort(freeVariableValues, testValues); 175 responseChart.Series["Test Data (edge)"].Points.DataBindXY(freeVariableValues, testValues); 176 177 178 179 responseChart.ChartAreas[0].AxisX.Maximum = Math.Ceiling(freeVariableValues.Max()); 180 responseChart.ChartAreas[0].AxisX.Minimum = Math.Floor(freeVariableValues.Min()); 181 responseChart.ChartAreas[0].AxisY.Maximum = Math.Ceiling(Math.Max(testValues.Max(), trainingValues.Max())); 182 responseChart.ChartAreas[0].AxisY.Minimum = Math.Floor(Math.Min(testValues.Min(), trainingValues.Min())); 183 } 184 185 private void UpdateResponseSeries() { 186 string freeVariable = (string)comboBox.SelectedItem; 131 187 132 188 var freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TrainingIndizes).ToArray(); 133 189 var responseValues = Content.Model.Interpreter.GetSymbolicExpressionTreeValues(clonedTree, 134 190 Content.ProblemData.Dataset, 135 Content.ProblemData.TrainingIndizes).ToArray(); 191 Content.ProblemData.TrainingIndizes) 192 .ToArray(); 136 193 Array.Sort(freeVariableValues, responseValues); 137 194 responseChart.Series["Model Response"].Points.DataBindXY(freeVariableValues, responseValues); 195 } 196 197 private void ComboBoxSelectedIndexChanged(object sender, EventArgs e) { 198 string freeVariable = (string)comboBox.SelectedItem; 199 IEnumerable<string> fixedVariables = comboBox.Items.OfType<string>() 200 .Except(new string[] { freeVariable }); 201 202 variableNodes.Clear(); 203 clonedTree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 204 205 foreach (var varNode in clonedTree.IterateNodesPrefix().OfType<VariableTreeNode>()) { 206 if (fixedVariables.Contains(varNode.VariableName)) { 207 if (!variableNodes.ContainsKey(varNode.VariableName)) 208 variableNodes.Add(varNode.VariableName, new List<ISymbolicExpressionTreeNode>()); 209 210 int childIndex = varNode.Parent.IndexOfSubtree(varNode); 211 var replacementNode = MakeConstantTreeNode(medianValues[varNode.VariableName]); 212 var parent = varNode.Parent; 213 parent.RemoveSubtree(childIndex); 214 parent.InsertSubtree(childIndex, MakeProduct(replacementNode, varNode.Weight)); 215 variableNodes[varNode.VariableName].Add(replacementNode); 216 } 217 } 218 219 CreateSliders(fixedVariables); 220 UpdateScatterPlot(); 221 UpdateResponseSeries(); 222 } 223 224 private ISymbolicExpressionTreeNode MakeProduct(ConstantTreeNode c, double weight) { 225 var mul = new Multiplication(); 226 var prod = mul.CreateTreeNode(); 227 prod.AddSubtree(MakeConstantTreeNode(weight)); 228 prod.AddSubtree(c); 229 return prod; 138 230 } 139 231 … … 146 238 return constantTreeNode; 147 239 } 148 149 private void ComboBoxSelectedIndexChanged(object sender, EventArgs e) {150 string freeVariable = (string)comboBox.SelectedItem;151 IEnumerable<string> fixedVariables = comboBox.Items.OfType<string>()152 .Except(new string[] { freeVariable });153 154 variableNodes.Clear();155 clonedTree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone();156 157 foreach (var varNode in clonedTree.IterateNodesPrefix().OfType<VariableTreeNode>()) {158 if (fixedVariables.Contains(varNode.VariableName)) {159 if (!variableNodes.ContainsKey(varNode.VariableName))160 variableNodes.Add(varNode.VariableName, new List<ISymbolicExpressionTreeNode>());161 162 int childIndex = varNode.Parent.IndexOfSubtree(varNode);163 var replacementNode = MakeConstantTreeNode(medianValues[varNode.VariableName]);164 var parent = varNode.Parent;165 parent.RemoveSubtree(childIndex);166 parent.InsertSubtree(childIndex, replacementNode);167 variableNodes[varNode.VariableName].Add(replacementNode);168 }169 }170 171 CreateSliders(fixedVariables);172 UpdateChart();173 }174 240 } 175 241 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.Designer.cs
r7020 r7028 1 namespace HeuristicLab.Problems.DataAnalysis.Symbolic. Views {1 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 2 2 partial class VariableTrackbar { 3 3 /// <summary> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.cs
r7020 r7028 10 10 using HeuristicLab.Common; 11 11 12 namespace HeuristicLab.Problems.DataAnalysis.Symbolic. Views {12 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 13 13 public partial class VariableTrackbar : UserControl { 14 14 private readonly string variableName; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r7021 r7028 115 115 <ItemGroup> 116 116 <Compile Include="Plugin.cs" /> 117 <Compile Include="SymbolicDataAnalysisSolutionResponseFunctionView.cs">118 <SubType>UserControl</SubType>119 </Compile>120 <Compile Include="SymbolicDataAnalysisSolutionResponseFunctionView.Designer.cs">121 <DependentUpon>SymbolicDataAnalysisSolutionResponseFunctionView.cs</DependentUpon>122 </Compile>123 117 <Compile Include="TextualSymbolicDataAnalysisModelView.cs"> 124 118 <SubType>UserControl</SubType> … … 168 162 <Compile Include="Symbols\VariableView.Designer.cs"> 169 163 <DependentUpon>VariableView.cs</DependentUpon> 170 </Compile>171 <Compile Include="VariableTrackbar.cs">172 <SubType>UserControl</SubType>173 </Compile>174 <Compile Include="VariableTrackbar.Designer.cs">175 <DependentUpon>VariableTrackbar.cs</DependentUpon>176 164 </Compile> 177 165 <None Include="HeuristicLab.snk" />
Note: See TracChangeset
for help on using the changeset viewer.