Package org.tribuo.math.distance
Class CosineDistance
java.lang.Object
org.tribuo.math.distance.CosineDistance
- 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
,Distance
,ProtoSerializable<org.tribuo.math.protos.DistanceProto>
Cosine similarity used as a distance measure.
- 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
-
Method Summary
Modifier and TypeMethodDescriptiondouble
computeDistance
(SGDVector first, SGDVector second) Computes the distance between the two vectors.static CosineDistance
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance
int
hashCode()
org.tribuo.math.protos.DistanceProto
Serializes this object to a protobuf.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfig
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
CosineDistance
public CosineDistance()Constructs a Cosine distance function.
-
-
Method Details
-
deserializeFromProto
public static CosineDistance deserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.- Parameters:
version
- The serialized object version.className
- The class name.message
- The serialized data.- Returns:
- The deserialized object.
-
serialize
public org.tribuo.math.protos.DistanceProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Specified by:
serialize
in interfaceProtoSerializable<org.tribuo.math.protos.DistanceProto>
- Returns:
- The protobuf.
-
computeDistance
Description copied from interface:Distance
Computes the distance between the two vectors.- Specified by:
computeDistance
in interfaceDistance
- Parameters:
first
- The first vector.second
- The second vector.- Returns:
- The distance between them.
-
equals
-
hashCode
public int hashCode() -
toString
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
-