Package org.tribuo.clustering
Class ClusterID
java.lang.Object
org.tribuo.clustering.ClusterID
- All Implemented Interfaces:
Serializable
,Output<ClusterID>
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
-
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 it's immutable state.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()
toString()
-
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
-
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 it's 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.
-