Class ClusterID
java.lang.Object
org.tribuo.clustering.ClusterID
- All Implemented Interfaces:
Serializable,Output<ClusterID>,ProtoSerializable<org.tribuo.protos.core.OutputProto>
A clustering id.
The id is an int, referring to a cluster stored in the model. Optionally contains a score representing the strength of association with that cluster, if available.
The id is UNASSIGNED if the output is not assigned to a
cluster (e.g., before the Model has been trained).
- See Also:
-
Field Summary
FieldsFields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionClusterID(int id) Creates a ClusterID with the sentinel score ofDouble.NaN.ClusterID(int id, double score) Creates a ClusterID with the specified id number and score. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Deep copy of the output up to its immutable state.static ClusterIDdeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.booleanbooleanCompares other to this output.intgetID()Gets the cluster id number.doublegetScore()Get a real valued score for this ClusterID.getSerializableForm(boolean includeConfidence) Returns "id" or "id,score=idScore".inthashCode()org.tribuo.protos.core.OutputProtoSerializes this object to a protobuf.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tribuo.Output
fullEquals
-
Field Details
-
UNASSIGNED
public static final int UNASSIGNEDThe sentinel unassigned cluster ID.- See Also:
-
-
Constructor Details
-
ClusterID
public ClusterID(int id) Creates a ClusterID with the sentinel score ofDouble.NaN.- Parameters:
id- The cluster id number.
-
ClusterID
public ClusterID(int id, double score) Creates a ClusterID with the specified id number and score.- Parameters:
id- The cluster id number.score- The score.
-
-
Method Details
-
deserializeFromProto
public static ClusterID 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.protos.core.OutputProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.protos.core.OutputProto>- Returns:
- The protobuf.
-
getScore
public double getScore()Get a real valued score for this ClusterID.If the score is not set then it returns Double.NaN.
- Returns:
- The predicted score for this cluster id.
-
getID
public int getID()Gets the cluster id number.- Returns:
- A int.
-
equals
-
hashCode
-
fullEquals
Description copied from interface:OutputCompares other to this output. Uses all score values and the strings.- Specified by:
fullEqualsin interfaceOutput<ClusterID>- Parameters:
o- Another output instance.- Returns:
- True if the other instance has value equality to this instance. False otherwise.
-
toString
-
copy
-
getSerializableForm
Returns "id" or "id,score=idScore".- Specified by:
getSerializableFormin interfaceOutput<ClusterID>- Parameters:
includeConfidence- Include whatever confidence score the clusterID contains, if known.- Returns:
- A string representing this ClusterID, suitable for csv or json serialization.
-