Changeset 15736 for branches/1614_GeneralizedQAP/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders
- Timestamp:
- 02/07/18 20:55:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1614_GeneralizedQAP/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/KNearestNeighborModel.cs
r13878 r15736 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Collections; 23 26 using HeuristicLab.Common; 24 27 using HeuristicLab.Optimization; 25 using System;26 using System.Collections.Generic;27 using System.Linq;28 28 29 29 namespace HeuristicLab.OptimizationExpertSystem.Common { … … 55 55 else feature[f] = (feature[f] - means[f]) / sdevs[f]; 56 56 } 57 var dist = features.Select((f, i) => Math.Sqrt(f.Select((g, j) => Math.Sqrt((g - feature[j]) * (g - feature[j]))).Sum())).ToList(); 57 58 var nearestK = features.Select((f, i) => new { ProblemInstanceIndex = i, Feature = f }) 58 .OrderBy(x => x.Feature.Select((f, i) => (f - feature[i]) * (f - feature[i])).Sum());59 .OrderBy(x => dist[x.ProblemInstanceIndex]); 59 60 60 61 var performances = new Dictionary<IAlgorithm, Performance>();
Note: See TracChangeset
for help on using the changeset viewer.