org.apache.ignite.ml.knn.utils.indices

## Class BallTreeSpatialIndex<L>

- java.lang.Object
- - org.apache.ignite.ml.knn.utils.indices.BallTreeSpatialIndex<L>

- Type Parameters:
    `L` - Label type.
  All Implemented Interfaces:
    AutoCloseable, SpatialIndex<L>

      public class BallTreeSpatialIndex<L>
      extends Object
      implements SpatialIndex<L>

  Ball tree based implementation of `SpatialIndex`. Asymptotic runtime complexity of finding `k` closest elements is `O(log(n)*k)`, but it degrades on high dimensional data.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BallTreeSpatialIndex(List<LabeledVector<L>> data, DistanceMeasure distanceMeasure)` Constructs a new instance of Ball tree spatial index.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<LabeledVector<L>>` | `findKClosest(int k, Vector pnt)` Finds `k` closest elements to the specified point.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.ignite.ml.knn.utils.indices.SpatialIndex

      `close`

- - ### Constructor Detail

    - #### BallTreeSpatialIndex

          public BallTreeSpatialIndex(List<LabeledVector<L>> data,
                                      DistanceMeasure distanceMeasure)

      Constructs a new instance of Ball tree spatial index.
      Parameters:
        `data` - Data.
        `distanceMeasure` - Distance measure.

  - ### Method Detail

    - #### findKClosest

          public List<LabeledVector<L>> findKClosest(int k,
                                                     Vector pnt)

      Finds `k` closest elements to the specified point.
      Specified by:
        `findKClosest` in interface `SpatialIndex<L>`
      Parameters:
        `k` - Number of elements to be returned.
        `pnt` - Point to be used to calculate distance to other points.
      Returns:
        An array of the `k` closest elements to the specified point.

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020