Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/28/20 10:56:16 (5 years ago)
Author:
mkommend
Message:

#2521: Merged trunk changes from 15684-HEAD into the branch.

Location:
branches/2521_ProblemRefactoring
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring

  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views

  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs

    r17226 r17457  
    9393      var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();
    9494
    95       // produce training and test values separately as they might overlap (e.g. for ensembles)
    96       var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray();
    97       int j = 0; // idx for predictedValues array
    98       foreach (var i in problemData.TrainingIndices) {
     95      var predictedValues = Content.EstimatedValues.ToArray();
     96      foreach (var i in problemData.AllIndices) {
    9997        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    10098        var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    101         AddErrors(run, predictedValuesTrain[j++], targetValue);
    102         run.Results.Add(PartitionLabel, new StringValue("Training"));
    103         run.Color = Color.Gold;
     99        AddErrors(run, predictedValues[i], targetValue);
     100
     101        if (problemData.IsTrainingSample(i) && problemData.IsTestSample(i)) {
     102          run.Results.Add(PartitionLabel, new StringValue("Training + Test"));
     103          run.Color = Color.Orange;
     104        } else if (problemData.IsTrainingSample(i)) {
     105          run.Results.Add(PartitionLabel, new StringValue("Training"));
     106          run.Color = Color.Gold;
     107        } else if (problemData.IsTestSample(i)) {
     108          run.Results.Add(PartitionLabel, new StringValue("Test"));
     109          run.Color = Color.Red;
     110        } else {
     111          run.Results.Add(PartitionLabel, new StringValue("Additional Data"));
     112          run.Color = Color.Black;
     113        }
    104114        runs.Add(run);
    105115      }
    106       var predictedValuesTest = Content.EstimatedTestValues.ToArray();
    107       j = 0;
    108       foreach (var i in problemData.TestIndices) {
    109         var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    110         var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    111         AddErrors(run, predictedValuesTest[j++], targetValue);
    112         run.Results.Add(PartitionLabel, new StringValue("Test"));
    113         run.Color = Color.Red;
    114         runs.Add(run);
    115       }
     116
    116117      if (string.IsNullOrEmpty(selectedXAxis))
    117118        selectedXAxis = "Index";
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs

    r17333 r17457  
    2525using System.Threading;
    2626using System.Threading.Tasks;
     27using System.Windows.Forms;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Data;
     
    4041    private CancellationTokenSource cancellationToken = new CancellationTokenSource();
    4142    private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>();
    42     private bool attachedToProgress = false;
    4343
    4444    public new IRegressionSolution Content {
     
    8888    }
    8989
    90     protected override void OnHidden(EventArgs e) {
    91       base.OnHidden(e);
     90    protected override void OnVisibleChanged(EventArgs e) {
     91      base.OnVisibleChanged(e);
     92      if (!this.Visible) {
     93        cancellationToken.Cancel();
     94      }
     95    }
     96
     97    protected override void OnClosed(FormClosedEventArgs e) {
     98      base.OnClosed(e);
    9299      cancellationToken.Cancel();
    93 
    94       if (attachedToProgress) {
    95         Progress.Hide(this);
    96         attachedToProgress = false;
    97       }
    98100    }
    99101
     
    132134      variableImpactsArrayView.Caption = Content.Name + " Variable Impacts";
    133135      var progress = Progress.Show(this, "Calculating variable impacts for " + Content.Name);
    134       attachedToProgress = true;
    135136      cancellationToken = new CancellationTokenSource();
    136137
     
    144145          .ToList();
    145146
    146         List<Tuple<string, double>> impacts = null;
    147         await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); });
    148         if (impacts == null) { return; }
     147        var impacts = await Task.Run(() => CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress));
    149148
    150149        rawVariableImpacts.AddRange(impacts);
    151150        UpdateOrdering();
     151      } catch (OperationCanceledException) {
    152152      } finally {
    153         if (attachedToProgress) {
    154           Progress.Hide(this);
    155           attachedToProgress = false;
    156         }
     153        Progress.Hide(this);
    157154      }
    158155    }
     
    179176
    180177      foreach (var variableName in originalVariableOrdering) {
    181         if (cancellationToken.Token.IsCancellationRequested) { return null; }
     178        token.ThrowIfCancellationRequested();
    182179        progress.ProgressValue = (double)++i / count;
    183180        progress.Message = string.Format("Calculating impact for variable {0} ({1} of {2})", variableName, i, count);
Note: See TracChangeset for help on using the changeset viewer.