Class OCIModel<T extends Output<T>>
- All Implemented Interfaces:
- com.oracle.labs.mlrg.olcut.provenance.Provenancable<ModelProvenance>,- Serializable,- AutoCloseable,- ProtoSerializable<org.tribuo.protos.core.ModelProto>
public final class OCIModel<T extends Output<T>>
extends ExternalModel<T, DenseMatrix, DenseMatrix>
implements AutoCloseable
A wrapper class around an OCI Data Science Model Deployment endpoint which sends off inputs for scoring and
 converts the output into a Tribuo prediction.
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classCarrier type for easy deserialization from JSON.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.Fields inherited from class org.tribuo.interop.ExternalModelDEFAULT_BATCH_SIZE, featureBackwardMapping, featureForwardMappingFields inherited from class org.tribuo.ModelALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutputFields inherited from interface org.tribuo.protos.ProtoSerializableDESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()protected DenseMatrixconvertFeatures(SparseVector sparseVector) Converts from a SparseVector using the external model's indices into the ingestion format for the external model.protected DenseMatrixconvertFeaturesList(List<SparseVector> list) Converts from a list of SparseVector using the external model's indices into the ingestion format for the external model.protected List<Prediction<T>> convertOutput(DenseMatrix scores, int[] numValidFeatures, List<Example<T>> list) Converts the output of the external model into a list ofPredictions.protected Prediction<T> convertOutput(DenseMatrix scores, int numValidFeature, Example<T> example) Converts the output of the external model into aPrediction.copy(String s, ModelProvenance modelProvenance) Copies a model, replacing its provenance and name with the supplied values.createOCIModel(OutputFactory<T> factory, Map<String, Integer> featureMapping, Map<T, Integer> outputMapping, Path configFile, String profileName, String endpointURL, OCIOutputConverter<T> outputConverter) Creates anOCIModelby wrapping an OCI DS Model Deployment endpoint.createOCIModel(OutputFactory<T> factory, Map<String, Integer> featureMapping, Map<T, Integer> outputMapping, Path configFile, String endpointURL, OCIOutputConverter<T> outputConverter) Creates anOCIModelby wrapping an OCI DS Model Deployment endpoint.static OCIModel<?> deserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.protected DenseMatrixexternalPrediction(DenseMatrix features) Runs the external model's prediction function.getTopFeatures(int i) Gets the topnfeatures associated with this model.static com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvidermakeAuthProvider(Path configFile, String profile) Makes an authentication provider from the config file and profile.org.tribuo.protos.core.ModelProtoSerializes this object to a protobuf.Methods inherited from class org.tribuo.interop.ExternalModelcreateFeatureMap, createOutputInfo, getBatchSize, getExcuse, innerPredict, predict, setBatchSize, validateFeatureMappingMethods inherited from class org.tribuo.ModelcastModel, copy, createDataCarrier, deserialize, deserializeFromFile, deserializeFromStream, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, predict, predict, serializeToFile, serializeToStream, setName, toString, validate
- 
Field Details- 
CURRENT_VERSIONpublic static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
 
 
- 
- 
Method Details- 
deserializeFromProtopublic static OCIModel<?> deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException, IOException 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 the- message.
- IOException
 
- 
getTopFeaturesDescription copied from class:ModelGets the topnfeatures associated with this model.If the model does not produce per output feature lists, it returns a map with a single element with key Model.ALL_OUTPUTS. If the model cannot describe it's top features then it returns Collections.emptyMap().- Specified by:
- getTopFeaturesin class- Model<T extends Output<T>>
- Parameters:
- i- the number of features to return. If this value is less than 0, all features should be returned for each class, unless the model cannot score it's features.
- Returns:
- a map from string outputs to an ordered list of pairs of feature names and weights associated with that feature in the model
 
- 
copyDescription copied from class:ModelCopies a model, replacing its provenance and name with the supplied values.Used to provide the provenance removal functionality. 
- 
convertFeaturesDescription copied from class:ExternalModelConverts from a SparseVector using the external model's indices into the ingestion format for the external model.- Specified by:
- convertFeaturesin class- ExternalModel<T extends Output<T>, DenseMatrix, DenseMatrix>
- Parameters:
- sparseVector- The features using external indices.
- Returns:
- The ingestion format for the external model.
 
- 
convertFeaturesListDescription copied from class:ExternalModelConverts from a list of SparseVector using the external model's indices into the ingestion format for the external model.- Specified by:
- convertFeaturesListin class- ExternalModel<T extends Output<T>, DenseMatrix, DenseMatrix>
- Parameters:
- list- The features using external indices.
- Returns:
- The ingestion format for the external model.
 
- 
externalPredictionDescription copied from class:ExternalModelRuns the external model's prediction function.- Specified by:
- externalPredictionin class- ExternalModel<T extends Output<T>, DenseMatrix, DenseMatrix>
- Parameters:
- features- The input in the external model's format.
- Returns:
- The output in the external model's format.
 
- 
convertOutputDescription copied from class:ExternalModelConverts the output of the external model into aPrediction.- Specified by:
- convertOutputin class- ExternalModel<T extends Output<T>, DenseMatrix, DenseMatrix>
- Parameters:
- scores- The output of the external model.
- numValidFeature- The number of valid features in the input.
- example- The input example, used to construct the Prediction.
- Returns:
- A Tribuo Prediction.
 
- 
convertOutputprotected List<Prediction<T>> convertOutput(DenseMatrix scores, int[] numValidFeatures, List<Example<T>> list) Description copied from class:ExternalModelConverts the output of the external model into a list ofPredictions.- Specified by:
- convertOutputin class- ExternalModel<T extends Output<T>, DenseMatrix, DenseMatrix>
- Parameters:
- scores- The output of the external model.
- numValidFeatures- An array with the number of valid features in each example.
- list- The input examples, used to construct the Predictions.
- Returns:
- A list of Tribuo Predictions.
 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
 
- 
serialize
- 
makeAuthProviderpublic static com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider makeAuthProvider(Path configFile, String profile) throws IOException Makes an authentication provider from the config file and profile.If the config file is null then it loads the default config file, if the profile is null it loads the default profile in the chosen config file. - Parameters:
- configFile- The config file to load.
- profile- The profile to load.
- Returns:
- An authentication provider.
- Throws:
- IOException- If the config file could not be read.
 
- 
createOCIModelpublic static <T extends Output<T>> OCIModel<T> createOCIModel(OutputFactory<T> factory, Map<String, Integer> featureMapping, Map<T, Integer> outputMapping, Path configFile, String endpointURL, OCIOutputConverter<T> outputConverter) Creates anOCIModelby wrapping an OCI DS Model Deployment endpoint.Uses the endpointURL as the value to hash for the trainer provenance. Loads the default profile in the configuration file. - Type Parameters:
- T- The output type.
- Parameters:
- factory- The output factory to use.
- featureMapping- The feature mapping between Tribuo names and model integer ids.
- outputMapping- The output mapping between Tribuo outputs and model integer ids.
- configFile- The OCI configuration file, if null use the default file.
- endpointURL- The endpoint URL.
- outputConverter- The converter for the specified output type.
- Returns:
- An OCIModel ready to score new inputs.
 
- 
createOCIModelpublic static <T extends Output<T>> OCIModel<T> createOCIModel(OutputFactory<T> factory, Map<String, Integer> featureMapping, Map<T, Integer> outputMapping, Path configFile, String profileName, String endpointURL, OCIOutputConverter<T> outputConverter) Creates anOCIModelby wrapping an OCI DS Model Deployment endpoint.Uses the endpointURL as the value to hash for the trainer provenance. - Type Parameters:
- T- The output type.
- Parameters:
- factory- The output factory to use.
- featureMapping- The feature mapping between Tribuo names and model integer ids.
- outputMapping- The output mapping between Tribuo outputs and model integer ids.
- configFile- The OCI configuration file, if null use the default file.
- profileName- The profile name in the OCI configuration file, if null uses the default profile.
- endpointURL- The endpoint URL.
- outputConverter- The converter for the specified output type.
- Returns:
- An OCIModel ready to score new inputs.
 
 
-