Package org.tribuo.classification
Class LabelFactory
java.lang.Object
org.tribuo.classification.LabelFactory
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
,Serializable
,OutputFactory<Label>
A factory for making Label related classes.
Parses the Label by calling toString on the input.
Label factories have no state, and are all equal to each other.
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Label
The singleton unknown label, used for unlablled examples. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconstructInfoForExternalModel
(Map<Label, Integer> mapping) Creates anImmutableOutputInfo
from the supplied mapping.boolean
Generates an empty MutableLabelInfo.<V> Label
generateOutput
(V label) Generates the Label string by calling toString on the input.Gets anEvaluator
suitable for measuring performance of predictions for the Output subclass.Returns the singleton unknown output of type T which can be used for prediction time examples.int
hashCode()
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_LABEL
The singleton unknown label, used for unlablled examples.
-
-
Constructor Details
-
LabelFactory
public LabelFactory()Constructs a label factory.
-
-
Method Details
-
generateOutput
Generates the Label string by calling toString on the input.- Specified by:
generateOutput
in interfaceOutputFactory<Label>
- Type Parameters:
V
- The type of the input.- Parameters:
label
- An input value.- Returns:
- A Label object.
-
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<Label>
- Returns:
- An unknown output.
-
generateInfo
Generates an empty MutableLabelInfo.- Specified by:
generateInfo
in interfaceOutputFactory<Label>
- Returns:
- An empty MutableLabelInfo.
-
constructInfoForExternalModel
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<Label>
- 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<Label>
- Returns:
- An evaluator.
-
hashCode
public int hashCode() -
equals
-
getProvenance
- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
-