Class ImmutableClusteringInfo

java.lang.Object
org.tribuo.clustering.ClusteringInfo
org.tribuo.clustering.ImmutableClusteringInfo
All Implemented Interfaces:
Serializable, Iterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer,ClusterID>>, ImmutableOutputInfo<ClusterID>, OutputInfo<ClusterID>, ProtoSerializable<org.tribuo.protos.core.OutputDomainProto>

public class ImmutableClusteringInfo extends ClusteringInfo implements ImmutableOutputInfo<ClusterID>
An ImmutableOutputInfo object for ClusterIDs.

Gives each unique cluster an id number. Also counts each id occurrence like MutableClusteringInfo does, though the counts are frozen in this object.

See Also:
  • Constructor Details

    • ImmutableClusteringInfo

      public ImmutableClusteringInfo(Map<Integer,com.oracle.labs.mlrg.olcut.util.MutableLong> counts)
      Constructs an immutable clustering info from the supplied cluster counts.
      Parameters:
      counts - The cluster counts.
    • ImmutableClusteringInfo

      public ImmutableClusteringInfo(ClusteringInfo other)
      Copies the supplied clustering info, generating id numbers.
      Parameters:
      other - The clustering info to copy.
  • Method Details

    • deserializeFromProto

      public static ImmutableClusteringInfo 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 the message.
    • getDomain

      public Set<ClusterID> getDomain()
      Description copied from interface: OutputInfo
      Returns a set of Output which represent the space of possible values the Output has taken.

      For real values this set represents the number of dimensions observed.

      Specified by:
      getDomain in interface OutputInfo<ClusterID>
      Overrides:
      getDomain in class ClusteringInfo
      Returns:
      A Set of T.
    • getID

      public int getID(ClusterID output)
      Description copied from interface: ImmutableOutputInfo
      Return the id number associated with this output, or -1 if the output is unknown.
      Specified by:
      getID in interface ImmutableOutputInfo<ClusterID>
      Parameters:
      output - An output
      Returns:
      A non-negative integer if the output is known, or -1 if the output is unknown.
    • getOutput

      public ClusterID getOutput(int id)
      Description copied from interface: ImmutableOutputInfo
      Returns the output associated with this id, or null if the id is unknown.
      Specified by:
      getOutput in interface ImmutableOutputInfo<ClusterID>
      Parameters:
      id - A non-negative integer.
      Returns:
      An output object or null if it's unknown.
    • getTotalObservations

      public long getTotalObservations()
      Description copied from interface: ImmutableOutputInfo
      Returns the total number of observed outputs seen by this ImmutableOutputInfo.
      Specified by:
      getTotalObservations in interface ImmutableOutputInfo<ClusterID>
      Returns:
      The number of observed outputs.
    • copy

      public ClusteringInfo copy()
      Description copied from interface: OutputInfo
      Generates a copy of this OutputInfo, including it's mutability.
      Specified by:
      copy in interface OutputInfo<ClusterID>
      Specified by:
      copy in class ClusteringInfo
      Returns:
      A copy of the OutputInfo.
    • iterator

      public Iterator<com.oracle.labs.mlrg.olcut.util.Pair<Integer,ClusterID>> iterator()
      Specified by:
      iterator in interface Iterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer,ClusterID>>
    • domainAndIDEquals

      public boolean domainAndIDEquals(ImmutableOutputInfo<ClusterID> other)
      Description copied from interface: ImmutableOutputInfo
      Checks if the domain is the same as the other output info's domain, and that each element is mapped to the same id number.

      Note the default behaviour will be removed in a future major release, and should be overridden for performance reasons in all implementing classes.

      Specified by:
      domainAndIDEquals in interface ImmutableOutputInfo<ClusterID>
      Parameters:
      other - The output info to compare.
      Returns:
      True if the domains and ids are the same.