Changeset 13791 for branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/KNearestNeighborRecommender.cs
- Timestamp:
- 04/25/16 12:56:17 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/KNearestNeighborRecommender.cs
r13787 r13791 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Optimization; 25 26 using HeuristicLab.Parameters; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System.Linq; 27 29 28 30 namespace HeuristicLab.OptimizationExpertSystem.Common { … … 37 39 [StorableConstructor] 38 40 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) { } 41 42 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))); 43 44 } 44 45 … … 47 48 } 48 49 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); 51 54 } 52 55 }
Note: See TracChangeset
for help on using the changeset viewer.