Changeset 8880 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCalculator.cs
- Timestamp:
- 11/08/12 12:10:38 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCalculator.cs
r8874 r8880 73 73 74 74 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 }; 76 80 if (bw == null) { 77 81 bw = new BackgroundWorker(); … … 89 93 } 90 94 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 91 105 #region backgroundworker 92 106 private void BwDoWork(object sender, DoWorkEventArgs e) { … … 104 118 BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument; 105 119 Dataset dataset = bwInfo.Dataset; 106 string partition = bwInfo.Partition;120 IEnumerable<int> indices = bwInfo.Indices; 107 121 IDependencyCalculator calc = bwInfo.Calculator; 108 122 … … 122 136 return; 123 137 } 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); 126 140 127 141 elements[i, j] = calc.Calculate(var1, var2, out error); … … 143 157 BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument; 144 158 Dataset dataset = bwInfo.Dataset; 145 string partition = bwInfo.Partition;159 IEnumerable<int> indices = bwInfo.Indices; 146 160 IDependencyCalculator calc = bwInfo.Calculator; 147 161 string variable = bwInfo.Variable; … … 173 187 } 174 188 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); 177 191 178 192 var valuesInFrame = var1.Take(j); … … 191 205 e.Result = elements; 192 206 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;203 207 } 204 208 … … 254 258 public IDependencyCalculator Calculator { get; set; } 255 259 public string Partition { get; set; } 260 public IEnumerable<int> Indices { get; set; } 256 261 public string Variable { get; set; } 257 262 public int Frames { get; set; }
Note: See TracChangeset
for help on using the changeset viewer.