Package org.tribuo.interop.oci
Class OCIMultiLabelConverter
java.lang.Object
org.tribuo.interop.oci.OCIMultiLabelConverter
- 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
,OCIOutputConverter<MultiLabel>
,ProtoSerializable<org.tribuo.interop.oci.protos.OCIOutputConverterProto>
A converter for
DenseMatrix
and DenseVector
into MultiLabel
Prediction
s.
The threshold is user determined, but defaults to 0.5.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Protobuf serialization version.static final double
The default threshold for conversion into a label.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionOCIMultiLabelConverter
(double threshold, boolean generatesProbabilities) Constructs an OCILabelConverter with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionconvertOutput
(DenseMatrix scores, int[] numValidFeatures, List<Example<MultiLabel>> examples, ImmutableOutputInfo<MultiLabel> outputIDInfo) Converts a dense matrix into a list of predictions of the appropriate type.convertOutput
(DenseVector scores, int numValidFeature, Example<MultiLabel> example, ImmutableOutputInfo<MultiLabel> outputIDInfo) Converts a dense vector into a single prediction of the appropriate type.static OCIMultiLabelConverter
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
boolean
Does this OCIOutputConverter generate probabilities?com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance
double
Returns the threshold this converter uses to emit labels.The type witness used when deserializing the OCI model from a protobuf.int
hashCode()
void
Used by the OLCUT configuration system, and should not be called by external code.org.tribuo.interop.oci.protos.OCIOutputConverterProto
Serializes this object to a protobuf.toString()
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
DEFAULT_THRESHOLD
public static final double DEFAULT_THRESHOLDThe default threshold for conversion into a label.- See Also:
-
-
Constructor Details
-
OCIMultiLabelConverter
public OCIMultiLabelConverter(double threshold, boolean generatesProbabilities) Constructs an OCILabelConverter with the specified parameters.- Parameters:
threshold
- Threshold for emitting a MultiLabel dimension.generatesProbabilities
- Does this converter emit probabilities?
-
-
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
-
deserializeFromProto
public static OCIMultiLabelConverter deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Deserialization factory.- Parameters:
version
- The serialized object version.className
- The class name.message
- The serialized data.- Returns:
- The deserialized object.
- Throws:
com.google.protobuf.InvalidProtocolBufferException
- If the protobuf could not be parsed from themessage
.
-
convertOutput
public Prediction<MultiLabel> convertOutput(DenseVector scores, int numValidFeature, Example<MultiLabel> example, ImmutableOutputInfo<MultiLabel> outputIDInfo) Description copied from interface:OCIOutputConverter
Converts a dense vector into a single prediction of the appropriate type.- Specified by:
convertOutput
in interfaceOCIOutputConverter<MultiLabel>
- Parameters:
scores
- The score vector.numValidFeature
- The number of valid features (stored in the prediction).example
- The example (stored in the prediction).outputIDInfo
- The output information.- Returns:
- A prediction representing the value of this score vector.
-
convertOutput
public List<Prediction<MultiLabel>> convertOutput(DenseMatrix scores, int[] numValidFeatures, List<Example<MultiLabel>> examples, ImmutableOutputInfo<MultiLabel> outputIDInfo) Description copied from interface:OCIOutputConverter
Converts a dense matrix into a list of predictions of the appropriate type.- Specified by:
convertOutput
in interfaceOCIOutputConverter<MultiLabel>
- Parameters:
scores
- The score matrix.numValidFeatures
- The number of valid features in each example (stored in the prediction).examples
- The examples (stored in the prediction).outputIDInfo
- The output information.- Returns:
- A list of predictions representing the value of this score matrix.
-
generatesProbabilities
public boolean generatesProbabilities()Description copied from interface:OCIOutputConverter
Does this OCIOutputConverter generate probabilities?- Specified by:
generatesProbabilities
in interfaceOCIOutputConverter<MultiLabel>
- Returns:
- True if it produces a probability distribution in the
Prediction
.
-
getTypeWitness
Description copied from interface:OCIOutputConverter
The type witness used when deserializing the OCI model from a protobuf.The default implementation throws
UnsupportedOperationException
for compatibility with implementations which don't use protobuf serialization. This implementation will be removed in the next major version of Tribuo.- Specified by:
getTypeWitness
in interfaceOCIOutputConverter<MultiLabel>
- Returns:
- The output class this object produces.
-
getThreshold
public double getThreshold()Returns the threshold this converter uses to emit labels.- Returns:
- The threshold.
-
toString
-
equals
-
hashCode
public int hashCode() -
serialize
public org.tribuo.interop.oci.protos.OCIOutputConverterProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Specified by:
serialize
in interfaceProtoSerializable<org.tribuo.interop.oci.protos.OCIOutputConverterProto>
- Returns:
- The protobuf.
-
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>
-