Changeset 13878 for branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/KNearestNeighborModel.cs
- Timestamp:
- 06/07/16 16:29:59 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/KNearestNeighborModel.cs
r13803 r13878 21 21 22 22 using HeuristicLab.Collections; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Optimization; 25 using System; 24 26 using System.Collections.Generic; 25 27 using System.Linq; … … 46 48 47 49 public IEnumerable<KeyValuePair<IAlgorithm, double>> GetRanking(IRun problemInstance) { 48 var features = KnowledgeCenter.GetFeatures(performance.Keys.OrderBy(problemInstanceMap.GetBySecond).ToArray(), characteristics, medianValues); 50 double[] means, sdevs; 51 var features = KnowledgeCenter.GetFeaturesStandardized(performance.Keys.OrderBy(problemInstanceMap.GetBySecond).ToArray(), characteristics, out means, out sdevs, medianValues); 49 52 var feature = KnowledgeCenter.GetFeatures(new [] { problemInstance }, characteristics, medianValues)[0]; 53 for (var f = 0; f < feature.Length; f++) { 54 if (sdevs[f].IsAlmost(0)) feature[f] = 0; 55 else feature[f] = (feature[f] - means[f]) / sdevs[f]; 56 } 50 57 var nearestK = features.Select((f, i) => new { ProblemInstanceIndex = i, Feature = f }) 51 58 .OrderBy(x => x.Feature.Select((f, i) => (f - feature[i]) * (f - feature[i])).Sum()); … … 60 67 61 68 foreach (var p in perfs) { 62 var ert = p.Value;69 var ert = Math.Pow(10, p.Value); 63 70 Performance perf; 64 71 if (!performances.TryGetValue(p.Key, out perf)) {
Note: See TracChangeset
for help on using the changeset viewer.