Class ImmutableMultiLabelInfo
java.lang.Object
org.tribuo.multilabel.MultiLabelInfo
org.tribuo.multilabel.ImmutableMultiLabelInfo
- All Implemented Interfaces:
Serializable,Iterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer, MultiLabel>>,ImmutableOutputInfo<MultiLabel>,OutputInfo<MultiLabel>,ProtoSerializable<org.tribuo.protos.core.OutputDomainProto>
public class ImmutableMultiLabelInfo
extends MultiLabelInfo
implements ImmutableOutputInfo<MultiLabel>
An
ImmutableOutputInfo for working with MultiLabel tasks.- See Also:
-
Field Summary
Fields inherited from class org.tribuo.multilabel.MultiLabelInfo
labelCounts, labels, totalCount, unknownCountFields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Method Summary
Modifier and TypeMethodDescriptioncopy()Generates a copy of this OutputInfo, including it's mutability.static ImmutableMultiLabelInfodeserializeFromProto(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.booleanReturns a set of MultiLabel, where each has a single Label inside it.intGets the id for the supplied label string.intgetID(MultiLabel output) Return the id number associated with this output, or -1 if the output is unknown.longgetLabelCount(int id) Gets the count of the label occurrence for the specified id number, or 0 if it's 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.inthashCode()Iterator<com.oracle.labs.mlrg.olcut.util.Pair<Integer, MultiLabel>> iterator()org.tribuo.protos.core.OutputDomainProtoSerializes this object to a protobuf.Generates a String form of this OutputInfo.toString()Methods inherited from class org.tribuo.multilabel.MultiLabelInfo
generateImmutableOutputInfo, generateMutableOutputInfo, getLabelCount, getLabelCount, getUnknownCount, outputCountsIterable, sizeMethods 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
-
Method Details
-
deserializeFromProto
public static ImmutableMultiLabelInfo 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.OutputDomainProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.protos.core.OutputDomainProto>- Returns:
- The protobuf.
-
getDomain
Description copied from class:MultiLabelInfoReturns a set of MultiLabel, where each has a single Label inside it. The set covers the space of Labels that this MultiLabelInfo has seen.- Specified by:
getDomainin interfaceOutputInfo<MultiLabel>- Overrides:
getDomainin classMultiLabelInfo- Returns:
- The set of possible labels.
-
getID
Description copied from interface:ImmutableOutputInfoReturn the id number associated with this output, or -1 if the output is unknown.- Specified by:
getIDin interfaceImmutableOutputInfo<MultiLabel>- 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<MultiLabel>- 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<MultiLabel>- Returns:
- The number of observed outputs.
-
getID
Gets the id for the supplied label string.- Parameters:
label- The label string.- Returns:
- The id number, or -1 if the label is unknown.
-
getLabelCount
public long getLabelCount(int id) Gets the count of the label occurrence for the specified id number, or 0 if it's unknown.- Parameters:
id- The label id.- Returns:
- The label count.
-
copy
Description copied from interface:OutputInfoGenerates a copy of this OutputInfo, including it's mutability.- Specified by:
copyin interfaceOutputInfo<MultiLabel>- Specified by:
copyin classMultiLabelInfo- Returns:
- A copy of the OutputInfo.
-
toReadableString
Description copied from interface:OutputInfoGenerates a String form of this OutputInfo.This String can contain newlines, tabs and other formatting.
- Specified by:
toReadableStringin interfaceOutputInfo<MultiLabel>- Returns:
- A formatted String representing this OutputInfo.
-
toString
-
equals
- Overrides:
equalsin classMultiLabelInfo
-
hashCode
public int hashCode()- Overrides:
hashCodein classMultiLabelInfo
-
iterator
- Specified by:
iteratorin interfaceIterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer, MultiLabel>>
-
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<MultiLabel>- Parameters:
other- The output info to compare.- Returns:
- True if the domains and ids are the same.
-