Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/18 15:26:57 (6 years ago)
Author:
pfleck
Message:

#2845 Merged trunk changes into branch (15406-15681, 15683-16308)

Location:
branches/2845_EnhancedProgress
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • branches/2845_EnhancedProgress

  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views

  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/ConfidenceRegressionSolutionEstimatedValuesView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/ConfidenceRegressionSolutionEstimatedValuesView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/ConfidenceRegressionSolutionLineChartView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/ConfidenceRegressionSolutionLineChartView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelWeightsView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelWeightsView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionFeatureCorrelationView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionFeatureCorrelationView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    249249    protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) {
    250250      switch (residualComboBox.SelectedItem.ToString()) {
    251         case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList();
    252         case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y)).ToList();
    253         case "Relative error": return originalValues.Zip(estimatedValues, (x, y) => x.IsAlmost(0.0) ? -1 : Math.Abs((x - y) / x))
    254           .Where(x => x > 0) // remove entries where the original value is 0
    255           .ToList();
     251        case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y))
     252            .Where(r => !double.IsNaN(r) && !double.IsInfinity(r)).ToList();
     253        case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y))
     254            .Where(r => !double.IsNaN(r) && !double.IsInfinity(r)).ToList();
     255        case "Relative error":
     256          return originalValues.Zip(estimatedValues, (x, y) => x.IsAlmost(0.0) ? -1 : Math.Abs((x - y) / x))
     257            .Where(r => r > 0 && !double.IsNaN(r) && !double.IsInfinity(r)) // remove entries where the original value is 0
     258            .ToList();
    256259        default: throw new NotSupportedException();
    257260      }
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionGradientView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionGradientView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2020#endregion
    2121using System;
    22 using System.Collections.Generic;
    2322using System.Drawing;
    2423using System.Linq;
     
    7271        this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = TARGETVARIABLE_SERIES_NAME;
    7372        this.chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    74         this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(),
    75           Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray());
     73
     74        var rows = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray();
     75        var targetValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable);
     76
     77
     78        this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(rows.ToArray(), targetValues.Select(v => double.IsInfinity(v) ? double.NaN : v).ToArray());
    7679        // training series
    7780        this.chart.Series.Add(ESTIMATEDVALUES_TRAINING_SERIES_NAME);
     
    161164      var targetValues = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0);
    162165      double estimatedValuesRange = estimatedValues.Max() - estimatedValues.Min();
    163       double targetValuesRange = targetValues.Max() - targetValues.Min();
     166      double targetValuesRange = targetValues.Where(v => !double.IsInfinity(v) && !double.IsNaN(v)).Max() -
     167                                 targetValues.Where(v => !double.IsInfinity(v) && !double.IsNaN(v)).Min();
    164168      double interestingValuesRange = Math.Min(Math.Max(targetValuesRange, 1.0), Math.Max(estimatedValuesRange, 1.0));
    165169      double digits = (int)Math.Log10(interestingValuesRange) - 3;
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionPartialDependencePlotView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    8989      var runs = new RunCollection();
    9090      // determine relevant variables (at least two different values)
    91       var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Max() > ds.GetDoubleValues(vn).Min()).ToArray();
     91      var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Distinct().Skip(1).Any()).ToArray();
    9292      var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray();
    9393      var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    126126
    127127      for (int i = 0; i < solution.ProblemData.Dataset.Rows; i++) {
     128        if (double.IsNaN(estimatedValues[i]) || double.IsInfinity(estimatedValues[i])) continue;
     129        if (double.IsNaN(targetValues[i]) || double.IsInfinity(targetValues[i])) continue;
    128130        double residual = estimatedValues[i] - targetValues[i];
    129131        residuals.Add(residual);
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3838      var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, idx).ToArray();
    3939      for (int i = 0; i < idx.Length; i++) {
    40         x[i] = target[i] - x[i];
     40        if (!double.IsInfinity(target[i]) && !double.IsNaN(target[i]) &&
     41            !double.IsInfinity(x[i]) && !double.IsNaN(x[i])) {
     42          x[i] = target[i] - x[i];
     43        } else {
     44          x[i] = 0.0;
     45        }
    4146      }
    4247    }
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    166166          this.chart.Series[TEST_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray(), "",
    167167            Content.EstimatedTestValues.ToArray(), "");
    168         double max = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Max();
    169         double min = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Min();
     168        double max = Content.EstimatedTrainingValues
     169          .Concat(Content.EstimatedTestValues
     170          .Concat(Content.EstimatedValues
     171          .Concat(dataset.GetDoubleValues(targetVariableName))))
     172          .Where(v => !double.IsNaN(v) && !double.IsInfinity(v)).Max();
     173        double min = Content.EstimatedTrainingValues
     174          .Concat(Content.EstimatedTestValues
     175          .Concat(Content.EstimatedValues
     176          .Concat(dataset.GetDoubleValues(targetVariableName))))
     177          .Where(v => !double.IsNaN(v) && !double.IsInfinity(v)).Min();
    170178
    171179        double axisMin, axisMax, axisInterval;
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    1919 */
    2020#endregion
     21
     22
    2123namespace HeuristicLab.Problems.DataAnalysis.Views {
    2224  partial class RegressionSolutionVariableImpactsView {
     
    4446    /// </summary>
    4547    private void InitializeComponent() {
     48      this.ascendingCheckBox = new System.Windows.Forms.CheckBox();
     49      this.sortByLabel = new System.Windows.Forms.Label();
     50      this.sortByComboBox = new System.Windows.Forms.ComboBox();
     51      this.factorVarReplComboBox = new System.Windows.Forms.ComboBox();
     52      this.factorVarReplacementLabel = new System.Windows.Forms.Label();
     53      this.replacementComboBox = new System.Windows.Forms.ComboBox();
     54      this.numericVarReplacementLabel = new System.Windows.Forms.Label();
     55      this.dataPartitionLabel = new System.Windows.Forms.Label();
     56      this.dataPartitionComboBox = new System.Windows.Forms.ComboBox();
    4657      this.variableImactsArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView();
    47       this.dataPartitionComboBox = new System.Windows.Forms.ComboBox();
    48       this.dataPartitionLabel = new System.Windows.Forms.Label();
    49       this.numericVarReplacementLabel = new System.Windows.Forms.Label();
    50       this.replacementComboBox = new System.Windows.Forms.ComboBox();
    51       this.factorVarReplacementLabel = new System.Windows.Forms.Label();
    52       this.factorVarReplComboBox = new System.Windows.Forms.ComboBox();
    5358      this.SuspendLayout();
    5459      //
    55       // variableImactsArrayView
    56       //
    57       this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    58             | System.Windows.Forms.AnchorStyles.Left)
    59             | System.Windows.Forms.AnchorStyles.Right)));
    60       this.variableImactsArrayView.Caption = "StringConvertibleArray View";
    61       this.variableImactsArrayView.Content = null;
    62       this.variableImactsArrayView.Location = new System.Drawing.Point(3, 84);
    63       this.variableImactsArrayView.Name = "variableImactsArrayView";
    64       this.variableImactsArrayView.ReadOnly = true;
    65       this.variableImactsArrayView.Size = new System.Drawing.Size(363, 278);
    66       this.variableImactsArrayView.TabIndex = 2;
    67       //
    68       // dataPartitionComboBox
    69       //
    70       this.dataPartitionComboBox.FormattingEnabled = true;
    71       this.dataPartitionComboBox.Items.AddRange(new object[] {
    72             HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.Training,
    73             HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.Test,
    74             HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.All});
    75       this.dataPartitionComboBox.Location = new System.Drawing.Point(197, 3);
    76       this.dataPartitionComboBox.Name = "dataPartitionComboBox";
    77       this.dataPartitionComboBox.Size = new System.Drawing.Size(121, 21);
    78       this.dataPartitionComboBox.TabIndex = 1;
    79       this.dataPartitionComboBox.SelectedIndexChanged += new System.EventHandler(this.dataPartitionComboBox_SelectedIndexChanged);
    80       //
    81       // dataPartitionLabel
    82       //
    83       this.dataPartitionLabel.AutoSize = true;
    84       this.dataPartitionLabel.Location = new System.Drawing.Point(3, 6);
    85       this.dataPartitionLabel.Name = "dataPartitionLabel";
    86       this.dataPartitionLabel.Size = new System.Drawing.Size(73, 13);
    87       this.dataPartitionLabel.TabIndex = 0;
    88       this.dataPartitionLabel.Text = "Data partition:";
    89       //
    90       // numericVarReplacementLabel
    91       //
    92       this.numericVarReplacementLabel.AutoSize = true;
    93       this.numericVarReplacementLabel.Location = new System.Drawing.Point(3, 33);
    94       this.numericVarReplacementLabel.Name = "numericVarReplacementLabel";
    95       this.numericVarReplacementLabel.Size = new System.Drawing.Size(173, 13);
    96       this.numericVarReplacementLabel.TabIndex = 2;
    97       this.numericVarReplacementLabel.Text = "Replacement for numeric variables:";
     60      // ascendingCheckBox
     61      //
     62      this.ascendingCheckBox.AutoSize = true;
     63      this.ascendingCheckBox.Location = new System.Drawing.Point(534, 6);
     64      this.ascendingCheckBox.Name = "ascendingCheckBox";
     65      this.ascendingCheckBox.Size = new System.Drawing.Size(76, 17);
     66      this.ascendingCheckBox.TabIndex = 7;
     67      this.ascendingCheckBox.Text = "Ascending";
     68      this.ascendingCheckBox.UseVisualStyleBackColor = true;
     69      this.ascendingCheckBox.CheckedChanged += new System.EventHandler(this.ascendingCheckBox_CheckedChanged);
     70      //
     71      // sortByLabel
     72      //
     73      this.sortByLabel.AutoSize = true;
     74      this.sortByLabel.Location = new System.Drawing.Point(324, 6);
     75      this.sortByLabel.Name = "sortByLabel";
     76      this.sortByLabel.Size = new System.Drawing.Size(77, 13);
     77      this.sortByLabel.TabIndex = 4;
     78      this.sortByLabel.Text = "Sorting criteria:";
     79      //
     80      // sortByComboBox
     81      //
     82      this.sortByComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     83      this.sortByComboBox.FormattingEnabled = true;
     84      this.sortByComboBox.Items.AddRange(new object[] {
     85            HeuristicLab.Problems.DataAnalysis.Views.RegressionSolutionVariableImpactsView.SortingCriteria.ImpactValue,
     86            HeuristicLab.Problems.DataAnalysis.Views.RegressionSolutionVariableImpactsView.SortingCriteria.Occurrence,
     87            HeuristicLab.Problems.DataAnalysis.Views.RegressionSolutionVariableImpactsView.SortingCriteria.VariableName});
     88      this.sortByComboBox.Location = new System.Drawing.Point(407, 3);
     89      this.sortByComboBox.Name = "sortByComboBox";
     90      this.sortByComboBox.Size = new System.Drawing.Size(121, 21);
     91      this.sortByComboBox.TabIndex = 5;
     92      this.sortByComboBox.SelectedIndexChanged += new System.EventHandler(this.sortByComboBox_SelectedIndexChanged);
     93      //
     94      // factorVarReplComboBox
     95      //
     96      this.factorVarReplComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     97      this.factorVarReplComboBox.FormattingEnabled = true;
     98      this.factorVarReplComboBox.Items.AddRange(new object[] {
     99            HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Best,
     100            HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Mode,
     101            HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Shuffle});
     102      this.factorVarReplComboBox.Location = new System.Drawing.Point(197, 57);
     103      this.factorVarReplComboBox.Name = "factorVarReplComboBox";
     104      this.factorVarReplComboBox.Size = new System.Drawing.Size(121, 21);
     105      this.factorVarReplComboBox.TabIndex = 1;
     106      this.factorVarReplComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged);
     107      //
     108      // factorVarReplacementLabel
     109      //
     110      this.factorVarReplacementLabel.AutoSize = true;
     111      this.factorVarReplacementLabel.Location = new System.Drawing.Point(3, 60);
     112      this.factorVarReplacementLabel.Name = "factorVarReplacementLabel";
     113      this.factorVarReplacementLabel.Size = new System.Drawing.Size(188, 13);
     114      this.factorVarReplacementLabel.TabIndex = 0;
     115      this.factorVarReplacementLabel.Text = "Replacement for categorical variables:";
    98116      //
    99117      // replacementComboBox
    100118      //
     119      this.replacementComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    101120      this.replacementComboBox.FormattingEnabled = true;
    102121      this.replacementComboBox.Items.AddRange(new object[] {
     
    111130      this.replacementComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged);
    112131      //
    113       // factorVarReplacementLabel
    114       //
    115       this.factorVarReplacementLabel.AutoSize = true;
    116       this.factorVarReplacementLabel.Location = new System.Drawing.Point(3, 60);
    117       this.factorVarReplacementLabel.Name = "factorVarReplacementLabel";
    118       this.factorVarReplacementLabel.Size = new System.Drawing.Size(188, 13);
    119       this.factorVarReplacementLabel.TabIndex = 0;
    120       this.factorVarReplacementLabel.Text = "Replacement for categorical variables:";
    121       //
    122       // factorVarReplComboBox
    123       //
    124       this.factorVarReplComboBox.FormattingEnabled = true;
    125       this.factorVarReplComboBox.Items.AddRange(new object[] {
    126             HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Best,
    127             HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Mode,
    128             HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Shuffle});
    129       this.factorVarReplComboBox.Location = new System.Drawing.Point(197, 57);
    130       this.factorVarReplComboBox.Name = "factorVarReplComboBox";
    131       this.factorVarReplComboBox.Size = new System.Drawing.Size(121, 21);
    132       this.factorVarReplComboBox.TabIndex = 1;
    133       this.factorVarReplComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged);
     132      // numericVarReplacementLabel
     133      //
     134      this.numericVarReplacementLabel.AutoSize = true;
     135      this.numericVarReplacementLabel.Location = new System.Drawing.Point(3, 33);
     136      this.numericVarReplacementLabel.Name = "numericVarReplacementLabel";
     137      this.numericVarReplacementLabel.Size = new System.Drawing.Size(173, 13);
     138      this.numericVarReplacementLabel.TabIndex = 2;
     139      this.numericVarReplacementLabel.Text = "Replacement for numeric variables:";
     140      //
     141      // dataPartitionLabel
     142      //
     143      this.dataPartitionLabel.AutoSize = true;
     144      this.dataPartitionLabel.Location = new System.Drawing.Point(3, 6);
     145      this.dataPartitionLabel.Name = "dataPartitionLabel";
     146      this.dataPartitionLabel.Size = new System.Drawing.Size(73, 13);
     147      this.dataPartitionLabel.TabIndex = 0;
     148      this.dataPartitionLabel.Text = "Data partition:";
     149      //
     150      // dataPartitionComboBox
     151      //
     152      this.dataPartitionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     153      this.dataPartitionComboBox.FormattingEnabled = true;
     154      this.dataPartitionComboBox.Items.AddRange(new object[] {
     155            HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.Training,
     156            HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.Test,
     157            HeuristicLab.Problems.DataAnalysis.RegressionSolutionVariableImpactsCalculator.DataPartitionEnum.All});
     158      this.dataPartitionComboBox.Location = new System.Drawing.Point(197, 3);
     159      this.dataPartitionComboBox.Name = "dataPartitionComboBox";
     160      this.dataPartitionComboBox.Size = new System.Drawing.Size(121, 21);
     161      this.dataPartitionComboBox.TabIndex = 1;
     162      this.dataPartitionComboBox.SelectedIndexChanged += new System.EventHandler(this.dataPartitionComboBox_SelectedIndexChanged);
     163      //
     164      // variableImactsArrayView
     165      //
     166      this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     167            | System.Windows.Forms.AnchorStyles.Left)
     168            | System.Windows.Forms.AnchorStyles.Right)));
     169      this.variableImactsArrayView.Caption = "StringConvertibleArray View";
     170      this.variableImactsArrayView.Content = null;
     171      this.variableImactsArrayView.Location = new System.Drawing.Point(3, 84);
     172      this.variableImactsArrayView.Name = "variableImactsArrayView";
     173      this.variableImactsArrayView.ReadOnly = true;
     174      this.variableImactsArrayView.Size = new System.Drawing.Size(706, 278);
     175      this.variableImactsArrayView.TabIndex = 2;
    134176      //
    135177      // RegressionSolutionVariableImpactsView
     
    137179      this.AllowDrop = true;
    138180      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     181      this.Controls.Add(this.ascendingCheckBox);
     182      this.Controls.Add(this.sortByLabel);
     183      this.Controls.Add(this.sortByComboBox);
    139184      this.Controls.Add(this.factorVarReplComboBox);
    140185      this.Controls.Add(this.factorVarReplacementLabel);
     
    145190      this.Controls.Add(this.variableImactsArrayView);
    146191      this.Name = "RegressionSolutionVariableImpactsView";
    147       this.Size = new System.Drawing.Size(369, 365);
     192      this.Size = new System.Drawing.Size(712, 365);
     193      this.VisibleChanged += new System.EventHandler(this.RegressionSolutionVariableImpactsView_VisibleChanged);
    148194      this.ResumeLayout(false);
    149195      this.PerformLayout();
     
    160206    private System.Windows.Forms.Label factorVarReplacementLabel;
    161207    private System.Windows.Forms.ComboBox factorVarReplComboBox;
     208    private System.Windows.Forms.Label sortByLabel;
     209    private System.Windows.Forms.ComboBox sortByComboBox;
     210    private System.Windows.Forms.CheckBox ascendingCheckBox;
    162211  }
    163212}
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    1919 */
    2020#endregion
     21
    2122using System;
     23using System.Collections.Generic;
    2224using System.Linq;
     25using System.Threading;
    2326using System.Threading.Tasks;
     27using HeuristicLab.Common;
    2428using HeuristicLab.Data;
    2529using HeuristicLab.MainForm;
     
    2933  [Content(typeof(IRegressionSolution))]
    3034  public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView {
     35    private CancellationTokenSource cancellationToken = new CancellationTokenSource();
     36    private enum SortingCriteria {
     37      ImpactValue,
     38      Occurrence,
     39      VariableName
     40    }
     41    private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>();
    3142
    3243    public new IRegressionSolution Content {
     
    4051      : base() {
    4152      InitializeComponent();
     53
     54      //Set the default values
    4255      this.dataPartitionComboBox.SelectedIndex = 0;
    43       this.replacementComboBox.SelectedIndex = 0;
     56      this.replacementComboBox.SelectedIndex = 3;
    4457      this.factorVarReplComboBox.SelectedIndex = 0;
    45     }
    46 
    47     #region events
     58      this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue;
     59    }
     60
    4861    protected override void RegisterContentEvents() {
    4962      base.RegisterContentEvents();
     
    7184        variableImactsArrayView.Content = null;
    7285      } else {
    73         UpdateVariableImpacts();
    74       }
    75     }
    76 
    77     private void UpdateVariableImpacts() {
    78       if (Content == null || replacementComboBox.SelectedIndex < 0
    79         || factorVarReplComboBox.SelectedIndex < 0
    80         || dataPartitionComboBox.SelectedIndex < 0) return;
     86        UpdateVariableImpact();
     87      }
     88    }
     89
     90    private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
     91      cancellationToken.Cancel();
     92    }
     93
     94
     95    private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     96      UpdateVariableImpact();
     97    }
     98
     99    private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     100      UpdateVariableImpact();
     101    }
     102
     103    private void sortByComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     104      //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice)
     105      ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged;
     106      ascendingCheckBox.Checked = (SortingCriteria)sortByComboBox.SelectedItem != SortingCriteria.ImpactValue;
     107      ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged;
     108
     109      UpdateOrdering();
     110    }
     111
     112    private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) {
     113      UpdateOrdering();
     114    }
     115
     116
     117    private async void UpdateVariableImpact() {
     118      //Check if the selection is valid
     119      if (Content == null) { return; }
     120      if (replacementComboBox.SelectedIndex < 0) { return; }
     121      if (dataPartitionComboBox.SelectedIndex < 0) { return; }
     122      if (factorVarReplComboBox.SelectedIndex < 0) { return; }
     123
     124      //Prepare arguments
     125      var replMethod = (RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum)replacementComboBox.Items[replacementComboBox.SelectedIndex];
     126      var factorReplMethod = (RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum)factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex];
     127      var dataPartition = (RegressionSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem;
     128
    81129      variableImactsArrayView.Caption = Content.Name + " Variable Impacts";
    82       var replMethod =
    83          (RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum)
    84            replacementComboBox.Items[replacementComboBox.SelectedIndex];
    85       var factorReplMethod =
    86         (RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum)
    87           factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex];
    88       var dataPartition =
    89         (RegressionSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem;
    90 
    91       Task.Factory.StartNew(() => {
    92         try {
    93           Progress.ShowMarquee(this, "Calculating variable impacts for " + Content.Name);
    94 
    95           var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod);
    96           var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
    97           impactArray.ElementNames = impacts.Select(i => i.Item1);
    98           variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly();
    99         } finally {
    100           Progress.Hide(this);
    101         }
    102       });
    103     }
    104 
    105     #endregion
    106 
    107     private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    108       UpdateVariableImpacts();
    109     }
    110 
    111     private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    112       UpdateVariableImpacts();
     130      var progress = Progress.ShowMarquee(this, "Calculating variable impacts for " + Content.Name);
     131      cancellationToken = new CancellationTokenSource();
     132      //Remember the original ordering of the variables
     133      try {
     134        var impacts = await Task.Run(() => RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod,
     135          (i, s) => {
     136            progress.ProgressValue = i;
     137            progress.Message = s;
     138            return cancellationToken.Token.IsCancellationRequested;
     139          }), cancellationToken.Token);
     140
     141        if (cancellationToken.Token.IsCancellationRequested) { return; }
     142        var problemData = Content.ProblemData;
     143        var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction));
     144        var originalVariableOrdering = problemData.Dataset.VariableNames
     145          .Where(v => inputvariables.Contains(v))
     146          .Where(v => problemData.Dataset.VariableHasType<double>(v) || problemData.Dataset.VariableHasType<string>(v))
     147          .ToList();
     148
     149        rawVariableImpacts.Clear();
     150        originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(new Tuple<string, double>(v, impacts.First(vv => vv.Item1 == v).Item2)));
     151        UpdateOrdering();
     152      } finally {
     153        Progress.Hide(this);
     154      }
     155    }
     156
     157    /// <summary>
     158    /// Updates the <see cref="variableImactsArrayView"/> according to the selected ordering <see cref="ascendingCheckBox"/> of the selected Column <see cref="sortByComboBox"/>
     159    /// The default is "Descending" by "VariableImpact" (as in previous versions)
     160    /// </summary>
     161    private void UpdateOrdering() {
     162      //Check if valid sortingCriteria is selected and data exists
     163      if (sortByComboBox.SelectedIndex == -1) { return; }
     164      if (rawVariableImpacts == null) { return; }
     165      if (!rawVariableImpacts.Any()) { return; }
     166
     167      var selectedItem = (SortingCriteria)sortByComboBox.SelectedItem;
     168      bool ascending = ascendingCheckBox.Checked;
     169
     170      IEnumerable<Tuple<string, double>> orderedEntries = null;
     171
     172      //Sort accordingly
     173      switch (selectedItem) {
     174        case SortingCriteria.ImpactValue:
     175          orderedEntries = rawVariableImpacts.OrderBy(v => v.Item2);
     176          break;
     177        case SortingCriteria.Occurrence:
     178          orderedEntries = rawVariableImpacts;
     179          break;
     180        case SortingCriteria.VariableName:
     181          orderedEntries = rawVariableImpacts.OrderBy(v => v.Item1, new NaturalStringComparer());
     182          break;
     183        default:
     184          throw new NotImplementedException("Ordering for selected SortingCriteria not implemented");
     185      }
     186
     187      if (!ascending) { orderedEntries = orderedEntries.Reverse(); }
     188
     189      //Write the data back
     190      var impactArray = new DoubleArray(orderedEntries.Select(i => i.Item2).ToArray()) {
     191        ElementNames = orderedEntries.Select(i => i.Item1)
     192      };
     193
     194      //Could be, if the View was closed
     195      if (!variableImactsArrayView.IsDisposed) {
     196        variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly();
     197      }
    113198    }
    114199  }
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionTimeframeFeatureCorrelationView.Designer.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionTimeframeFeatureCorrelationView.cs

    r16308 r16311  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
Note: See TracChangeset for help on using the changeset viewer.