Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/25/16 12:56:17 (8 years ago)
Author:
abeham
Message:

#2457: working on recommendation algorithms

File:
1 edited

Legend:

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

    r13787 r13791  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.Optimization;
    2526using HeuristicLab.Parameters;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using System.Linq;
    2729
    2830namespace HeuristicLab.OptimizationExpertSystem.Common {
     
    3739    [StorableConstructor]
    3840    private KNearestNeighborRecommender(bool deserializing) : base(deserializing) { }
    39     private KNearestNeighborRecommender(KNearestNeighborRecommender original, Cloner cloner)
    40       : base(original, cloner) { }
     41    private KNearestNeighborRecommender(KNearestNeighborRecommender original, Cloner cloner) : base(original, cloner) { }
    4142    public KNearestNeighborRecommender() {
    42       Parameters.Add(new FixedValueParameter<IntValue>("K", "The number of nearest neighbors to consider.", new IntValue(5)));
     43      Parameters.Add(new FixedValueParameter<IntValue>("K", "The number of nearest neighbors to consider.", new IntValue(3)));
    4344    }
    4445
     
    4748    }
    4849
    49     public IRecommendationModel TrainModel(KnowledgeCenter kc, string[] characteristics) {
    50       return new KNearestNeighborModel(KParameter.Value.Value, characteristics);
     50    public IRecommendationModel TrainModel(IRun[] problemInstances, KnowledgeCenter kc, string[] characteristics) {
     51      var perfData = problemInstances.Select(pi => new { ProblemInstance = pi, Performance = kc.GetAlgorithmPerformance(pi) })
     52                                     .ToDictionary(x => x.ProblemInstance, x => x.Performance);
     53      return new KNearestNeighborModel(KParameter.Value.Value, perfData, characteristics);
    5154    }
    5255  }
Note: See TracChangeset for help on using the changeset viewer.