Changeset 12263
- Timestamp:
- 03/27/15 16:10:16 (10 years ago)
- Location:
- branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/HeuristicLab.VariableInteractionNetworks.Views-3.3.csproj
r12230 r12263 47 47 <Private>False</Private> 48 48 </Reference> 49 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 50 <SpecificVersion>False</SpecificVersion> 51 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath> 52 </Reference> 49 53 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 50 54 <SpecificVersion>False</SpecificVersion> … … 61 65 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath> 62 66 <Private>False</Private> 67 </Reference> 68 <Reference Include="HeuristicLab.Data.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 69 <SpecificVersion>False</SpecificVersion> 70 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data.Views-3.3.dll</HintPath> 63 71 </Reference> 64 72 <Reference Include="HeuristicLab.MainForm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> … … 102 110 <Private>False</Private> 103 111 </Reference> 112 <Reference Include="PresentationCore" /> 113 <Reference Include="PresentationFramework" /> 104 114 <Reference Include="System" /> 105 115 <Reference Include="System.Core" /> 106 116 <Reference Include="System.Drawing" /> 107 117 <Reference Include="System.Windows.Forms" /> 118 <Reference Include="System.Xaml" /> 108 119 <Reference Include="System.Xml.Linq" /> 109 120 <Reference Include="System.Data.DataSetExtensions" /> … … 111 122 <Reference Include="System.Data" /> 112 123 <Reference Include="System.Xml" /> 124 <Reference Include="UIAutomationProvider" /> 125 <Reference Include="WindowsBase" /> 126 <Reference Include="WindowsFormsIntegration" /> 113 127 </ItemGroup> 114 128 <ItemGroup> … … 133 147 <None Include="Plugin.cs.frame" /> 134 148 </ItemGroup> 149 <ItemGroup> 150 <EmbeddedResource Include="VariableInteractionNetworkView.resx"> 151 <DependentUpon>VariableInteractionNetworkView.cs</DependentUpon> 152 </EmbeddedResource> 153 </ItemGroup> 135 154 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 136 155 <PropertyGroup> -
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/VariableInteractionNetworkView.Designer.cs
r12229 r12263 31 31 this.groupBox1 = new System.Windows.Forms.GroupBox(); 32 32 this.viewHost1 = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 33 this.viewHost2 = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 34 this.groupBox2 = new System.Windows.Forms.GroupBox(); 35 this.viewHost3 = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 33 36 this.groupBox1.SuspendLayout(); 37 this.groupBox2.SuspendLayout(); 34 38 this.SuspendLayout(); 35 39 // … … 37 41 // 38 42 this.groupBox1.Controls.Add(this.viewHost1); 43 this.groupBox1.Controls.Add(this.viewHost2); 39 44 this.groupBox1.Location = new System.Drawing.Point(0, 3); 40 45 this.groupBox1.Name = "groupBox1"; 41 this.groupBox1.Size = new System.Drawing.Size( 779, 403);46 this.groupBox1.Size = new System.Drawing.Size(635, 228); 42 47 this.groupBox1.TabIndex = 0; 43 48 this.groupBox1.TabStop = false; 44 this.groupBox1.Text = "Adjacency Matrix ";49 this.groupBox1.Text = "Adjacency Matrix. Node Impacts"; 45 50 // 46 51 // viewHost1 … … 52 57 this.viewHost1.Name = "viewHost1"; 53 58 this.viewHost1.ReadOnly = false; 54 this.viewHost1.Size = new System.Drawing.Size( 667, 382);59 this.viewHost1.Size = new System.Drawing.Size(354, 247); 55 60 this.viewHost1.TabIndex = 0; 56 61 this.viewHost1.ViewsLabelVisible = true; 57 62 this.viewHost1.ViewType = null; 63 // 64 // viewHost2 65 // 66 this.viewHost2.Caption = "View"; 67 this.viewHost2.Content = null; 68 this.viewHost2.Enabled = false; 69 this.viewHost2.Location = new System.Drawing.Point(365, 19); 70 this.viewHost2.Name = "viewHost2"; 71 this.viewHost2.ReadOnly = false; 72 this.viewHost2.Size = new System.Drawing.Size(210, 259); 73 this.viewHost2.TabIndex = 0; 74 this.viewHost2.ViewsLabelVisible = true; 75 this.viewHost2.ViewType = null; 76 // 77 // groupBox2 78 // 79 this.groupBox2.Controls.Add(this.viewHost3); 80 this.groupBox2.Location = new System.Drawing.Point(6, 268); 81 this.groupBox2.Name = "groupBox2"; 82 this.groupBox2.Size = new System.Drawing.Size(629, 258); 83 this.groupBox2.TabIndex = 1; 84 this.groupBox2.TabStop = false; 85 this.groupBox2.Text = "Updated Adjacency Matrix (for target variable x1 and threshold 0.2)"; 86 // 87 // viewHost3 88 // 89 this.viewHost3.Caption = "View"; 90 this.viewHost3.Content = null; 91 this.viewHost3.Enabled = false; 92 this.viewHost3.Location = new System.Drawing.Point(6, 19); 93 this.viewHost3.Name = "viewHost3"; 94 this.viewHost3.ReadOnly = false; 95 this.viewHost3.Size = new System.Drawing.Size(367, 239); 96 this.viewHost3.TabIndex = 0; 97 this.viewHost3.ViewsLabelVisible = true; 98 this.viewHost3.ViewType = null; 58 99 // 59 100 // VariableInteractionNetworkView … … 61 102 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 62 103 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 104 this.Controls.Add(this.groupBox2); 63 105 this.Controls.Add(this.groupBox1); 64 106 this.Name = "VariableInteractionNetworkView"; 65 this.Size = new System.Drawing.Size(6 76, 407);107 this.Size = new System.Drawing.Size(635, 513); 66 108 this.groupBox1.ResumeLayout(false); 109 this.groupBox2.ResumeLayout(false); 67 110 this.ResumeLayout(false); 68 111 … … 73 116 private System.Windows.Forms.GroupBox groupBox1; 74 117 private MainForm.WindowsForms.ViewHost viewHost1; 75 118 private MainForm.WindowsForms.ViewHost viewHost2; 119 private System.Windows.Forms.GroupBox groupBox2; 120 private MainForm.WindowsForms.ViewHost viewHost3; 76 121 } 77 122 } -
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/VariableInteractionNetworkView.cs
r12229 r12263 42 42 public sealed partial class VariableInteractionNetworkView : AsynchronousContentView { 43 43 private const string variableImpactResultName = "Variable impacts"; 44 private const string TrainingBestSolutionParameterName = "Best training solution"; 44 45 public new RunCollection Content { 45 46 get { return (RunCollection)base.Content; } … … 83 84 from variableName in variableImpact.RowNames 84 85 select variableName).Distinct().ToArray(); 85 86 86 var adjMatrix = new DoubleMatrix(variableNames.Length, variableNames.Length); 87 var adjRow = groupRunCollection.Select(x => CalculateAdjacencyRows(x)).ToList(); 88 var targets = groupRunCollection.Select(x => x.Key); 89 90 adjMatrix.RowNames = targets; 87 88 adjMatrix.RowNames = groupRunCollection.Select(x => x.Key); 91 89 adjMatrix.ColumnNames = adjMatrix.RowNames; 92 90 … … 109 107 } 110 108 } 109 viewHost2.Content = CalculateNodeImportance(adjMatrix); 110 viewHost3.Content = UpdateAdjacencyMatrixByThreshold(0.2, "x1", adjMatrix); 111 111 viewHost1.Content = adjMatrix; 112 112 } … … 125 125 select variableName) 126 126 .ToList(); 127 128 var inputVariables = runs.Select(x => ((IRegressionProblemData)x.Parameters["ProblemData"]).InputVariables).ToArray(); 127 129 128 var runNames = runs.Select(x => x.Name).ToArray(); 130 129 var runsArray = runs.ToArray(); … … 143 142 } 144 143 145 //taken from RunCollectionVariableImpactView 146 private IEnumerable<double> GetVariableImpacts(string variableName, IEnumerable<DoubleMatrix> allVariableImpacts) 147 { 148 foreach (DoubleMatrix runVariableImpacts in allVariableImpacts) 149 { 150 int row = 0; 151 foreach (string rowName in runVariableImpacts.RowNames) 152 { 153 if (rowName == variableName) 154 yield return runVariableImpacts[row, 0]; 155 row++; 156 } 157 } 144 private DoubleMatrix UpdateAdjacencyMatrixByThreshold(double threshold, string targetVariable, DoubleMatrix adjMatrix) 145 { 146 var updatedMatrix = (DoubleMatrix) adjMatrix.Clone(); 147 var groupRunCollection = Content.GroupBy(x => ((IRegressionProblemData)x.Parameters["ProblemData"]).TargetVariable).ToList(); 148 string[] targets = adjMatrix.RowNames.ToArray(); 149 var targetIndex = Array.IndexOf(targets, targetVariable); 150 151 for (int j = 0; j < groupRunCollection.Count; ++j) 152 { 153 if (updatedMatrix[targetIndex, j] < threshold) 154 { 155 updatedMatrix[targetIndex, j] = 0; 156 } 157 } 158 return updatedMatrix; 159 } 160 161 private DoubleMatrix CalculateNodeImportance(DoubleMatrix adjMatrix) 162 { 163 DoubleMatrix nodeImportance = new DoubleMatrix(adjMatrix.Rows, 1); 164 var variables = new List<Tuple<string, double>>(); 165 var rowNames = adjMatrix.RowNames.ToList(); 166 var groupRunCollection = Content.GroupBy(x => ((IRegressionProblemData)x.Parameters["ProblemData"]).TargetVariable).ToList(); 167 double[] meanQuality = new double[groupRunCollection.Count]; 168 169 for (int j = 0; j < groupRunCollection.Count; ++j) 170 { 171 var g = groupRunCollection[j]; 172 meanQuality[j] = g.Average(x => ((IRegressionSolution)x.Results[TrainingBestSolutionParameterName]).TrainingRSquared); 173 } 174 175 for (int i = 0; i < adjMatrix.Columns; ++i) 176 { 177 for (int j = 0; j < adjMatrix.Rows; ++j) 178 { 179 nodeImportance[i, 0] += adjMatrix[j, i]; 180 } 181 nodeImportance[i, 0] = nodeImportance[i, 0] * meanQuality[i] / (adjMatrix.Rows - 1); 182 variables.Add(new Tuple<string, double>(rowNames[i], nodeImportance[i, 0])); 183 } 184 185 variables.Sort((b,a) => a.Item2.CompareTo(b.Item2)); 186 187 for (int i = 0; i < nodeImportance.Rows; ++i) 188 { 189 nodeImportance[i, 0] = variables[i].Item2; 190 rowNames[i] = variables[i].Item1; 191 } 192 193 nodeImportance.RowNames = rowNames; 194 nodeImportance.ColumnNames = new[] { "Node Importance" }; 195 return nodeImportance; 158 196 } 159 197 … … 205 243 return matrix; 206 244 } 245 246 //taken from RunCollectionVariableImpactView 247 private IEnumerable<double> GetVariableImpacts(string variableName, IEnumerable<DoubleMatrix> allVariableImpacts) 248 { 249 foreach (DoubleMatrix runVariableImpacts in allVariableImpacts) 250 { 251 int row = 0; 252 foreach (string rowName in runVariableImpacts.RowNames) 253 { 254 if (rowName == variableName) 255 yield return runVariableImpacts[row, 0]; 256 row++; 257 } 258 } 259 } 207 260 } 208 261 }
Note: See TracChangeset
for help on using the changeset viewer.