Class KDTreeFactory

java.lang.Object
org.tribuo.math.neighbour.kdtree.KDTreeFactory
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, Serializable, NeighboursQueryFactory, ProtoSerializable<org.tribuo.math.protos.NeighbourFactoryProto>

public class KDTreeFactory extends Object implements NeighboursQueryFactory
A factory which creates k-d tree nearest neighbour query objects.
See Also:
  • Field Details

    • CURRENT_VERSION

      public static final int CURRENT_VERSION
      Protobuf serialization version.
      See Also:
  • Constructor Details

    • KDTreeFactory

      public KDTreeFactory(Distance distance, int numThreads)
      Constructs a k-d tree nearest neighbor query factory object using the supplied parameters.
      Parameters:
      distance - The distance function.
      numThreads - The number of threads to be used to parallelize the computation.
  • Method Details

    • deserializeFromProto

      public static KDTreeFactory deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException
      Deserialization factory.
      Parameters:
      version - The serialized object version.
      className - The class name.
      message - The serialized data.
      Returns:
      The deserialized object.
      Throws:
      com.google.protobuf.InvalidProtocolBufferException - If the protobuf could not be parsed from the message.
    • serialize

      public org.tribuo.math.protos.NeighbourFactoryProto serialize()
      Description copied from interface: ProtoSerializable
      Serializes this object to a protobuf.
      Specified by:
      serialize in interface ProtoSerializable<org.tribuo.math.protos.NeighbourFactoryProto>
      Returns:
      The protobuf.
    • createNeighboursQuery

      public KDTree createNeighboursQuery(SGDVector[] data)
      Constructs a k-d tree nearest neighbor query object using the supplied array of SGDVector.
      Specified by:
      createNeighboursQuery in interface NeighboursQueryFactory
      Parameters:
      data - An array of SGDVector.
      Returns:
      A query object.
    • getDistance

      public Distance getDistance()
      Description copied from interface: NeighboursQueryFactory
      Gets the Distance set on this object.
      Specified by:
      getDistance in interface NeighboursQueryFactory
      Returns:
      The distance function.
    • getNumThreads

      public int getNumThreads()
      Description copied from interface: NeighboursQueryFactory
      Get the number of threads set on this object. There could be factory implementations that are sequential, meaning they are single threaded.
      Specified by:
      getNumThreads in interface NeighboursQueryFactory
      Returns:
      The number of threads used to parallelize the query operation.
    • postConfig

      public void postConfig()
      Used by the OLCUT configuration system, and should not be called by external code.
      Specified by:
      postConfig in interface com.oracle.labs.mlrg.olcut.config.Configurable
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object