- Timestamp:
- 10/23/12 10:07:48 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 12 added
- 2 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj
r8600 r8833 128 128 </Compile> 129 129 <Compile Include="Plugin.cs" /> 130 <Compile Include="StringConvertibleMatrixColumnVisibilityDialog.cs"> 131 <SubType>Form</SubType> 132 </Compile> 133 <Compile Include="StringConvertibleMatrixColumnVisibilityDialog.Designer.cs"> 134 <DependentUpon>StringConvertibleMatrixColumnVisibilityDialog.cs</DependentUpon> 135 </Compile> 136 <Compile Include="StringConvertibleMatrixRowVisibilityDialog.cs"> 137 <SubType>Form</SubType> 138 </Compile> 139 <Compile Include="StringConvertibleMatrixRowVisibilityDialog.Designer.cs"> 140 <DependentUpon>StringConvertibleMatrixRowVisibilityDialog.cs</DependentUpon> 141 </Compile> 130 142 <Compile Include="StringConvertibleValueTupleView.cs"> 131 143 <SubType>UserControl</SubType> … … 141 153 <DependentUpon>BoolValueView.cs</DependentUpon> 142 154 </Compile> 143 <Compile Include=" ColumnsVisibilityDialog.cs">155 <Compile Include="StringConvertibleMatrixVisibilityDialog.cs"> 144 156 <SubType>Form</SubType> 145 157 </Compile> 146 <Compile Include=" ColumnsVisibilityDialog.Designer.cs">147 <DependentUpon> ColumnsVisibilityDialog.cs</DependentUpon>158 <Compile Include="StringConvertibleMatrixVisibilityDialog.Designer.cs"> 159 <DependentUpon>StringConvertibleMatrixVisibilityDialog.cs</DependentUpon> 148 160 </Compile> 149 161 <Compile Include="ComparisonView.cs"> … … 240 252 --> 241 253 <PropertyGroup> 242 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)254 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 243 255 set ProjectDir=$(ProjectDir) 244 256 set SolutionDir=$(SolutionDir) … … 247 259 call PreBuildEvent.cmd 248 260 </PreBuildEvent> 249 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">261 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 250 262 export ProjectDir=$(ProjectDir) 251 263 export SolutionDir=$(SolutionDir) -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r8139 r8833 35 35 [Content(typeof(IStringConvertibleMatrix), true)] 36 36 public partial class StringConvertibleMatrixView : AsynchronousContentView { 37 pr ivateint[] virtualRowIndices;37 protected int[] virtualRowIndices; 38 38 private List<KeyValuePair<int, SortOrder>> sortedColumnIndices; 39 39 private RowComparer rowComparer; … … 171 171 } 172 172 } 173 protected v oid UpdateRowHeaders() {173 protected virtual void UpdateRowHeaders() { 174 174 int index = dataGridView.FirstDisplayedScrollingRowIndex; 175 175 if (index == -1) index = 0; … … 509 509 contextMenu.Show(MousePosition); 510 510 } 511 pr ivatevoid ShowHideColumns_Click(object sender, EventArgs e) {512 new ColumnsVisibilityDialog(this.dataGridView.Columns.Cast<DataGridViewColumn>()).ShowDialog();511 protected virtual void ShowHideColumns_Click(object sender, EventArgs e) { 512 new StringConvertibleMatrixColumnVisibilityDialog(this.dataGridView.Columns.Cast<DataGridViewColumn>()).ShowDialog(); 513 513 } 514 514 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationFeatureCorrelationView.cs
r8689 r8833 37 37 } 38 38 39 protected override bool[] SetInitialV isibilityOfColumns() {39 protected override bool[] SetInitialVariableVisibility() { 40 40 int i = Content.Dataset.DoubleVariables.ToList().FindIndex(x => x == Content.TargetVariable); 41 var initialVisibility = base.SetInitialV isibilityOfColumns();41 var initialVisibility = base.SetInitialVariableVisibility(); 42 42 initialVisibility[i] = true; 43 43 return initialVisibility; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationTimeframeFeatureCorrelationView.cs
r8689 r8833 37 37 } 38 38 39 protected override bool[] SetInitialV isibilityOfColumns() {39 protected override bool[] SetInitialVariableVisibility() { 40 40 int i = Content.Dataset.DoubleVariables.ToList().FindIndex(x => x == Content.TargetVariable); 41 var initialVisibility = base.SetInitialV isibilityOfColumns();41 var initialVisibility = base.SetInitialVariableVisibility(); 42 42 initialVisibility[i] = true; 43 43 return initialVisibility; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.Designer.cs
r8689 r8833 21 21 22 22 #endregion 23 23 24 namespace HeuristicLab.Problems.DataAnalysis.Views { 24 25 partial class AbstractFeatureCorrelationView { … … 48 49 this.components = new System.ComponentModel.Container(); 49 50 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AbstractFeatureCorrelationView)); 50 this.DataGridView = new System.Windows.Forms.DataGridView();51 51 this.HeatMapProgressBar = new System.Windows.Forms.ProgressBar(); 52 52 this.PartitionComboBox = new System.Windows.Forms.ComboBox(); … … 60 60 this.CalculatingPanel = new System.Windows.Forms.Panel(); 61 61 this.CalculatingLabel = new System.Windows.Forms.Label(); 62 this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 63 this.ShowHideColumns = new System.Windows.Forms.ToolStripMenuItem(); 64 ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit(); 62 this.dataView = new HeuristicLab.Problems.DataAnalysis.Views.EnhancedStringConvertibleMatrixView(); 65 63 ((System.ComponentModel.ISupportInitialize)(this.PictureBox)).BeginInit(); 66 64 ((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit(); … … 69 67 this.SplitContainer.SuspendLayout(); 70 68 this.CalculatingPanel.SuspendLayout(); 71 this.contextMenu.SuspendLayout();72 69 this.SuspendLayout(); 73 //74 // DataGridView75 //76 this.DataGridView.AllowUserToAddRows = false;77 this.DataGridView.AllowUserToDeleteRows = false;78 this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;79 this.DataGridView.Dock = System.Windows.Forms.DockStyle.Fill;80 this.DataGridView.Location = new System.Drawing.Point(0, 0);81 this.DataGridView.Name = "DataGridView";82 this.DataGridView.ReadOnly = true;83 this.DataGridView.Size = new System.Drawing.Size(475, 301);84 this.DataGridView.TabIndex = 0;85 this.DataGridView.VirtualMode = true;86 this.DataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.DataGridView_CellPainting);87 this.DataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.DataGridView_CellValueNeeded);88 this.DataGridView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DataGridView_ColumnHeaderMouseClick);89 this.DataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DataGridView_KeyDown);90 this.DataGridView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.DataGridView_MouseClick);91 70 // 92 71 // HeatMapProgressBar … … 162 141 // 163 142 this.PictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 164 143 | System.Windows.Forms.AnchorStyles.Right))); 165 144 this.PictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 166 145 this.PictureBox.Image = ((System.Drawing.Image)(resources.GetObject("PictureBox.Image"))); … … 175 154 // 176 155 this.SplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 177 178 156 | System.Windows.Forms.AnchorStyles.Left) 157 | System.Windows.Forms.AnchorStyles.Right))); 179 158 this.SplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; 180 159 this.SplitContainer.IsSplitterFixed = true; … … 193 172 // 194 173 this.SplitContainer.Panel2.Controls.Add(this.CalculatingPanel); 195 this.SplitContainer.Panel2.Controls.Add(this. DataGridView);174 this.SplitContainer.Panel2.Controls.Add(this.dataView); 196 175 this.SplitContainer.Size = new System.Drawing.Size(475, 330); 197 176 this.SplitContainer.SplitterDistance = 25; … … 217 196 this.CalculatingLabel.Text = "Calculating correlation..."; 218 197 // 219 // contextMenu 220 // 221 this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 222 this.ShowHideColumns}); 223 this.contextMenu.Name = "contextMenu"; 224 this.contextMenu.Size = new System.Drawing.Size(191, 26); 225 // 226 // ShowHideColumns 227 // 228 this.ShowHideColumns.Name = "ShowHideColumns"; 229 this.ShowHideColumns.Size = new System.Drawing.Size(190, 22); 230 this.ShowHideColumns.Text = "Show / Hide Columns"; 231 this.ShowHideColumns.Click += new System.EventHandler(this.ShowHideColumns_Click); 198 // DataGridView 199 // 200 this.dataView.Dock = System.Windows.Forms.DockStyle.Fill; 201 this.dataView.Location = new System.Drawing.Point(0, 0); 202 this.dataView.Name = "DataView"; 203 this.dataView.ReadOnly = true; 204 this.dataView.Size = new System.Drawing.Size(475, 301); 205 this.dataView.TabIndex = 0; 232 206 // 233 207 // AbstractFeatureCorrelationView … … 241 215 this.Name = "AbstractFeatureCorrelationView"; 242 216 this.Size = new System.Drawing.Size(569, 336); 243 ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();244 217 ((System.ComponentModel.ISupportInitialize)(this.PictureBox)).EndInit(); 245 218 this.SplitContainer.Panel1.ResumeLayout(false); … … 250 223 this.CalculatingPanel.ResumeLayout(false); 251 224 this.CalculatingPanel.PerformLayout(); 252 this.contextMenu.ResumeLayout(false);253 225 this.ResumeLayout(false); 254 226 … … 257 229 #endregion 258 230 259 protected System.Windows.Forms.DataGridView DataGridView;260 231 protected System.Windows.Forms.ProgressBar HeatMapProgressBar; 261 232 protected System.Windows.Forms.ComboBox PartitionComboBox; … … 269 240 protected System.Windows.Forms.Panel CalculatingPanel; 270 241 protected System.Windows.Forms.Label CalculatingLabel; 271 protected System.Windows.Forms.ContextMenuStrip contextMenu; 272 protected System.Windows.Forms.ToolStripMenuItem ShowHideColumns; 242 protected HeuristicLab.Problems.DataAnalysis.Views.EnhancedStringConvertibleMatrixView dataView; 273 243 274 244 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs
r8729 r8833 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using System.ComponentModel; 25 using System.Drawing;26 23 using System.Linq; 27 using System.Text;28 24 using System.Windows.Forms; 29 25 using HeuristicLab.Analysis; 30 using HeuristicLab.Common;31 using HeuristicLab.Data.Views;32 using HeuristicLab.DataAnalysis.Views;33 26 using HeuristicLab.MainForm; 34 27 using HeuristicLab.MainForm.WindowsForms; 28 using HeuristicLab.PluginInfrastructure; 35 29 36 30 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 38 32 [Content(typeof(DataAnalysisProblemData), false)] 39 33 public abstract partial class AbstractFeatureCorrelationView : AsynchronousContentView { 40 41 private int[] virtualRowIndices;42 private VariableVisibilityDialog variableVisibility;43 private List<KeyValuePair<int, SortOrder>> sortedColumnIndices;44 private StringConvertibleMatrixView.RowComparer rowComparer;45 46 34 protected FeatureCorrelationCalculator fcc; 47 35 protected HeatMap currentCorrelation; … … 54 42 protected AbstractFeatureCorrelationView() { 55 43 InitializeComponent(); 56 sortedColumnIndices = new List<KeyValuePair<int, SortOrder>>();57 rowComparer = new StringConvertibleMatrixView.RowComparer();58 44 fcc = new FeatureCorrelationCalculator(); 59 var calculator List = FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.CorrelationCalculators>().Select(x => new KeyValuePair<FeatureCorrelationEnums.CorrelationCalculators, string>(x, FeatureCorrelationEnums.GetEnumDescription(x))).ToList();60 CorrelationCalcComboBox.ValueMember = "Key";61 CorrelationCalcComboBox. DisplayMember = "Value";62 CorrelationCalcComboBox.D ataSource = new BindingList<KeyValuePair<FeatureCorrelationEnums.CorrelationCalculators, string>>(calculatorList);63 var partitionList = FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.Partitions>().Select(x => new KeyValuePair<FeatureCorrelationEnums.Partitions, string>(x, FeatureCorrelationEnums.GetEnumDescription(x))).ToList();64 PartitionComboBox.ValueMember = "Key";65 PartitionComboBox.D isplayMember = "Value";66 PartitionComboBox. DataSource = new BindingList<KeyValuePair<FeatureCorrelationEnums.Partitions, string>>(partitionList);45 var calculators = ApplicationManager.Manager.GetInstances<IDependencyCalculator>(); 46 var calcList = calculators.OrderBy(c => c.Name).Select(c => new { Name = c.Name, Calculator = c }).ToList(); 47 CorrelationCalcComboBox.ValueMember = "Calculator"; 48 CorrelationCalcComboBox.DisplayMember = "Name"; 49 CorrelationCalcComboBox.DataSource = calcList; 50 CorrelationCalcComboBox.SelectedItem = calcList.First(c => c.Calculator.GetType().Equals(typeof(PearsonsRDependenceCalculator))); 51 PartitionComboBox.DataSource = FeatureCorrelationPartitions.Partitions; 52 PartitionComboBox.SelectedItem = FeatureCorrelationPartitions.TRAININGSAMPLES; 67 53 } 68 54 … … 81 67 protected override void OnContentChanged() { 82 68 base.OnContentChanged(); 69 fcc.TryCancelCalculation(); 83 70 if (Content != null) { 84 71 fcc.ProblemData = Content; 85 bool[] initialVisibility = SetInitialVisibilityOfColumns();86 87 variableVisibility = new VariableVisibilityDialog(Content.Dataset.DoubleVariables, initialVisibility);88 variableVisibility.VariableVisibilityChanged += new ItemCheckEventHandler(variableVisibility_VariableVisibilityChanged);89 72 CalculateCorrelation(); 90 73 } else { 91 DataGridView.Columns.Clear();92 DataGridView.Rows.Clear();74 dataView.Content = null; 75 dataView.ResetVisibility(); 93 76 } 94 77 } 95 78 96 protected virtual bool[] SetInitialV isibilityOfColumns() {79 protected virtual bool[] SetInitialVariableVisibility() { 97 80 bool[] initialVisibility = new bool[Content.Dataset.DoubleVariables.Count()]; 98 81 int i = 0; … … 103 86 return initialVisibility; 104 87 } 105 106 protected abstract void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e);107 88 108 89 protected void CorrelationMeasureComboBox_SelectedChangeCommitted(object sender, System.EventArgs e) { … … 116 97 protected abstract void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e); 117 98 118 protected void UpdateDataGrid() { 119 virtualRowIndices = Enumerable.Range(0, currentCorrelation.Rows).ToArray(); 120 DataGridViewColumn[] columns = new DataGridViewColumn[currentCorrelation.Columns]; 121 for (int i = 0; i < columns.Length; ++i) { 122 var column = new DataGridViewTextBoxColumn(); 123 column.FillWeight = 1; 124 columns[i] = column; 125 } 126 127 DataGridView.Columns.Clear(); 128 DataGridView.Columns.AddRange(columns); 129 130 DataGridView.RowCount = currentCorrelation.Rows; 131 132 ClearSorting(); 133 UpdateColumnHeaders(); 134 UpdateRowHeaders(); 135 99 protected void UpdateDataView() { 136 100 maximumLabel.Text = currentCorrelation.Maximum.ToString(); 137 101 minimumLabel.Text = currentCorrelation.Minimum.ToString(); 138 102 139 DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader); 140 DataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders); 141 DataGridView.Enabled = true; 142 } 143 144 protected virtual void UpdateColumnHeaders() { 145 for (int i = 0; i < DataGridView.ColumnCount; i++) { 146 DataGridView.Columns[i].HeaderText = currentCorrelation.ColumnNames.ElementAt(i); 147 DataGridView.Columns[i].Visible = variableVisibility.Visibility[i]; 148 } 149 } 150 protected virtual void UpdateRowHeaders() { 151 for (int i = 0; i < DataGridView.RowCount; i++) { 152 DataGridView.Rows[i].HeaderCell.Value = currentCorrelation.RowNames.ElementAt(virtualRowIndices[i]); 153 DataGridView.Rows[i].Visible = variableVisibility.Visibility[virtualRowIndices[i]]; 154 } 103 currentCorrelation.SortableView = true; 104 dataView.Content = currentCorrelation; 105 dataView.Enabled = true; 155 106 } 156 107 … … 163 114 HeatMapProgressBar.Value = e.ProgressPercentage; 164 115 } 165 166 protected void DataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {167 if (Content == null) return;168 int rowIndex = virtualRowIndices[e.RowIndex];169 e.Value = currentCorrelation[rowIndex, e.ColumnIndex];170 }171 172 protected void DataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {173 if (Content == null) return;174 if (e.RowIndex < 0) return;175 if (e.ColumnIndex < 0) return;176 if (e.State.HasFlag(DataGridViewElementStates.Selected)) return;177 if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return;178 179 int rowIndex = virtualRowIndices[e.RowIndex];180 Color backColor = GetDataPointColor(currentCorrelation[rowIndex, e.ColumnIndex], currentCorrelation.Minimum, currentCorrelation.Maximum);181 using (Brush backColorBrush = new SolidBrush(backColor)) {182 e.Graphics.FillRectangle(backColorBrush, e.CellBounds);183 }184 e.PaintContent(e.CellBounds);185 e.Handled = true;186 }187 188 protected virtual Color GetDataPointColor(double value, double min, double max) {189 if (double.IsNaN(value)) {190 return Color.DarkGray;191 }192 IList<Color> colors = ColorGradient.Colors;193 int index = (int)((colors.Count - 1) * (value - min) / (max - min));194 if (index >= colors.Count) index = colors.Count - 1;195 if (index < 0) index = 0;196 return colors[index];197 }198 199 #region sort200 protected void DataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {201 if (Content != null) {202 if (e.Button == MouseButtons.Left) {203 bool addToSortedIndices = (Control.ModifierKeys & Keys.Control) == Keys.Control;204 SortOrder newSortOrder = SortOrder.Ascending;205 if (sortedColumnIndices.Any(x => x.Key == e.ColumnIndex)) {206 SortOrder oldSortOrder = sortedColumnIndices.Where(x => x.Key == e.ColumnIndex).First().Value;207 int enumLength = Enum.GetValues(typeof(SortOrder)).Length;208 newSortOrder = oldSortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), ((((int)oldSortOrder) + 1) % enumLength).ToString());209 }210 211 if (!addToSortedIndices)212 sortedColumnIndices.Clear();213 214 if (sortedColumnIndices.Any(x => x.Key == e.ColumnIndex)) {215 int sortedIndex = sortedColumnIndices.FindIndex(x => x.Key == e.ColumnIndex);216 if (newSortOrder != SortOrder.None)217 sortedColumnIndices[sortedIndex] = new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder);218 else219 sortedColumnIndices.RemoveAt(sortedIndex);220 } else221 if (newSortOrder != SortOrder.None)222 sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder));223 Sort();224 }225 }226 }227 228 protected virtual void ClearSorting() {229 virtualRowIndices = Enumerable.Range(0, currentCorrelation.Rows).ToArray();230 sortedColumnIndices.Clear();231 UpdateSortGlyph();232 }233 234 private void Sort() {235 virtualRowIndices = Sort(sortedColumnIndices);236 UpdateSortGlyph();237 UpdateRowHeaders();238 DataGridView.Invalidate();239 }240 241 protected virtual int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {242 int[] newSortedIndex = Enumerable.Range(0, currentCorrelation.Rows).ToArray();243 if (sortedColumns.Count() != 0) {244 rowComparer.SortedIndices = sortedColumns;245 rowComparer.Matrix = currentCorrelation;246 Array.Sort(newSortedIndex, rowComparer);247 }248 return newSortedIndex;249 }250 private void UpdateSortGlyph() {251 foreach (DataGridViewColumn col in this.DataGridView.Columns)252 col.HeaderCell.SortGlyphDirection = SortOrder.None;253 foreach (KeyValuePair<int, SortOrder> p in sortedColumnIndices)254 this.DataGridView.Columns[p.Key].HeaderCell.SortGlyphDirection = p.Value;255 }256 #endregion257 258 #region copy259 protected void DataGridView_KeyDown(object sender, KeyEventArgs e) {260 if (e.Control && e.KeyCode == Keys.C)261 CopyValuesFromDataGridView();262 }263 264 private void CopyValuesFromDataGridView() {265 if (DataGridView.SelectedCells.Count == 0) return;266 StringBuilder s = new StringBuilder();267 int minRowIndex = DataGridView.SelectedCells[0].RowIndex;268 int maxRowIndex = DataGridView.SelectedCells[DataGridView.SelectedCells.Count - 1].RowIndex;269 int minColIndex = DataGridView.SelectedCells[0].ColumnIndex;270 int maxColIndex = DataGridView.SelectedCells[DataGridView.SelectedCells.Count - 1].ColumnIndex;271 272 if (minRowIndex > maxRowIndex) {273 int temp = minRowIndex;274 minRowIndex = maxRowIndex;275 maxRowIndex = temp;276 }277 if (minColIndex > maxColIndex) {278 int temp = minColIndex;279 minColIndex = maxColIndex;280 maxColIndex = temp;281 }282 283 bool addRowNames = DataGridView.AreAllCellsSelected(false) && currentCorrelation.RowNames.Count() > 0;284 bool addColumnNames = DataGridView.AreAllCellsSelected(false) && currentCorrelation.ColumnNames.Count() > 0;285 286 //add colum names287 if (addColumnNames) {288 if (addRowNames)289 s.Append('\t');290 291 DataGridViewColumn column = DataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible);292 while (column != null) {293 s.Append(column.HeaderText);294 s.Append('\t');295 column = DataGridView.Columns.GetNextColumn(column, DataGridViewElementStates.Visible, DataGridViewElementStates.None);296 }297 s.Remove(s.Length - 1, 1); //remove last tab298 s.Append(Environment.NewLine);299 }300 301 for (int i = minRowIndex; i <= maxRowIndex; i++) {302 int rowIndex = this.virtualRowIndices[i];303 if (addRowNames) {304 s.Append(currentCorrelation.RowNames.ElementAt(rowIndex));305 s.Append('\t');306 }307 308 DataGridViewColumn column = DataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible);309 while (column != null) {310 DataGridViewCell cell = DataGridView[column.Index, i];311 if (cell.Selected) {312 s.Append(currentCorrelation[rowIndex, column.Index]);313 s.Append('\t');314 }315 316 column = DataGridView.Columns.GetNextColumn(column, DataGridViewElementStates.Visible, DataGridViewElementStates.None);317 }318 s.Remove(s.Length - 1, 1); //remove last tab319 s.Append(Environment.NewLine);320 }321 Clipboard.SetText(s.ToString());322 }323 #endregion324 325 protected void ShowHideColumns_Click(object sender, EventArgs e) {326 variableVisibility.ShowDialog();327 }328 329 protected void DataGridView_MouseClick(object sender, MouseEventArgs e) {330 if (Content == null) return;331 if (e.Button == MouseButtons.Right && DataGridView.Columns.Count != 0)332 contextMenu.Show(MousePosition);333 }334 335 protected int GetRowIndexOfVirtualindex(int virtualIndex) {336 if (virtualIndex < 0 || virtualIndex >= virtualRowIndices.Length) {337 throw new ArgumentException("Virtual index is out of bounds");338 }339 340 for (int i = 0; i < virtualRowIndices.Length; i++) {341 if (virtualRowIndices[i] == virtualIndex) {342 return i;343 }344 }345 throw new ArgumentException("Virtual index was not found!");346 }347 116 } 348 117 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCalculator.cs
r8729 r8833 51 51 } 52 52 53 public void CalculateElements( FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitionspartition) {53 public void CalculateElements(IDependencyCalculator calc, string partition) { 54 54 CalculateElements(problemData.Dataset, calc, partition); 55 55 } 56 56 57 // returns if any calculation takes place58 public bool CalculateTimeframeElements( FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitionspartition, string variable, int frames, double[,] correlation = null) {57 // returns true if any calculation takes place 58 public bool CalculateTimeframeElements(IDependencyCalculator calc, string partition, string variable, int frames, double[,] correlation = null) { 59 59 if (correlation == null || correlation.GetLength(1) <= frames) { 60 60 CalculateElements(problemData.Dataset, calc, partition, variable, frames, correlation); … … 65 65 } 66 66 67 public void TryCancelCalculation() { 68 if (bw != null && bw.IsBusy) { 69 bwInfo = null; 70 bw.CancelAsync(); 71 } 72 } 73 67 74 private double[,] GetElementsOfCorrelation(double[,] corr, int frames) { 68 75 double[,] elements = new double[corr.GetLength(0), frames + 1]; … … 75 82 } 76 83 77 private void CalculateElements(Dataset dataset, FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitionspartition, string variable = null, int frames = 0, double[,] alreadyCalculated = null) {84 private void CalculateElements(Dataset dataset, IDependencyCalculator calc, string partition, string variable = null, int frames = 0, double[,] alreadyCalculated = null) { 78 85 bwInfo = new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition, Variable = variable, Frames = frames, AlreadyCalculated = alreadyCalculated }; 79 86 if (bw == null) { … … 107 114 BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument; 108 115 Dataset dataset = bwInfo.Dataset; 109 FeatureCorrelationEnums.Partitionspartition = bwInfo.Partition;110 FeatureCorrelationEnums.CorrelationCalculatorscalc = bwInfo.Calculator;116 string partition = bwInfo.Partition; 117 IDependencyCalculator calc = bwInfo.Calculator; 111 118 112 119 IList<string> doubleVariableNames = dataset.DoubleVariables.ToList(); … … 121 128 for (int j = 0; j < i + 1; j++) { 122 129 if (worker.CancellationPending) { 130 worker.ReportProgress(100); 123 131 e.Cancel = true; 124 132 return; … … 127 135 IEnumerable<double> var2 = GetRelevantValues(problemData, partition, doubleVariableNames[j]); 128 136 129 elements[i, j] = CalculateElementWithCalculator(calc,var1, var2, out error);137 elements[i, j] = calc.Calculate(var1, var2, out error); 130 138 131 139 if (!error.Equals(OnlineCalculatorError.None)) { … … 137 145 } 138 146 e.Result = elements; 147 worker.ReportProgress(100); 139 148 } 140 149 … … 144 153 BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument; 145 154 Dataset dataset = bwInfo.Dataset; 146 FeatureCorrelationEnums.Partitionspartition = bwInfo.Partition;147 FeatureCorrelationEnums.CorrelationCalculatorscalc = bwInfo.Calculator;155 string partition = bwInfo.Partition; 156 IDependencyCalculator calc = bwInfo.Calculator; 148 157 string variable = bwInfo.Variable; 149 158 int frames = bwInfo.Frames; … … 169 178 for (int j = start; j <= frames; j++) { 170 179 if (worker.CancellationPending) { 180 worker.ReportProgress(100); 171 181 e.Cancel = true; 172 182 return; … … 181 191 var1 = help; 182 192 183 elements[i, j] = CalculateElementWithCalculator(calc,var1, var2, out error);193 elements[i, j] = calc.Calculate(var1, var2, out error); 184 194 185 195 if (!error.Equals(OnlineCalculatorError.None)) { … … 190 200 } 191 201 e.Result = elements; 192 } 193 194 private IEnumerable<double> GetRelevantValues(IDataAnalysisProblemData problemData, FeatureCorrelationEnums.Partitions partition, string variable) { 202 worker.ReportProgress(100); 203 } 204 205 private IEnumerable<double> GetRelevantValues(IDataAnalysisProblemData problemData, string partition, string variable) { 195 206 IEnumerable<double> var = problemData.Dataset.GetDoubleValues(variable); 196 if (partition.Equals(FeatureCorrelation Enums.Partitions.TrainingSamples)) {207 if (partition.Equals(FeatureCorrelationPartitions.TRAININGSAMPLES)) { 197 208 var = var.Skip(problemData.TrainingPartition.Start).Take(problemData.TrainingPartition.End - problemData.TrainingPartition.Start); 198 } else if (partition.Equals(FeatureCorrelation Enums.Partitions.TestSamples)) {209 } else if (partition.Equals(FeatureCorrelationPartitions.TESTSAMPLES)) { 199 210 var = var.Skip(problemData.TestPartition.Start).Take(problemData.TestPartition.End - problemData.TestPartition.Start); 200 211 } 201 212 return var; 202 }203 204 private double CalculateElementWithCalculator(FeatureCorrelationEnums.CorrelationCalculators calc, IEnumerable<double> var1, IEnumerable<double> var2, out OnlineCalculatorError error) {205 if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.HoeffdingsDependence)) {206 return HoeffdingsDependenceCalculator.Calculate(var1, var2, out error);207 } else if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.SpearmansRank)) {208 return SpearmansRankCorrelationCoefficientCalculator.Calculate(var1, var2, out error);209 } else if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.PearsonsRSquared)) {210 return OnlinePearsonsRSquaredCalculator.Calculate(var1, var2, out error);211 } else {212 return Math.Sqrt(OnlinePearsonsRSquaredCalculator.Calculate(var1, var2, out error));213 }214 213 } 215 214 … … 222 221 OnCorrelationCalculationFinished((double[,])e.Result, bwInfo.Calculator, bwInfo.Partition, bwInfo.Variable); 223 222 } 224 } else {223 } else if (bwInfo != null) { 225 224 bw.RunWorkerAsync(bwInfo); 226 225 } … … 231 230 public class CorrelationCalculationFinishedArgs : EventArgs { 232 231 public double[,] Correlation { get; private set; } 233 public FeatureCorrelationEnums.CorrelationCalculatorsCalculcator { get; private set; }234 public FeatureCorrelationEnums.PartitionsPartition { get; private set; }232 public IDependencyCalculator Calculcator { get; private set; } 233 public string Partition { get; private set; } 235 234 public string Variable { get; private set; } 236 235 237 public CorrelationCalculationFinishedArgs(double[,] correlation, FeatureCorrelationEnums.CorrelationCalculators calculator, FeatureCorrelationEnums.Partitionspartition, string variable = null) {236 public CorrelationCalculationFinishedArgs(double[,] correlation, IDependencyCalculator calculator, string partition, string variable = null) { 238 237 this.Correlation = correlation; 239 238 this.Calculcator = calculator; … … 245 244 public delegate void CorrelationCalculationFinishedHandler(object sender, CorrelationCalculationFinishedArgs e); 246 245 public event CorrelationCalculationFinishedHandler CorrelationCalculationFinished; 247 protected virtual void OnCorrelationCalculationFinished(double[,] correlation, FeatureCorrelationEnums.CorrelationCalculators calculator, FeatureCorrelationEnums.Partitionspartition, string variable = null) {246 protected virtual void OnCorrelationCalculationFinished(double[,] correlation, IDependencyCalculator calculator, string partition, string variable = null) { 248 247 var handler = CorrelationCalculationFinished; 249 248 if (handler != null) … … 255 254 protected void BwProgressChanged(object sender, ProgressChangedEventArgs e) { 256 255 BackgroundWorker worker = sender as BackgroundWorker; 257 if ( !worker.CancellationPending &&ProgressCalculation != null) {256 if (ProgressCalculation != null) { 258 257 ProgressCalculation(sender, e); 259 258 } … … 263 262 private class BackgroundWorkerInfo { 264 263 public Dataset Dataset { get; set; } 265 public FeatureCorrelationEnums.CorrelationCalculatorsCalculator { get; set; }266 public FeatureCorrelationEnums.PartitionsPartition { get; set; }264 public IDependencyCalculator Calculator { get; set; } 265 public string Partition { get; set; } 267 266 public string Variable { get; set; } 268 267 public int Frames { get; set; } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs
r8729 r8833 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Windows.Forms; 23 25 using HeuristicLab.Analysis; … … 25 27 using HeuristicLab.MainForm; 26 28 using HeuristicLab.MainForm.WindowsForms; 29 using HeuristicLab.PluginInfrastructure; 27 30 28 31 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 40 43 41 44 protected override void OnContentChanged() { 45 if (Content != null) { 46 dataView.RowVisibility = SetInitialVariableVisibility(); 47 dataView.ColumnVisibility = SetInitialVariableVisibility(); 48 } 42 49 correlationCache.Reset(); 43 50 base.OnContentChanged(); … … 46 53 protected override void CalculateCorrelation() { 47 54 if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null) { 48 FeatureCorrelationEnums.CorrelationCalculators calc = (FeatureCorrelationEnums.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue; 49 FeatureCorrelationEnums.Partitions partition = (FeatureCorrelationEnums.Partitions)PartitionComboBox.SelectedValue; 50 DataGridView.Columns.Clear(); 51 DataGridView.Enabled = false; 55 IDependencyCalculator calc = (IDependencyCalculator)CorrelationCalcComboBox.SelectedValue; 56 string partition = (string)PartitionComboBox.SelectedValue; 57 dataView.Enabled = false; 52 58 double[,] corr = correlationCache.GetCorrelation(calc, partition); 53 59 if (corr == null) { 54 60 fcc.CalculateElements(calc, partition); 55 61 } else { 62 fcc.TryCancelCalculation(); 56 63 SetNewCorrelation(corr, calc); 57 UpdateData Grid();64 UpdateDataView(); 58 65 } 59 66 } 60 67 } 61 68 62 private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculatorscalc) {63 DoubleRange range = FeatureCorrelationEnums.calculatorInterval[calc];69 private void SetNewCorrelation(double[,] elements, IDependencyCalculator calc) { 70 DoubleRange range = calc.Interval; 64 71 HeatMap hm = new HeatMap(elements, "", range.End, range.Start); 65 72 hm.RowNames = Content.Dataset.DoubleVariables; … … 74 81 correlationCache.SetCorrelation(e.Calculcator, e.Partition, e.Correlation); 75 82 SetNewCorrelation(e.Correlation, e.Calculcator); 76 UpdateData Grid();83 UpdateDataView(); 77 84 } 78 85 } 79 86 80 protected override void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e) { 81 DataGridView.Columns[e.Index].Visible = e.NewValue == CheckState.Checked; 82 DataGridView.Rows[GetRowIndexOfVirtualindex(e.Index)].Visible = e.NewValue == CheckState.Checked; 87 [NonDiscoverableType] 88 private class FeatureCorrelationCache : Object { 89 private Dictionary<Tuple<IDependencyCalculator, string>, double[,]> correlationsCache; 90 91 public FeatureCorrelationCache() 92 : base() { 93 InitializeCaches(); 94 } 95 96 private void InitializeCaches() { 97 correlationsCache = new Dictionary<Tuple<IDependencyCalculator, string>, double[,]>(); 98 } 99 100 public void Reset() { 101 InitializeCaches(); 102 } 103 104 public double[,] GetCorrelation(IDependencyCalculator calc, string partition) { 105 double[,] corr; 106 var key = new Tuple<IDependencyCalculator, string>(calc, partition); 107 correlationsCache.TryGetValue(key, out corr); 108 return corr; 109 } 110 111 public void SetCorrelation(IDependencyCalculator calc, string partition, double[,] correlation) { 112 var key = new Tuple<IDependencyCalculator, string>(calc, partition); 113 correlationsCache[key] = correlation; 114 } 83 115 } 84 116 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.Designer.cs
r8578 r8833 49 49 this.VariableSelectionComboBox = new System.Windows.Forms.ComboBox(); 50 50 this.TimeFrameLabel = new System.Windows.Forms.Label(); 51 this.Timeframe ComboBox = new System.Windows.Forms.ComboBox();51 this.TimeframeTextbox = new System.Windows.Forms.TextBox(); 52 52 ((System.ComponentModel.ISupportInitialize)(this.PictureBox)).BeginInit(); 53 53 ((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit(); … … 78 78 // 79 79 this.SplitContainer.Panel1.Controls.Add(this.VariableSelectionComboBox); 80 this.SplitContainer.Panel1.Controls.Add(this.Timeframe ComboBox);80 this.SplitContainer.Panel1.Controls.Add(this.TimeframeTextbox); 81 81 this.SplitContainer.Panel1.Controls.Add(this.TimeFrameLabel); 82 82 this.SplitContainer.Panel1.Controls.Add(this.VariableSelectionLabel); … … 117 117 // TimeframeComboBox 118 118 // 119 this.TimeframeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 120 this.TimeframeComboBox.FormattingEnabled = true; 121 this.TimeframeComboBox.Location = new System.Drawing.Point(344, 30); 122 this.TimeframeComboBox.Name = "TimeframeComboBox"; 123 this.TimeframeComboBox.Size = new System.Drawing.Size(131, 21); 124 this.TimeframeComboBox.TabIndex = 19; 125 this.TimeframeComboBox.SelectionChangeCommitted += new System.EventHandler(this.TimeframeComboBox_SelectedChangeCommitted); 119 this.TimeframeTextbox.Location = new System.Drawing.Point(344, 30); 120 this.TimeframeTextbox.Name = "TimeframeTextbox"; 121 this.TimeframeTextbox.Size = new System.Drawing.Size(131, 21); 122 this.TimeframeTextbox.TabIndex = 19; 123 this.TimeframeTextbox.Text = "5"; 124 this.TimeframeTextbox.KeyDown += new System.Windows.Forms.KeyEventHandler(TimeframeTextbox_KeyDown); 126 125 // 127 126 // TimeframeFeatureCorrelationView … … 146 145 protected System.Windows.Forms.ComboBox VariableSelectionComboBox; 147 146 protected System.Windows.Forms.Label TimeFrameLabel; 148 protected System.Windows.Forms. ComboBox TimeframeComboBox;147 protected System.Windows.Forms.TextBox TimeframeTextbox; 149 148 } 150 149 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs
r8729 r8833 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using System.Windows.Forms; … … 26 27 using HeuristicLab.Data; 27 28 using HeuristicLab.MainForm; 29 using HeuristicLab.PluginInfrastructure; 28 30 29 31 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 36 38 public TimeframeFeatureCorrelationView() { 37 39 InitializeComponent(); 38 TimeframeComboBox.DataSource = Enumerable.Range(0, 16).ToList<int>();39 40 correlationTimeframCache = new FeatureCorrelationTimeframeCache(); 40 41 } … … 43 44 correlationTimeframCache.Reset(); 44 45 if (Content != null) { 46 dataView.RowVisibility = SetInitialVariableVisibility(); 45 47 VariableSelectionComboBox.DataSource = Content.Dataset.DoubleVariables.ToList(); 46 48 } … … 51 53 CalculateCorrelation(); 52 54 } 53 protected void TimeframeComboBox_SelectedChangeCommitted(object sender, EventArgs e) { 54 CalculateCorrelation(); 55 protected void TimeframeTextbox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { 56 if (e.KeyCode == Keys.Enter) { 57 CalculateCorrelation(); 58 } 55 59 } 56 60 57 61 protected override void CalculateCorrelation() { 58 string variable = (string)VariableSelectionComboBox.SelectedItem; 59 if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null && variable != null) { 60 FeatureCorrelationEnums.CorrelationCalculators calc = (FeatureCorrelationEnums.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue; 61 FeatureCorrelationEnums.Partitions partition = (FeatureCorrelationEnums.Partitions)PartitionComboBox.SelectedValue; 62 DataGridView.Columns.Clear(); 63 DataGridView.Enabled = false; 64 int frames = (int)TimeframeComboBox.SelectedItem; 62 if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null 63 && VariableSelectionComboBox.SelectedItem != null && ValidateTimeframeTextbox()) { 64 string variable = (string)VariableSelectionComboBox.SelectedItem; 65 IDependencyCalculator calc = (IDependencyCalculator)CorrelationCalcComboBox.SelectedValue; 66 string partition = (string)PartitionComboBox.SelectedValue; 67 int frames; 68 int.TryParse(TimeframeTextbox.Text, out frames); 69 dataView.Enabled = false; 65 70 double[,] corr = correlationTimeframCache.GetTimeframeCorrelation(calc, partition, variable); 66 71 if (corr == null) { … … 69 74 fcc.CalculateTimeframeElements(calc, partition, variable, frames, corr); 70 75 } else { 76 fcc.TryCancelCalculation(); 71 77 SetNewCorrelation(corr, calc, frames); 72 UpdateData Grid();78 UpdateDataView(); 73 79 } 74 80 } 75 81 } 76 82 77 private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc, int frames) { 83 protected bool ValidateTimeframeTextbox() { 84 int help; 85 if (!int.TryParse(TimeframeTextbox.Text, out help)) { 86 MessageBox.Show("Timeframe couldn't be parsed. Enter a valid integer value.", "Parse Error", MessageBoxButtons.OK); 87 return false; 88 } else { 89 if (help > 50) { 90 DialogResult dr = MessageBox.Show("The entered value is bigger than 50. Are you sure you want to calculate? " + 91 "The calculation could take some time.", "Huge Value Warning", MessageBoxButtons.YesNo); 92 return dr.Equals(DialogResult.Yes); 93 } 94 } 95 return true; 96 } 97 98 private void SetNewCorrelation(double[,] elements, IDependencyCalculator calc, int frames) { 78 99 double[,] neededValues = new double[elements.GetLength(0), frames + 1]; 79 100 for (int i = 0; i < elements.GetLength(0); i++) { … … 83 104 } 84 105 85 private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculatorscalc) {86 DoubleRange range = FeatureCorrelationEnums.calculatorInterval[calc];106 private void SetNewCorrelation(double[,] elements, IDependencyCalculator calc) { 107 DoubleRange range = calc.Interval; 87 108 HeatMap hm = new HeatMap(elements, "", range.End, range.Start); 88 109 hm.RowNames = Content.Dataset.DoubleVariables; … … 97 118 correlationTimeframCache.SetTimeframeCorrelation(e.Calculcator, e.Partition, e.Variable, e.Correlation); 98 119 SetNewCorrelation(e.Correlation, e.Calculcator); 99 UpdateData Grid();120 UpdateDataView(); 100 121 } 101 122 } 102 123 103 protected override void UpdateColumnHeaders() { 104 for (int i = 0; i < DataGridView.ColumnCount; i++) { 105 DataGridView.Columns[i].HeaderText = i.ToString(); 124 [NonDiscoverableType] 125 private class FeatureCorrelationTimeframeCache : Object { 126 private Dictionary<Tuple<IDependencyCalculator, string, string>, double[,]> timeFrameCorrelationsCache; 127 128 public FeatureCorrelationTimeframeCache() 129 : base() { 130 InitializeCaches(); 106 131 } 107 }108 132 109 protected override void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e) { 110 DataGridView.Rows[GetRowIndexOfVirtualindex(e.Index)].Visible = e.NewValue == CheckState.Checked; 133 private void InitializeCaches() { 134 timeFrameCorrelationsCache = new Dictionary<Tuple<IDependencyCalculator, string, string>, double[,]>(); 135 } 136 137 public void Reset() { 138 InitializeCaches(); 139 } 140 141 public double[,] GetTimeframeCorrelation(IDependencyCalculator calc, string partition, string variable) { 142 double[,] corr; 143 var key = new Tuple<IDependencyCalculator, string, string>(calc, partition, variable); 144 timeFrameCorrelationsCache.TryGetValue(key, out corr); 145 return corr; 146 } 147 148 public void SetTimeframeCorrelation(IDependencyCalculator calc, string partition, string variable, double[,] correlation) { 149 var key = new Tuple<IDependencyCalculator, string, string>(calc, partition, variable); 150 timeFrameCorrelationsCache[key] = correlation; 151 } 111 152 } 112 153 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r8798 r8833 162 162 <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon> 163 163 </Compile> 164 <Compile Include="FeatureCorrelation\EnhancedStringConvertibleMatrixView.cs"> 165 <SubType>UserControl</SubType> 166 </Compile> 167 <Compile Include="FeatureCorrelation\EnhancedStringConvertibleMatrixView.Designer.cs"> 168 <DependentUpon>EnhancedStringConvertibleMatrixView.cs</DependentUpon> 169 </Compile> 164 170 <Compile Include="FeatureCorrelation\FeatureCorrelationCalculator.cs" /> 165 <Compile Include="FeatureCorrelation\FeatureCorrelationEnums.cs" /> 166 <Compile Include="FeatureCorrelation\VariableVisibilityDialog.cs"> 167 <SubType>Form</SubType> 168 </Compile> 169 <Compile Include="FeatureCorrelation\VariableVisibilityDialog.Designer.cs"> 170 <DependentUpon>VariableVisibilityDialog.cs</DependentUpon> 171 </Compile> 171 <Compile Include="FeatureCorrelation\FeatureCorrelationHelpers.cs" /> 172 172 <Compile Include="FeatureCorrelation\FeatureCorrelationView.cs"> 173 173 <SubType>UserControl</SubType> … … 176 176 <DependentUpon>FeatureCorrelationView.cs</DependentUpon> 177 177 </Compile> 178 <Compile Include="FeatureCorrelation\FeatureCorrelationCache.cs" />179 <Compile Include="FeatureCorrelation\FeatureCorrelationTimeframeCache.cs" />180 178 <Compile Include="Plugin.cs" /> 181 179 <Compile Include="ProblemDataView.cs"> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataView.cs
r8689 r8833 45 45 46 46 protected void FeatureCorrelationButton_Click(object sender, System.EventArgs e) { 47 Type viewType = MainFormManager.GetViewTypes(this.Content.GetType(), true).FirstOrDefault(t => typeof( AbstractFeatureCorrelationView).IsAssignableFrom(t));47 Type viewType = MainFormManager.GetViewTypes(this.Content.GetType(), true).FirstOrDefault(t => typeof(FeatureCorrelationView).IsAssignableFrom(t)); 48 48 MainFormManager.MainForm.ShowContent(Content, viewType); 49 49 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionFeatureCorrelationView.cs
r8689 r8833 37 37 } 38 38 39 protected override bool[] SetInitialV isibilityOfColumns() {39 protected override bool[] SetInitialVariableVisibility() { 40 40 int i = Content.Dataset.DoubleVariables.ToList().FindIndex(x => x == Content.TargetVariable); 41 var initialVisibility = base.SetInitialV isibilityOfColumns();41 var initialVisibility = base.SetInitialVariableVisibility(); 42 42 initialVisibility[i] = true; 43 43 return initialVisibility; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionTimeframeFeatureCorrelationView.cs
r8689 r8833 37 37 } 38 38 39 protected override bool[] SetInitialV isibilityOfColumns() {39 protected override bool[] SetInitialVariableVisibility() { 40 40 int i = Content.Dataset.DoubleVariables.ToList().FindIndex(x => x == Content.TargetVariable); 41 var initialVisibility = base.SetInitialV isibilityOfColumns();41 var initialVisibility = base.SetInitialVariableVisibility(); 42 42 initialVisibility[i] = true; 43 43 return initialVisibility; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r8798 r8833 152 152 </Compile> 153 153 <Compile Include="Interfaces\Classification\IDiscriminantFunctionThresholdCalculator.cs" /> 154 <Compile Include="Interfaces\IDependencyCalculator.cs" /> 154 155 <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs"> 155 156 <SubType>Code</SubType> … … 206 207 <Compile Include="OnlineCalculators\OnlineTheilsUStatisticCalculator.cs" /> 207 208 <Compile Include="OnlineCalculators\OnlineWeightedDirectionalSymmetryCalculator.cs" /> 209 <Compile Include="OnlineCalculators\PearsonsRDependenceCalculator.cs" /> 210 <Compile Include="OnlineCalculators\PearsonsRSquaredDependenceCalculator.cs" /> 208 211 <Compile Include="OnlineCalculators\SpearmansRankCorrelationCoefficientCalculator.cs" /> 209 212 <Compile Include="Plugin.cs" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/HoeffdingsDependenceCalculator.cs
r8542 r8833 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Data; 25 26 26 27 namespace HeuristicLab.Problems.DataAnalysis { 27 public class HoeffdingsDependenceCalculator {28 public class HoeffdingsDependenceCalculator : IDependencyCalculator { 28 29 29 public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 30 public DoubleRange Interval { get { return new DoubleRange(1.0, -0.5); } } 31 32 public string Name { get { return "Hoeffdings Dependence"; } } 33 34 public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 35 return HoeffdingsDependenceCalculator.CalculateHoeffdings(originalValues, estimatedValues, out errorState); 36 } 37 38 public static double CalculateHoeffdings(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 30 39 double d = HoeffD(originalValues, estimatedValues, out errorState); 31 40 if (errorState != OnlineCalculatorError.None) return double.NaN; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs
r8728 r8833 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HeuristicLab.Data; 24 25 25 26 namespace HeuristicLab.Problems.DataAnalysis { 26 public class SpearmansRankCorrelationCoefficientCalculator {27 public class SpearmansRankCorrelationCoefficientCalculator : IDependencyCalculator { 27 28 28 public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 29 public DoubleRange Interval { get { return new DoubleRange(1.0, -1.0); } } 30 31 public string Name { get { return "Spearmans Rank"; } } 32 33 public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 34 return SpearmansRankCorrelationCoefficientCalculator.CalculateSpearmansRank(originalValues, estimatedValues, out errorState); 35 } 36 37 public static double CalculateSpearmansRank(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 29 38 double rs = double.NaN; 30 39 try {
Note: See TracChangeset
for help on using the changeset viewer.