Class ClusterID

java.lang.Object
org.tribuo.clustering.ClusterID
All Implemented Interfaces:
Serializable, Output<ClusterID>

public class ClusterID extends Object implements 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 Details

    • UNASSIGNED

      public static final int UNASSIGNED
      The sentinel unassigned cluster ID.
      See Also:
  • Constructor Details

    • ClusterID

      public ClusterID(int id)
      Creates a ClusterID with the sentinel score of Double.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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • fullEquals

      public boolean fullEquals(ClusterID o)
      Description copied from interface: Output
      Compares other to this output. Uses all score values and the strings.
      Specified by:
      fullEquals in interface Output<ClusterID>
      Parameters:
      o - Another output instance.
      Returns:
      True if the other instance has value equality to this instance. False otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copy

      public ClusterID copy()
      Description copied from interface: Output
      Deep copy of the output up to it's immutable state.
      Specified by:
      copy in interface Output<ClusterID>
      Returns:
      A copy of the output.
    • getSerializableForm

      public String getSerializableForm(boolean includeConfidence)
      Returns "id" or "id,score=idScore".
      Specified by:
      getSerializableForm in interface Output<ClusterID>
      Parameters:
      includeConfidence - Include whatever confidence score the clusterID contains, if known.
      Returns:
      A string representing this ClusterID, suitable for csv or json serialization.