Changeset 17416
- Timestamp:
- 01/31/20 16:21:00 (5 years ago)
- Location:
- branches/3040_VectorBasedGP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r17276 r17416 141 141 var originalVariableOrdering = problemData.Dataset.VariableNames 142 142 .Where(v => inputvariables.Contains(v)) 143 .Where(v => problemData.Dataset.VariableHasType<double>(v) || problemData.Dataset.VariableHasType<string>(v))143 //.Where(v => problemData.Dataset.VariableHasType<double>(v) || problemData.Dataset.VariableHasType<string>(v)) 144 144 .ToList(); 145 145 -
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.