Package org.tribuo.multilabel
Class MultiLabelFactory
java.lang.Object
org.tribuo.multilabel.MultiLabelFactory
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
,Serializable
,OutputFactory<MultiLabel>
,ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>
A factory for generating MultiLabel objects and their associated OutputInfo and Evaluator objects.
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MultiLabel
The sentinel unknown multi-label output used to signal there is no ground truth value.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconstructInfoForExternalModel
(Map<MultiLabel, Integer> mapping) Creates anImmutableOutputInfo
from the supplied mapping.static MultiLabelFactory
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
Generates the appropriateMutableOutputInfo
so the output values can be tracked by aDataset
or other aggregate.static String
generateLabelString
(Set<Label> input) <V> MultiLabel
generateOutput
(V label) Parses the MultiLabel value either by toStringing the input and callingMultiLabel.parseString(java.lang.String)
or if it's aCollection
iterating over the elements calling toString on each element in turn and usingMultiLabel.parseElement(java.lang.String)
.Gets anEvaluator
suitable for measuring performance of predictions for the Output subclass.Gets the output class that this factory supports.Returns the singleton unknown output of type T which can be used for prediction time examples.int
hashCode()
org.tribuo.protos.core.OutputFactoryProto
Serializes this object to a protobuf.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfig
Methods inherited from interface org.tribuo.OutputFactory
generateOutputs
-
Field Details
-
UNKNOWN_MULTILABEL
The sentinel unknown multi-label output used to signal there is no ground truth value.
-
-
Constructor Details
-
MultiLabelFactory
public MultiLabelFactory()Construct a MultiLabelFactory.
-
-
Method Details
-
deserializeFromProto
public static MultiLabelFactory deserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.- Parameters:
version
- The serialized object version.className
- The class name.message
- The serialized data.- Returns:
- The deserialized object.
-
serialize
public org.tribuo.protos.core.OutputFactoryProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Specified by:
serialize
in interfaceProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>
- Returns:
- The protobuf.
-
generateOutput
Parses the MultiLabel value either by toStringing the input and callingMultiLabel.parseString(java.lang.String)
or if it's aCollection
iterating over the elements calling toString on each element in turn and usingMultiLabel.parseElement(java.lang.String)
.- Specified by:
generateOutput
in interfaceOutputFactory<MultiLabel>
- Type Parameters:
V
- The type of the input value.- Parameters:
label
- An input value.- Returns:
- A MultiLabel
-
getUnknownOutput
Description copied from interface:OutputFactory
Returns the singleton unknown output of type T which can be used for prediction time examples.- Specified by:
getUnknownOutput
in interfaceOutputFactory<MultiLabel>
- Returns:
- An unknown output.
-
generateInfo
Description copied from interface:OutputFactory
Generates the appropriateMutableOutputInfo
so the output values can be tracked by aDataset
or other aggregate.- Specified by:
generateInfo
in interfaceOutputFactory<MultiLabel>
- Returns:
- The appropriate subclass of
MutableOutputInfo
initialised to zero.
-
constructInfoForExternalModel
public ImmutableOutputInfo<MultiLabel> constructInfoForExternalModel(Map<MultiLabel, Integer> mapping) Description copied from interface:OutputFactory
Creates anImmutableOutputInfo
from the supplied mapping. Requires that the mapping is dense in the integers [0,mapping.size()) and each mapping is unique.This call is used to import external models, and should not be used for other purposes.
- Specified by:
constructInfoForExternalModel
in interfaceOutputFactory<MultiLabel>
- Parameters:
mapping
- The mapping to use.- Returns:
- The appropriate subclass of
ImmutableOutputInfo
with a single observation of each element.
-
getEvaluator
Description copied from interface:OutputFactory
Gets anEvaluator
suitable for measuring performance of predictions for the Output subclass.Evaluator
instances are thread safe and immutable, and commonly this is a singleton stored in theOutputFactory
implementation.- Specified by:
getEvaluator
in interfaceOutputFactory<MultiLabel>
- Returns:
- An evaluator.
-
getTypeWitness
Description copied from interface:OutputFactory
Gets the output class that this factory supports.- Specified by:
getTypeWitness
in interfaceOutputFactory<MultiLabel>
- Returns:
- The output class.
-
hashCode
public int hashCode() -
equals
-
getProvenance
- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
-
generateLabelString
- Parameters:
input
- A Set of Label objects.- Returns:
- A (possibly empty) comma separated string.
-