Ignore:
Timestamp:
06/07/16 16:29:59 (3 years ago)
Author:
abeham
Message:

#2457: added standardization of features for recommendation and using log10 of the expected runtime for clustering

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/KNearestNeighborModel.cs

    r13803 r13878  
    2121
    2222using HeuristicLab.Collections;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Optimization;
     25using System;
    2426using System.Collections.Generic;
    2527using System.Linq;
     
    4648
    4749    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);
    4952      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      }
    5057      var nearestK = features.Select((f, i) => new { ProblemInstanceIndex = i, Feature = f })
    5158                             .OrderBy(x => x.Feature.Select((f, i) => (f - feature[i]) * (f - feature[i])).Sum());
     
    6067       
    6168        foreach (var p in perfs) {
    62           var ert = p.Value;
     69          var ert = Math.Pow(10, p.Value);
    6370          Performance perf;
    6471          if (!performances.TryGetValue(p.Key, out perf)) {
Note: See TracChangeset for help on using the changeset viewer.