Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj (revision 14347)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj (revision 14348)
@@ -245,4 +245,10 @@
RegressionFeatureCorrelationView.cs
+
+
+ UserControl
+
+
+ RegressionSolutionVariableImpactsView.cs
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs (revision 14348)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs (revision 14348)
@@ -0,0 +1,135 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ partial class RegressionSolutionVariableImpactsView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.variableImactsArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView();
+ this.dataPartitionComboBox = new System.Windows.Forms.ComboBox();
+ this.dataPartitionLabel = new System.Windows.Forms.Label();
+ this.replacementLabel = new System.Windows.Forms.Label();
+ this.replacementComboBox = new System.Windows.Forms.ComboBox();
+ this.SuspendLayout();
+ //
+ // variableImactsArrayView
+ //
+ this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.variableImactsArrayView.Caption = "StringConvertibleArray View";
+ this.variableImactsArrayView.Content = null;
+ this.variableImactsArrayView.Location = new System.Drawing.Point(3, 59);
+ this.variableImactsArrayView.Name = "variableImactsArrayView";
+ this.variableImactsArrayView.ReadOnly = true;
+ this.variableImactsArrayView.Size = new System.Drawing.Size(304, 223);
+ this.variableImactsArrayView.TabIndex = 4;
+ //
+ // dataPartitionComboBox
+ //
+ this.dataPartitionComboBox.FormattingEnabled = true;
+ this.dataPartitionComboBox.Items.AddRange(new object[] {
+ HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.Training,
+ HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.Test,
+ HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.All});
+ this.dataPartitionComboBox.Location = new System.Drawing.Point(82, 3);
+ this.dataPartitionComboBox.Name = "dataPartitionComboBox";
+ this.dataPartitionComboBox.Size = new System.Drawing.Size(121, 21);
+ this.dataPartitionComboBox.TabIndex = 1;
+ this.dataPartitionComboBox.SelectedIndexChanged += new System.EventHandler(this.dataPartitionComboBox_SelectedIndexChanged);
+ //
+ // dataPartitionLabel
+ //
+ this.dataPartitionLabel.AutoSize = true;
+ this.dataPartitionLabel.Location = new System.Drawing.Point(3, 6);
+ this.dataPartitionLabel.Name = "dataPartitionLabel";
+ this.dataPartitionLabel.Size = new System.Drawing.Size(73, 13);
+ this.dataPartitionLabel.TabIndex = 0;
+ this.dataPartitionLabel.Text = "Data partition:";
+ //
+ // replacementLabel
+ //
+ this.replacementLabel.AutoSize = true;
+ this.replacementLabel.Location = new System.Drawing.Point(3, 35);
+ this.replacementLabel.Name = "replacementLabel";
+ this.replacementLabel.Size = new System.Drawing.Size(73, 13);
+ this.replacementLabel.TabIndex = 2;
+ this.replacementLabel.Text = "Replacement:";
+ //
+ // replacementComboBox
+ //
+ this.replacementComboBox.FormattingEnabled = true;
+ this.replacementComboBox.Items.AddRange(new object[] {
+ HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum.Median,
+ HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum.Average,
+ HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum.Noise,
+ HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum.Shuffle});
+ this.replacementComboBox.Location = new System.Drawing.Point(82, 32);
+ this.replacementComboBox.Name = "replacementComboBox";
+ this.replacementComboBox.Size = new System.Drawing.Size(121, 21);
+ this.replacementComboBox.TabIndex = 3;
+ this.replacementComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged);
+ //
+ // RegressionSolutionVariableImpactsView
+ //
+ this.AllowDrop = true;
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+ this.Controls.Add(this.replacementComboBox);
+ this.Controls.Add(this.replacementLabel);
+ this.Controls.Add(this.dataPartitionLabel);
+ this.Controls.Add(this.dataPartitionComboBox);
+ this.Controls.Add(this.variableImactsArrayView);
+ this.Name = "RegressionSolutionVariableImpactsView";
+ this.Size = new System.Drawing.Size(310, 285);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Data.Views.StringConvertibleArrayView variableImactsArrayView;
+ private System.Windows.Forms.ComboBox dataPartitionComboBox;
+ private System.Windows.Forms.Label dataPartitionLabel;
+ private System.Windows.Forms.Label replacementLabel;
+ private System.Windows.Forms.ComboBox replacementComboBox;
+ }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs (revision 14348)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs (revision 14348)
@@ -0,0 +1,110 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using HeuristicLab.Data;
+using HeuristicLab.MainForm;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ [View("Variable Impacts")]
+ [Content(typeof(IRegressionSolution))]
+ public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView {
+
+ public new IRegressionSolution Content {
+ get { return (IRegressionSolution)base.Content; }
+ set {
+ base.Content = value;
+ }
+ }
+
+ public RegressionSolutionVariableImpactsView()
+ : base() {
+ InitializeComponent();
+ this.dataPartitionComboBox.SelectedIndex = 0;
+ this.replacementComboBox.SelectedIndex = 0;
+ }
+
+ #region events
+ protected override void RegisterContentEvents() {
+ base.RegisterContentEvents();
+ Content.ModelChanged += new EventHandler(Content_ModelChanged);
+ Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
+ }
+
+ protected override void DeregisterContentEvents() {
+ base.DeregisterContentEvents();
+ Content.ModelChanged -= new EventHandler(Content_ModelChanged);
+ Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
+ }
+
+ protected virtual void Content_ProblemDataChanged(object sender, EventArgs e) {
+ OnContentChanged();
+ }
+
+ protected virtual void Content_ModelChanged(object sender, EventArgs e) {
+ OnContentChanged();
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ if (Content == null) {
+ variableImactsArrayView.Content = null;
+ } else {
+ UpdateVariableImpacts();
+ }
+ }
+
+ private void UpdateVariableImpacts() {
+ if (Content == null || replacementComboBox.SelectedIndex < 0 || dataPartitionComboBox.SelectedIndex < 0) return;
+ var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
+ variableImactsArrayView.Caption = Content.Name + " Variable Impacts";
+ var replMethod =
+ (RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum)replacementComboBox.Items[replacementComboBox.SelectedIndex];
+ var dataPartition =
+ (RegressionSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem;
+
+ Task.Factory.StartNew(() => {
+ try {
+ mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name);
+
+ var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod);
+ var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
+ impactArray.ElementNames = impacts.Select(i => i.Item1);
+ variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly();
+ } finally {
+ mainForm.RemoveOperationProgressFromView(this);
+ }
+ });
+ }
+
+ #endregion
+
+ private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) {
+ UpdateVariableImpacts();
+ }
+
+ private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) {
+ UpdateVariableImpacts();
+ }
+ }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.Designer.cs (revision 14347)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.Designer.cs (revision 14348)
@@ -46,5 +46,4 @@
///
private void InitializeComponent() {
- this.btnImpactCalculation = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
@@ -54,26 +53,4 @@
this.detailsGroupBox.SuspendLayout();
this.SuspendLayout();
- //
- // btnImpactCalculation
- //
- this.btnImpactCalculation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
- this.btnImpactCalculation.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
- this.btnImpactCalculation.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnImpactCalculation.Name = "btnImpactCalculation";
- this.btnImpactCalculation.TabIndex = 6;
- this.btnImpactCalculation.Size = new System.Drawing.Size(110, 24);
- this.btnImpactCalculation.Text = "Variable Impacts";
- this.btnImpactCalculation.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.btnImpactCalculation.UseVisualStyleBackColor = true;
- this.btnImpactCalculation.Click += new System.EventHandler(this.btnImpactCalculation_Click);
- this.toolTip.SetToolTip(this.btnImpactCalculation, "Calculate impacts");
- //
- // flowLayoutPanel
- //
- this.flowLayoutPanel.Controls.Add(this.btnImpactCalculation);
- //
- // splitContainer
- //
- //
// itemsGroupBox
//
@@ -104,6 +81,4 @@
#endregion
-
- protected System.Windows.Forms.Button btnImpactCalculation;
}
}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs (revision 14347)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs (revision 14348)
@@ -20,13 +20,7 @@
#endregion
-using System;
-using System.Linq;
-using System.Threading.Tasks;
using System.Windows.Forms;
using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Data.Views;
using HeuristicLab.MainForm;
-using HeuristicLab.MainForm.WindowsForms;
namespace HeuristicLab.Problems.DataAnalysis.Views {
@@ -41,30 +35,4 @@
get { return (RegressionSolutionBase)base.Content; }
set { base.Content = value; }
- }
-
- protected override void SetEnabledStateOfControls() {
- base.SetEnabledStateOfControls();
- btnImpactCalculation.Enabled = Content != null && !Locked;
- }
-
- protected virtual void btnImpactCalculation_Click(object sender, EventArgs e) {
- var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
- var view = new StringConvertibleArrayView();
- view.Caption = Content.Name + " Variable Impacts";
- view.Show();
-
- Task.Factory.StartNew(() => {
- try {
- mainForm.AddOperationProgressToView(view, "Calculating variable impacts for " + Content.Name);
-
- var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content);
- var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
- impactArray.ElementNames = impacts.Select(i => i.Item1);
- view.Content = (DoubleArray)impactArray.AsReadOnly();
- }
- finally {
- mainForm.RemoveOperationProgressFromView(view);
- }
- });
}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs (revision 14347)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs (revision 14348)
@@ -156,5 +156,13 @@
// new var has same empirical distribution but the relation to y is broken
rand = new FastRandom(31415);
- replacementValues = rows.Select(r => originalValues[r]).Shuffle(rand).ToList();
+ // prepare a complete column for the dataset
+ replacementValues = Enumerable.Repeat(double.NaN, dataset.Rows).ToList();
+ // shuffle only the selected rows
+ var shuffledValues = rows.Select(r => originalValues[r]).Shuffle(rand).ToList();
+ int i = 0;
+ // update column values
+ foreach (var r in rows) {
+ replacementValues[r] = shuffledValues[i++];
+ }
break;
case ReplacementMethodEnum.Noise:
@@ -162,5 +170,10 @@
var stdDev = rows.Select(r => originalValues[r]).StandardDeviation();
rand = new FastRandom(31415);
- replacementValues = rows.Select(_ => NormalDistributedRandom.NextDouble(rand, avg, stdDev)).ToList();
+ // prepare a complete column for the dataset
+ replacementValues = Enumerable.Repeat(double.NaN, dataset.Rows).ToList();
+ // update column values
+ foreach (var r in rows) {
+ replacementValues[r] = NormalDistributedRandom.NextDouble(rand, avg, stdDev);
+ }
break;