Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/08/12 12:10:38 (12 years ago)
Author:
sforsten
Message:

#1292: implemented changes suggested by mkommend in comment:49:ticket:1292

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCalculator.cs

    r8874 r8880  
    7373
    7474    private void CalculateElements(Dataset dataset, IDependencyCalculator calc, string partition, string variable = null, int frames = 0, double[,] alreadyCalculated = null) {
    75       bwInfo = new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition, Variable = variable, Frames = frames, AlreadyCalculated = alreadyCalculated };
     75      var indices = GetRelevantIndices(problemData, partition);
     76      bwInfo = new BackgroundWorkerInfo {
     77        Dataset = dataset, Calculator = calc, Partition = partition, Indices = indices,
     78        Variable = variable, Frames = frames, AlreadyCalculated = alreadyCalculated
     79      };
    7680      if (bw == null) {
    7781        bw = new BackgroundWorker();
     
    8993    }
    9094
     95    private IEnumerable<int> GetRelevantIndices(IDataAnalysisProblemData problemData, string partition) {
     96      IEnumerable<int> var;
     97      if (partition.Equals(AbstractFeatureCorrelationView.TRAININGSAMPLES))
     98        var = problemData.TrainingIndices;
     99      else if (partition.Equals(AbstractFeatureCorrelationView.TESTSAMPLES))
     100        var = problemData.TestIndices;
     101      else var = Enumerable.Range(0, problemData.Dataset.Rows);
     102      return var;
     103    }
     104
    91105    #region backgroundworker
    92106    private void BwDoWork(object sender, DoWorkEventArgs e) {
     
    104118      BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument;
    105119      Dataset dataset = bwInfo.Dataset;
    106       string partition = bwInfo.Partition;
     120      IEnumerable<int> indices = bwInfo.Indices;
    107121      IDependencyCalculator calc = bwInfo.Calculator;
    108122
     
    122136            return;
    123137          }
    124           IEnumerable<double> var1 = GetRelevantValues(problemData, partition, doubleVariableNames[i]);
    125           IEnumerable<double> var2 = GetRelevantValues(problemData, partition, doubleVariableNames[j]);
     138          IEnumerable<double> var1 = problemData.Dataset.GetDoubleValues(doubleVariableNames[i], indices);
     139          IEnumerable<double> var2 = problemData.Dataset.GetDoubleValues(doubleVariableNames[j], indices);
    126140
    127141          elements[i, j] = calc.Calculate(var1, var2, out error);
     
    143157      BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument;
    144158      Dataset dataset = bwInfo.Dataset;
    145       string partition = bwInfo.Partition;
     159      IEnumerable<int> indices = bwInfo.Indices;
    146160      IDependencyCalculator calc = bwInfo.Calculator;
    147161      string variable = bwInfo.Variable;
     
    173187          }
    174188
    175           IEnumerable<double> var1 = GetRelevantValues(problemData, partition, variable);
    176           IEnumerable<double> var2 = GetRelevantValues(problemData, partition, doubleVariableNames[i]);
     189          IEnumerable<double> var1 = problemData.Dataset.GetDoubleValues(variable, indices);
     190          IEnumerable<double> var2 = problemData.Dataset.GetDoubleValues(doubleVariableNames[i], indices);
    177191
    178192          var valuesInFrame = var1.Take(j);
     
    191205      e.Result = elements;
    192206      worker.ReportProgress(100);
    193     }
    194 
    195     private IEnumerable<double> GetRelevantValues(IDataAnalysisProblemData problemData, string partition, string variable) {
    196       IEnumerable<double> var;
    197       if (partition.Equals(FeatureCorrelationPartitions.TRAININGSAMPLES))
    198         var = problemData.Dataset.GetDoubleValues(variable, problemData.TrainingIndices);
    199       else if (partition.Equals(FeatureCorrelationPartitions.TESTSAMPLES))
    200         var = problemData.Dataset.GetDoubleValues(variable, problemData.TestIndices);
    201       else var = problemData.Dataset.GetDoubleValues(variable);
    202       return var;
    203207    }
    204208
     
    254258      public IDependencyCalculator Calculator { get; set; }
    255259      public string Partition { get; set; }
     260      public IEnumerable<int> Indices { get; set; }
    256261      public string Variable { get; set; }
    257262      public int Frames { get; set; }
Note: See TracChangeset for help on using the changeset viewer.