Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/27/16 16:21:07 (8 years ago)
Author:
abeham
Message:

#2457:

  • changed expected runtime calculation
    • now outputs positive infinity instead of nan when no run was successful
    • now filters outliers in successful and unsuccessful runs by using two standard deviations of the mean of successful runs as lower bound
      • this change allows having unsuccessful runs in the database with low evaluations / runtime (e.g. due to being aborted early or from an experiment where the max budget was lower)
  • worked on recommendation algorithms
    • implemented several performance measures (absolute error, absolute log error, ndcp, kendall's tau) to evaluate the ranking
File:
1 edited

Legend:

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

    r13794 r13803  
    4949      var feature = KnowledgeCenter.GetFeatures(new [] { problemInstance }, characteristics, medianValues)[0];
    5050      var nearestK = features.Select((f, i) => new { ProblemInstanceIndex = i, Feature = f })
    51                              .OrderBy(x => x.Feature.Select((f, i) => (f - feature[i]) * (f - feature[i])).Sum())
    52                              .Take(K);
     51                             .OrderBy(x => x.Feature.Select((f, i) => (f - feature[i]) * (f - feature[i])).Sum());
    5352     
    54       var performances = new Dictionary<IAlgorithm, List<double>>();
     53      var performances = new Dictionary<IAlgorithm, Performance>();
     54
     55      var k = 0;
    5556      foreach (var next in nearestK) {
     57        if (k >= K) break;
    5658        var perfs = performance[problemInstanceMap.GetByFirst(next.ProblemInstanceIndex)];
    5759        if (perfs.Count == 0) continue;
     
    5961        foreach (var p in perfs) {
    6062          var ert = p.Value;
    61           if (double.IsNaN(ert)) ert = int.MaxValue;
    62           List<double> erts;
    63           if (!performances.TryGetValue(p.Key, out erts)) {
    64             performances[p.Key] = new List<double>() { ert }; ;
    65           } else erts.Add(ert);
     63          Performance perf;
     64          if (!performances.TryGetValue(p.Key, out perf)) {
     65            perf = new Performance();
     66            performances[p.Key] = perf;
     67          }
     68          perf.Add(ert);
    6669        }
     70
     71        k++;
    6772      }
    6873
    69       return performances.Select(x => new { Alg = x.Key, Perf = x.Value.Average() })
     74      return performances.Select(x => new { Alg = x.Key, Perf = x.Value.ExpectedRuntime() })
    7075                         .OrderBy(x => x.Perf)
    7176                         .Select(x => new KeyValuePair<IAlgorithm, double>(x.Alg, x.Perf));
    7277    }
     78
     79    private class Performance {
     80      private readonly List<double> successful;
     81      private int runs;
     82      public int Fails { get { return runs - successful.Count; } }
     83
     84      public Performance() {
     85        successful = new List<double>();
     86      }
     87
     88      public void Add(double ert) {
     89        if (!double.IsInfinity(ert)) successful.Add(ert);
     90        runs++;
     91      }
     92
     93      public double ExpectedRuntime() {
     94        if (successful.Count == 0) return int.MaxValue;
     95        return successful.Average() / (successful.Count / (double)runs);
     96      }
     97    }
    7398  }
    7499}
Note: See TracChangeset for help on using the changeset viewer.