Package org.tribuo.clustering
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
Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionClusterID
(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 ClusterID
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
boolean
Compares other to this output.int
getID()
Gets the cluster id number.double
getScore()
Get a real valued score for this ClusterID.getSerializableForm
(boolean includeConfidence) Returns "id" or "id,score=idScore".int
hashCode()
org.tribuo.protos.core.OutputProto
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 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:ProtoSerializable
Serializes this object to a protobuf.- Specified by:
serialize
in 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
public int hashCode() -
fullEquals
Description copied from interface:Output
Compares other to this output. Uses all score values and the strings.- Specified by:
fullEquals
in interfaceOutput<ClusterID>
- Parameters:
o
- Another output instance.- Returns:
- True if the other instance has value equality to this instance. False otherwise.
-
toString
-
copy
Description copied from interface:Output
Deep copy of the output up to its immutable state. -
getSerializableForm
Returns "id" or "id,score=idScore".- Specified by:
getSerializableForm
in 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.
-