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
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default threshold for conversion into a label. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a MultiLabelTransformer with a threshold ofDEFAULT_THRESHOLDwhich assumes the model emits probabilities.MultiLabelTransformer(double threshold, boolean generatesProbabilities) Constructs a MultiLabelTransformer with the supplied threshold. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDoes this OutputTransformer generate probabilities.com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenancevoidUsed by the OLCUT configuration system, and should not be called by external code.toString()transformToBatchOutput(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo) Converts aOnnxValuecontaining multiple outputs into a list ofOutputs.transformToBatchPrediction(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo, int[] numValidFeatures, List<Example<MultiLabel>> examples) Converts aOnnxValuecontaining multiple outputs into a list ofPredictions.transformToOutput(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo) Converts aOnnxValueinto the specified output type.transformToPrediction(List<ai.onnxruntime.OnnxValue> value, ImmutableOutputInfo<MultiLabel> outputIDInfo, int numValidFeatures, Example<MultiLabel> example) Converts aOnnxValueinto 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_THRESHOLDwhich 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 ifgeneratesProbabilitiesis 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:
postConfigin 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:OutputTransformerConverts aOnnxValueinto aPrediction.- Specified by:
transformToPredictionin 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:OutputTransformerConverts aOnnxValueinto the specified output type.- Specified by:
transformToOutputin 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:OutputTransformerConverts aOnnxValuecontaining multiple outputs into a list ofPredictions.- Specified by:
transformToBatchPredictionin 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:OutputTransformerConverts aOnnxValuecontaining multiple outputs into a list ofOutputs.- Specified by:
transformToBatchOutputin 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:OutputTransformerDoes this OutputTransformer generate probabilities.- Specified by:
generatesProbabilitiesin 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:
getProvenancein interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
-