Changeset 14530


Ignore:
Timestamp:
12/25/16 17:09:04 (2 years ago)
Author:
gkronber
Message:

#2673: merged r14348 and 14463 from trunk to stable

Location:
stable
Files:
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r14166 r14530  
    245245    <Compile Include="Regression\RegressionFeatureCorrelationView.Designer.cs">
    246246      <DependentUpon>RegressionFeatureCorrelationView.cs</DependentUpon>
     247    </Compile>
     248    <Compile Include="Regression\RegressionSolutionVariableImpactsView.cs">
     249      <SubType>UserControl</SubType>
     250    </Compile>
     251    <Compile Include="Regression\RegressionSolutionVariableImpactsView.Designer.cs">
     252      <DependentUpon>RegressionSolutionVariableImpactsView.cs</DependentUpon>
    247253    </Compile>
    248254    <Compile Include="Regression\RegressionSolutionGradientView.cs">
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.Designer.cs

    r14186 r14530  
    4646    /// </summary>
    4747    private void InitializeComponent() {
    48       this.btnImpactCalculation = new System.Windows.Forms.Button();
    4948      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    5049      this.splitContainer.Panel1.SuspendLayout();
     
    5453      this.detailsGroupBox.SuspendLayout();
    5554      this.SuspendLayout();
    56       //
    57       // btnImpactCalculation
    58       //
    59       this.btnImpactCalculation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
    60       this.btnImpactCalculation.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
    61       this.btnImpactCalculation.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
    62       this.btnImpactCalculation.Name = "btnImpactCalculation";
    63       this.btnImpactCalculation.TabIndex = 6;
    64       this.btnImpactCalculation.Size = new System.Drawing.Size(110, 24);
    65       this.btnImpactCalculation.Text = "Variable Impacts";
    66       this.btnImpactCalculation.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
    67       this.btnImpactCalculation.UseVisualStyleBackColor = true;
    68       this.btnImpactCalculation.Click += new System.EventHandler(this.btnImpactCalculation_Click);
    69       this.toolTip.SetToolTip(this.btnImpactCalculation, "Calculate impacts");
    70       //
    71       // flowLayoutPanel
    72       //
    73       this.flowLayoutPanel.Controls.Add(this.btnImpactCalculation);
    74       //
    75       // splitContainer
    76       //
    77       //
    7855      // itemsGroupBox
    7956      //
     
    10481
    10582    #endregion
    106 
    107     protected System.Windows.Forms.Button btnImpactCalculation;
    10883  }
    10984}
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r14186 r14530  
    2020#endregion
    2121
    22 using System;
    23 using System.Linq;
    24 using System.Threading.Tasks;
    2522using System.Windows.Forms;
    2623using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    28 using HeuristicLab.Data.Views;
    2924using HeuristicLab.MainForm;
    30 using HeuristicLab.MainForm.WindowsForms;
    3125
    3226namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    4135      get { return (RegressionSolutionBase)base.Content; }
    4236      set { base.Content = value; }
    43     }
    44 
    45     protected override void SetEnabledStateOfControls() {
    46       base.SetEnabledStateOfControls();
    47       btnImpactCalculation.Enabled = Content != null && !Locked;
    48     }
    49 
    50     protected virtual void btnImpactCalculation_Click(object sender, EventArgs e) {
    51       var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
    52       var view = new StringConvertibleArrayView();
    53       view.Caption = Content.Name + " Variable Impacts";
    54       view.Show();
    55 
    56       Task.Factory.StartNew(() => {
    57         try {
    58           mainForm.AddOperationProgressToView(view, "Calculating variable impacts for " + Content.Name);
    59 
    60           var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content);
    61           var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
    62           impactArray.ElementNames = impacts.Select(i => i.Item1);
    63           view.Content = (DoubleArray)impactArray.AsReadOnly();
    64         }
    65         finally {
    66           mainForm.RemoveOperationProgressFromView(view);
    67         }
    68       });
    6937    }
    7038
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs

    r14022 r14530  
    122122      }
    123123
    124 
    125124      var impacts = new Dictionary<string, double>();
    126125      var modifiableDataset = ((Dataset)dataset).ToModifiable();
    127126
    128       foreach (var inputVariable in problemData.AllowedInputVariables) {
     127      var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(solution.Model.VariablesUsedForPrediction));
     128      var allowedInputVariables = dataset.VariableNames.Where(v => inputvariables.Contains(v)).ToList();
     129
     130      foreach (var inputVariable in allowedInputVariables) {
    129131        var newEstimates = EvaluateModelWithReplacedVariable(solution.Model, inputVariable, modifiableDataset, rows, replacement);
    130132        var newR2 = OnlinePearsonsRCalculator.Calculate(targetValues, newEstimates, out error);
     
    156158          // new var has same empirical distribution but the relation to y is broken
    157159          rand = new FastRandom(31415);
    158           replacementValues = rows.Select(r => originalValues[r]).Shuffle(rand).ToList();
     160          // prepare a complete column for the dataset
     161          replacementValues = Enumerable.Repeat(double.NaN, dataset.Rows).ToList();
     162          // shuffle only the selected rows
     163          var shuffledValues = rows.Select(r => originalValues[r]).Shuffle(rand).ToList();
     164          int i = 0;
     165          // update column values
     166          foreach (var r in rows) {
     167            replacementValues[r] = shuffledValues[i++];
     168          }
    159169          break;
    160170        case ReplacementMethodEnum.Noise:
     
    162172          var stdDev = rows.Select(r => originalValues[r]).StandardDeviation();
    163173          rand = new FastRandom(31415);
    164           replacementValues = rows.Select(_ => NormalDistributedRandom.NextDouble(rand, avg, stdDev)).ToList();
     174          // prepare a complete column for the dataset
     175          replacementValues = Enumerable.Repeat(double.NaN, dataset.Rows).ToList();
     176          // update column values
     177          foreach (var r in rows) {
     178            replacementValues[r] = NormalDistributedRandom.NextDouble(rand, avg, stdDev);
     179          }
    165180          break;
    166181
Note: See TracChangeset for help on using the changeset viewer.