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:
-
Field Summary
Fields inherited from class org.tribuo.clustering.ClusteringInfo
clusterCounts, unknownCountFields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionImmutableClusteringInfo(Map<Integer, com.oracle.labs.mlrg.olcut.util.MutableLong> counts) Constructs an immutable clustering info from the supplied cluster counts.Copies the supplied clustering info, generating id numbers. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Generates a copy of this OutputInfo, including it's mutability.static ImmutableClusteringInfodeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.booleanChecks if the domain is the same as the other output info's domain, and that each element is mapped to the same id number.intReturn the id number associated with this output, or -1 if the output is unknown.getOutput(int id) Returns the output associated with this id, or null if the id is unknown.longReturns the total number of observed outputs seen by this ImmutableOutputInfo.iterator()Methods inherited from class org.tribuo.clustering.ClusteringInfo
equals, generateImmutableOutputInfo, generateMutableOutputInfo, getUnknownCount, hashCode, outputCountsIterable, serialize, size, toReadableString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.tribuo.OutputInfo
generateImmutableOutputInfo, generateMutableOutputInfo, getUnknownCount, outputCountsIterable, size, toReadableStringMethods inherited from interface org.tribuo.protos.ProtoSerializable
serialize
-
Constructor Details
-
ImmutableClusteringInfo
-
ImmutableClusteringInfo
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 themessage.
-
getDomain
Description copied from interface:OutputInfoReturns a set ofOutputwhich represent the space of possible values theOutputhas taken.For real values this set represents the number of dimensions observed.
- Specified by:
getDomainin interfaceOutputInfo<ClusterID>- Overrides:
getDomainin classClusteringInfo- Returns:
- A Set of
T.
-
getID
Description copied from interface:ImmutableOutputInfoReturn the id number associated with this output, or -1 if the output is unknown.- Specified by:
getIDin interfaceImmutableOutputInfo<ClusterID>- Parameters:
output- An output- Returns:
- A non-negative integer if the output is known, or -1 if the output is unknown.
-
getOutput
Description copied from interface:ImmutableOutputInfoReturns the output associated with this id, or null if the id is unknown.- Specified by:
getOutputin interfaceImmutableOutputInfo<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:ImmutableOutputInfoReturns the total number of observed outputs seen by this ImmutableOutputInfo.- Specified by:
getTotalObservationsin interfaceImmutableOutputInfo<ClusterID>- Returns:
- The number of observed outputs.
-
copy
Description copied from interface:OutputInfoGenerates a copy of this OutputInfo, including it's mutability.- Specified by:
copyin interfaceOutputInfo<ClusterID>- Specified by:
copyin classClusteringInfo- Returns:
- A copy of the OutputInfo.
-
iterator
-
domainAndIDEquals
Description copied from interface:ImmutableOutputInfoChecks 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:
domainAndIDEqualsin interfaceImmutableOutputInfo<ClusterID>- Parameters:
other- The output info to compare.- Returns:
- True if the domains and ids are the same.
-