Package org.tribuo
Interface OutputFactory<T extends Output<T>>
- All Superinterfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
,Serializable
- All Known Implementing Classes:
AnomalyFactory
,ClusteringFactory
,LabelFactory
,MultiLabelFactory
,RegressionFactory
public interface OutputFactory<T extends Output<T>>
extends com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>, Serializable
An interface associated with a specific
Output
, which can generate the
appropriate Output subclass, and OutputInfo
subclass.
Must be Configurable
so it can be loaded from an olcut config file.
-
Method Summary
Modifier and TypeMethodDescriptionconstructInfoForExternalModel
(Map<T, Integer> mapping) Creates anImmutableOutputInfo
from the supplied mapping.Generates the appropriateMutableOutputInfo
so the output values can be tracked by aDataset
or other aggregate.<V> T
generateOutput
(V label) Parses theV
and generates the appropriateOutput
value.generateOutputs
(List<V> inputs) Generate a list of outputs from the supplied list of inputs.Evaluator<T,
? extends Evaluation<T>> 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.static <T extends Output<T>>
voidvalidateMapping
(Map<T, Integer> mapping) Validates that the mapping can be used as an output info, i.e.Methods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfig
Methods inherited from interface com.oracle.labs.mlrg.olcut.provenance.Provenancable
getProvenance
-
Method Details
-
generateOutput
Parses theV
and generates the appropriateOutput
value.Most implementations call toString on the label before parsing it, but this is not required.
- Type Parameters:
V
- The type of the input value.- Parameters:
label
- An input value.- Returns:
- The parsed Output as an instance of
T
.
-
getUnknownOutput
T getUnknownOutput()Returns the singleton unknown output of type T which can be used for prediction time examples.- Returns:
- An unknown output.
-
generateInfo
MutableOutputInfo<T> generateInfo()Generates the appropriateMutableOutputInfo
so the output values can be tracked by aDataset
or other aggregate.- Returns:
- The appropriate subclass of
MutableOutputInfo
initialised to zero.
-
constructInfoForExternalModel
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.
- Parameters:
mapping
- The mapping to use.- Returns:
- The appropriate subclass of
ImmutableOutputInfo
with a single observation of each element.
-
getEvaluator
Evaluator<T,? extends Evaluation<T>> getEvaluator()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.- Returns:
- An evaluator.
-
generateOutputs
Generate a list of outputs from the supplied list of inputs.Makes inputs.size() calls to
generateOutput(V)
.- Type Parameters:
V
- The type of the inputs- Parameters:
inputs
- The list to convert.- Returns:
- A list of outputs.
-
validateMapping
Validates that the mapping can be used as an output info, i.e. that it is dense in the region [0,mapping.size()) - meaning no duplicate ids, each id 0 through mapping.size() is used, and there are no negative ids.- Type Parameters:
T
- The type of the output.- Parameters:
mapping
- The mapping to use.
-