Free cookie consent management tool by TermsFeed Policy Generator

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

#2673: merged r14348 and 14463 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • 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.