Changeset 17416 for branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression
- Timestamp:
- 01/31/20 16:21:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs
r17180 r17416 195 195 originalValues = modifiableDataset.GetReadOnlyStringValues(variableName).ToList(); 196 196 replacementValues = GetReplacementValuesForString(model, modifiableDataset, variableName, rows, (List<string>)originalValues, targetValues, factorReplacementMethod); 197 } else if (modifiableDataset.VariableHasType<DoubleVector>(variableName)) { 198 originalValues = modifiableDataset.GetReadOnlyDoubleVectorValues(variableName).ToList(); 199 replacementValues = GetReplacementValuesForDoubleVector(modifiableDataset, rows, (List<DoubleVector>)originalValues, replacementMethod); 197 200 } else { 198 201 throw new NotSupportedException("Variable not supported"); … … 303 306 } 304 307 308 private static IList GetReplacementValuesForDoubleVector(ModifiableDataset modifiableDataset, 309 IEnumerable<int> rows, 310 List<DoubleVector> originalValues, 311 ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle) { 312 313 IRandom random = new FastRandom(31415); 314 List<DoubleVector> replacementValues; 315 DoubleVector replacementValue; 316 317 switch (replacementMethod) { 318 case ReplacementMethodEnum.Shuffle: 319 // new var has same empirical distribution but the relation to y is broken 320 // prepare a complete column for the dataset 321 replacementValues = Enumerable.Repeat(new DoubleVector(new[] { double.NaN }), modifiableDataset.Rows).ToList(); 322 // shuffle only the selected rows 323 var shuffledValues = rows.Select(r => originalValues[r]).Shuffle(random).ToList(); 324 int i = 0; 325 // update column values 326 foreach (var r in rows) { 327 replacementValues[r] = shuffledValues[i++]; 328 } 329 break; 330 331 default: 332 throw new ArgumentException(string.Format("ReplacementMethod {0} cannot be handled.", replacementMethod)); 333 } 334 335 return replacementValues; 336 } 337 305 338 private static double CalculateQualityForReplacement( 306 339 IRegressionModel model,
Note: See TracChangeset
for help on using the changeset viewer.