Class OCILabelConverter
java.lang.Object
org.tribuo.interop.oci.OCILabelConverter
- 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<Label>,ProtoSerializable<org.tribuo.interop.oci.protos.OCIOutputConverterProto>
A converter for
DenseMatrix and DenseVector into Label Predictions.
If the input has length 1 it is assumed to be a single label value, otherwise it must have length = outputIDInfo.size().
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionOCILabelConverter(boolean generatesProbabilities) Constructs an OCILabelConverter with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionconvertOutput(DenseMatrix scores, int[] numValidFeatures, List<Example<Label>> examples, ImmutableOutputInfo<Label> outputIDInfo) Converts a dense matrix into a list of predictions of the appropriate type.convertOutput(DenseVector scores, int numValidFeature, Example<Label> example, ImmutableOutputInfo<Label> outputIDInfo) Converts a dense vector into a single prediction of the appropriate type.static OCILabelConverterdeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.booleanbooleanDoes this OCIOutputConverter generate probabilities?com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenanceThe type witness used when deserializing the OCI model from a protobuf.inthashCode()org.tribuo.interop.oci.protos.OCIOutputConverterProtoSerializes this object to a protobuf.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfig
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
OCILabelConverter
public OCILabelConverter(boolean generatesProbabilities) Constructs an OCILabelConverter with the specified parameters.- Parameters:
generatesProbabilities- Does this converter emit probabilities?
-
-
Method Details
-
deserializeFromProto
public static OCILabelConverter 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<Label> convertOutput(DenseVector scores, int numValidFeature, Example<Label> example, ImmutableOutputInfo<Label> outputIDInfo) Description copied from interface:OCIOutputConverterConverts a dense vector into a single prediction of the appropriate type.- Specified by:
convertOutputin interfaceOCIOutputConverter<Label>- 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<Label>> convertOutput(DenseMatrix scores, int[] numValidFeatures, List<Example<Label>> examples, ImmutableOutputInfo<Label> outputIDInfo) Description copied from interface:OCIOutputConverterConverts a dense matrix into a list of predictions of the appropriate type.- Specified by:
convertOutputin interfaceOCIOutputConverter<Label>- 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:OCIOutputConverterDoes this OCIOutputConverter generate probabilities?- Specified by:
generatesProbabilitiesin interfaceOCIOutputConverter<Label>- Returns:
- True if it produces a probability distribution in the
Prediction.
-
getTypeWitness
Description copied from interface:OCIOutputConverterThe type witness used when deserializing the OCI model from a protobuf.The default implementation throws
UnsupportedOperationExceptionfor compatibility with implementations which don't use protobuf serialization. This implementation will be removed in the next major version of Tribuo.- Specified by:
getTypeWitnessin interfaceOCIOutputConverter<Label>- Returns:
- The output class this object produces.
-
toString
-
equals
-
hashCode
-
serialize
public org.tribuo.interop.oci.protos.OCIOutputConverterProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.interop.oci.protos.OCIOutputConverterProto>- Returns:
- The protobuf.
-
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>
-