Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15024


Ignore:
Timestamp:
06/03/17 19:32:50 (8 years ago)
Author:
gkronber
Message:

#2779: hide 'constant variables' (only one distinct value)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs

    r14943 r15024  
    2020#endregion
    2121using System;
     22using System.Collections.Generic;
    2223using System.Drawing;
    2324using System.Linq;
     25using HeuristicLab.Common;
    2426using HeuristicLab.Data;
    2527using HeuristicLab.MainForm;
     
    8688      var ds = problemData.Dataset;
    8789      var runs = new RunCollection();
     90      // determine relevant variables (at least two different values)
     91      var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Max() > ds.GetDoubleValues(vn).Min()).ToArray();
     92      var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray();
     93
    8894      // produce training and test values separately as they might overlap (e.g. for ensembles)
    8995      var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray();
    9096      int j = 0; // idx for predictedValues array
    9197      foreach (var i in problemData.TrainingIndices) {
    92         var run = CreateRunForIdx(i, problemData);
     98        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars);
    9399        var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    94100        AddErrors(run, predictedValuesTrain[j++], targetValue);
     
    100106      j = 0;
    101107      foreach (var i in problemData.TestIndices) {
    102         var run = CreateRunForIdx(i, problemData);
     108        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars);
    103109        var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    104110        AddErrors(run, predictedValuesTest[j++], targetValue);
     
    127133    }
    128134
    129     private IRun CreateRunForIdx(int i, IRegressionProblemData problemData) {
     135    private IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars) {
    130136      var ds = problemData.Dataset;
    131137      var run = new Run();
    132       foreach (var variableName in ds.DoubleVariables) {
     138      foreach (var variableName in doubleVars) {
    133139        run.Results.Add(variableName, new DoubleValue(ds.GetDoubleValue(variableName, i)));
    134140      }
    135       foreach (var variableName in ds.StringVariables) {
     141      foreach (var variableName in stringVars) {
    136142        run.Results.Add(variableName, new StringValue(ds.GetStringValue(variableName, i)));
    137143      }
    138 
    139144      return run;
    140145    }
Note: See TracChangeset for help on using the changeset viewer.