Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/17 15:17:41 (7 years ago)
Author:
bwerth
Message:

#2700 worked on TSNE (mostly removing unused code)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/VantagePointTree.cs

    r14862 r15207  
    6868  /// </summary>
    6969  /// <typeparam name="T"></typeparam>
    70   public class VantagePointTree<T> : IVantagePointTree<T> {
    71     #region properties
     70  public class VantagePointTree<T> {
    7271    private readonly List<T> items;
    7372    private readonly Node root;
    7473    private readonly IDistance<T> distance;
    75     #endregion
    7674
    7775    public VantagePointTree(IDistance<T> distance, IEnumerable<T> items) : base() {
     
    8280    }
    8381
     82    /// <summary>
     83    /// provides the k-nearest neighbours to a certain target element
     84    /// </summary>
     85    /// <param name="target">The target element</param>
     86    /// <param name="k">How many neighbours</param>
     87    /// <param name="results">The nearest neighbouring elements</param>
     88    /// <param name="distances">The distances form the target corresponding to the neighbouring elements</param>
    8489    public void Search(T target, int k, out IList<T> results, out IList<double> distances) {
    8590      var heap = new PriorityQueue<double, IndexedItem<double>>(double.MaxValue, double.MinValue, k);
    86       double tau = double.MaxValue;
     91      var tau = double.MaxValue;
    8792      Search(root, target, k, heap, ref tau);
    8893      var res = new List<T>();
    8994      var dist = new List<double>();
    9095      while (heap.Size > 0) {
    91         res.Add(items[heap.PeekMinValue().Index]);          // actually max distance
     96        res.Add(items[heap.PeekMinValue().Index]);// actually max distance
    9297        dist.Add(heap.PeekMinValue().Value);
    9398        heap.RemoveMin();
    9499      }
    95       res.Reverse(); 
     100      res.Reverse();
    96101      dist.Reverse();
    97102      results = res;
     
    104109      if (dist < tau) {
    105110        if (heap.Size == k) heap.RemoveMin();   // remove furthest node from result list (if we already have k results)
    106         heap.Insert(-dist, new IndexedItem<double>(node.index, dist));     
     111        heap.Insert(-dist, new IndexedItem<double>(node.index, dist));
    107112        if (heap.Size == k) tau = heap.PeekMinValue().Value;
    108113      }
Note: See TracChangeset for help on using the changeset viewer.