Package org.tribuo.interop.onnx
Class MultiLabelTransformer
java.lang.Object
org.tribuo.interop.onnx.MultiLabelTransformer
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
,Serializable
,OutputTransformer<MultiLabel>
Can convert an
OnnxValue
into a Prediction
or a MultiLabel
.
Accepts a single tensor representing the scores of each label in the batch.
By default predictions are thresholded at DEFAULT_THRESHOLD
, scores
above this are considered to be present in the output, and the model output is assumed
to be probabilistic.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The default threshold for conversion into a label. -
Constructor Summary
ConstructorDescriptionConstructs a MultiLabelTransformer with a threshold ofDEFAULT_THRESHOLD
which assumes the model emits probabilities.MultiLabelTransformer
(double threshold, boolean generatesProbabilities) Constructs a MultiLabelTransformer with the supplied threshold. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Does this OutputTransformer generate probabilities.com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance
void
Used by the OLCUT configuration system, and should not be called by external code.toString()
transformToBatchOutput
(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo) Converts aOnnxValue
containing multiple outputs into a list ofOutput
s.transformToBatchPrediction
(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo, int[] numValidFeatures, List<Example<MultiLabel>> examples) Converts aOnnxValue
containing multiple outputs into a list ofPrediction
s.transformToOutput
(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo) Converts aOnnxValue
into the specified output type.transformToPrediction
(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo, int numValidFeatures, Example<MultiLabel> example) Converts aOnnxValue
into aPrediction
.
-
Field Details
-
DEFAULT_THRESHOLD
public static final double DEFAULT_THRESHOLDThe default threshold for conversion into a label.- See Also:
-
-
Constructor Details
-
MultiLabelTransformer
public MultiLabelTransformer()Constructs a MultiLabelTransformer with a threshold ofDEFAULT_THRESHOLD
which assumes the model emits probabilities. -
MultiLabelTransformer
public MultiLabelTransformer(double threshold, boolean generatesProbabilities) Constructs a MultiLabelTransformer with the supplied threshold.- Parameters:
threshold
- The threshold to set. Must be between 0 and 1 ifgeneratesProbabilities
is true.generatesProbabilities
- Does this model produce probabilistic outputs.
-
-
Method Details
-
postConfig
public void postConfig()Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfig
in interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
transformToPrediction
public Prediction<MultiLabel> transformToPrediction(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo, int numValidFeatures, Example<MultiLabel> example) Description copied from interface:OutputTransformer
Converts aOnnxValue
into aPrediction
.- Specified by:
transformToPrediction
in interfaceOutputTransformer<MultiLabel>
- Parameters:
value
- The value to convert.outputIDInfo
- The output info to use to identify the outputs.numValidFeatures
- The number of valid features used by the prediction.example
- The example to insert into the prediction.- Returns:
- A prediction object.
-
transformToOutput
public MultiLabel transformToOutput(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo) Description copied from interface:OutputTransformer
Converts aOnnxValue
into the specified output type.- Specified by:
transformToOutput
in interfaceOutputTransformer<MultiLabel>
- Parameters:
value
- The value to convert.outputIDInfo
- The output info to use to identify the outputs.- Returns:
- A output.
-
transformToBatchPrediction
public List<Prediction<MultiLabel>> transformToBatchPrediction(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo, int[] numValidFeatures, List<Example<MultiLabel>> examples) Description copied from interface:OutputTransformer
Converts aOnnxValue
containing multiple outputs into a list ofPrediction
s.- Specified by:
transformToBatchPrediction
in interfaceOutputTransformer<MultiLabel>
- Parameters:
value
- The value to convert.outputIDInfo
- The output info to use to identify the outputs.numValidFeatures
- The number of valid features used by the prediction.examples
- The example to insert into the prediction.- Returns:
- A list of predictions.
-
transformToBatchOutput
public List<MultiLabel> transformToBatchOutput(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo) Description copied from interface:OutputTransformer
Converts aOnnxValue
containing multiple outputs into a list ofOutput
s.- Specified by:
transformToBatchOutput
in interfaceOutputTransformer<MultiLabel>
- Parameters:
value
- The value to convert.outputIDInfo
- The output info to use to identify the outputs.- Returns:
- A list of outputs.
-
generatesProbabilities
public boolean generatesProbabilities()Description copied from interface:OutputTransformer
Does this OutputTransformer generate probabilities.- Specified by:
generatesProbabilities
in interfaceOutputTransformer<MultiLabel>
- Returns:
- True if it produces a probability distribution in the
Prediction
.
-
toString
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
-