Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17808 for stable


Ignore:
Timestamp:
12/30/20 09:47:47 (4 years ago)
Author:
gkronber
Message:

#3038: merged r17341 and r17539 from trunk to stable

Location:
stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Views

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

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs

    r17181 r17808  
    8888      var ds = problemData.Dataset;
    8989      var runs = new RunCollection();
    90       // determine relevant variables (at least two different values)
    91       var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Distinct().Skip(1).Any()).ToArray();
    92       var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray();
    93       var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();
    9490
    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) {
     91      var doubleVars = ds.DoubleVariables.ToArray();
     92      var stringVars = ds.StringVariables.ToArray();
     93      var dateTimeVars = ds.DateTimeVariables.ToArray();
     94
     95      var predictedValues = Content.EstimatedValues.ToArray();
     96      var targetValues = ds.GetReadOnlyDoubleValues(problemData.TargetVariable);
     97
     98      foreach (var i in problemData.AllIndices) {
    9999        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    100         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;
     100        AddErrors(run, predictedValues[i], targetValues[i]);
     101
     102        if (problemData.IsTrainingSample(i) && problemData.IsTestSample(i)) {
     103          run.Results.Add(PartitionLabel, new StringValue("Training + Test"));
     104          run.Color = Color.Orange;
     105        } else if (problemData.IsTrainingSample(i)) {
     106          run.Results.Add(PartitionLabel, new StringValue("Training"));
     107          run.Color = Color.Gold;
     108        } else if (problemData.IsTestSample(i)) {
     109          run.Results.Add(PartitionLabel, new StringValue("Test"));
     110          run.Color = Color.Red;
     111        } else {
     112          run.Results.Add(PartitionLabel, new StringValue("Additional Data"));
     113          run.Color = Color.Black;
     114        }
    104115        runs.Add(run);
    105116      }
    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       }
     117
    116118      if (string.IsNullOrEmpty(selectedXAxis))
    117119        selectedXAxis = "Index";
     
    124126    }
    125127
    126     private void AddErrors(IRun run, double pred, double target) {
     128    private static void AddErrors(IRun run, double pred, double target) {
    127129      var residual = target - pred;
    128130      var relError = residual / target;
     
    135137    }
    136138
    137     private IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars, IEnumerable<string> dateTimeVars) {
     139    private static IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars, IEnumerable<string> dateTimeVars) {
    138140      var ds = problemData.Dataset;
    139141      var run = new Run();
Note: See TracChangeset for help on using the changeset viewer.