Package org.tribuo.math.neighbour.kdtree
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>
A factory which creates k-d tree nearest neighbour query objects.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Protobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionKDTreeFactory
(Distance distance, int numThreads) Constructs a k-d tree nearest neighbor query factory object using the supplied parameters. -
Method Summary
Modifier and TypeMethodDescriptioncreateNeighboursQuery
(SGDVector[] data) Constructs a k-d tree nearest neighbor query object using the supplied array ofSGDVector
.static KDTreeFactory
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
Gets theDistance
set on this object.int
Get the number of threads set on this object.int
hashCode()
void
Used by the OLCUT configuration system, and should not be called by external code.org.tribuo.math.protos.NeighbourFactoryProto
Serializes this object to a protobuf.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.tribuo.math.neighbour.NeighboursQueryFactory
getProvenance
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
KDTreeFactory
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 themessage
.
-
serialize
public org.tribuo.math.protos.NeighbourFactoryProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Specified by:
serialize
in interfaceProtoSerializable<org.tribuo.math.protos.NeighbourFactoryProto>
- Returns:
- The protobuf.
-
createNeighboursQuery
Constructs a k-d tree nearest neighbor query object using the supplied array ofSGDVector
.- Specified by:
createNeighboursQuery
in interfaceNeighboursQueryFactory
- Parameters:
data
- An array ofSGDVector
.- Returns:
- A query object.
-
getDistance
Description copied from interface:NeighboursQueryFactory
Gets theDistance
set on this object.- Specified by:
getDistance
in interfaceNeighboursQueryFactory
- 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 interfaceNeighboursQueryFactory
- 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 interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
equals
-
hashCode
public int hashCode()
-