Work with Oracle Machine Learning Models

Oracle Machine Learning Services is a middle tier web application that uses an Oracle Database as the backend repository. Oracle Machine Learning Services supports model deployment of Oracle Machine Learning models and ONNX format models. Model deployment refers to the method for integrating machine learning models into the production environment.

Supported Functions

Oracle Machine Learning Services REST API supports the following functions for Oracle Machine Learning models and ONNX format models.
  • Storing, deleting, and listing of deployed models
  • Retrieving metadata and content of models
  • Organizing models under namespace
  • Creating, deleting, and listing of model endpoints
  • Getting Swagger document for the model endpoint
  • Getting model details
  • Getting endpoint details
  • Scoring with model endpoints

Supported Machine Learning Models

Oracle Machine Learning Services REST API supports the following machine learning models:
  • Classification models
  • Clustering models
  • Feature Extraction models
  • Regression models

Note:

Partitioned models are also included.
It supports numeric columns, categorical columns, text columns and nested columns. Prediction details are supported for numeric and categorical columns, but not for nested and text columns.

Note:

Models with embedded sql transformations are not supported.

Deployment methods

cURL Commands

This section lists the cURL commands to:
  • View the Oracle Machine Learning Services REST API
  • Get the List of Saved Models
  • View a Specific Model by Referencing the Model ID
  • Get a List of Models Filtered by Model Name
  • Get a List of Models Filtered by Version and Namespace

1: View the Oracle Machine Learning Services REST API

This example demonstrates how to view the OML Services REST API.

Run the following cURL command to view the REST API for Oracle Machine Learning Services:
curl -i -X GET --header "Authorization: Bearer ${token}" "<oml-cloud-service-location-url>/omlmod/v1/api"
The command returns the following information and displays the API for Oracle Machine Learning Services:
HTTP/1.1 200 OK
Date: Tue, 10 Nov 2021 18:03:08 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: X-Requested-With, Content-Type
{
  "openapi": "3.0.0",
  "info": {
    "title": "OML Services APIs",
    "description": "APIs for the Oracle Machine Learning Services.",
    "termsOfService": "http://swagger.io/terms/",
    "contact": {
      "name": "Simeon Greene",
      "url": "http://www.oracle.com",
      "email": "simeon.m.greene@oracle.com"
    },
    "version": "1.0.0"
  },
  "servers": 
  ..
  ..

2: Get the List of Saved Models

This example demonstrates how to get the list of all OML models that are saved in the repository.

Run the following cURL command to get the list of saved models:
curl -X GET --header "Authorization: Bearer ${token}" "<oml-cloud-service-location-url>/omlmod/v1/models" | jq
The command returns the list of all the stored OML models along with the model metadata:
{
  "items": [
    {
      "version": "1.5",
      "modelType": "OML",
      "createdBy": "OMLUSER",
      "modelId": "1b6fed66-bacb-48c7-8549-14542abe2a82",
      "modelName": "OML_Insurance_Affinity",
      "links": [
        {
          "rel": "self",
          "href": "https://qtraya2braestch-omldb.adb.us-sanjose-1.oraclecloudapps.com/omlmod/v1/models/1b6fed66-bacb-48c7-8549-14542abe2a82"
        }
      ],
      "namespace": "OML_MODELS",
      "shared": true,
      "storedOn": "2021-11-16T20:43:28.733Z"
    },
    {
      "version": "1.4",
      "modelType": "ONNX",
      "createdBy": "OMLUSER",
      "modelId": "228707fa-218a-4fb9-b1e7-bc111059a04f",
      "modelName": "onnxTitanicModel",
      "links": [
        {
          "rel": "self",
          "href": "https://qtraya2braestch-omldb.adb.us-sanjose-1.oraclecloudapps.com/omlmod/v1/models/228707fa-218a-4fb9-b1e7-bc111059a04f"
        }
      ],
      "namespace": "ONNX_MODELS",
      "shared": true,
      "storedOn": "2021-11-16T21:07:13.291Z"
    },
...
...
}
  ]
}

3: View a Specific Model by Referencing the Model ID

This example demonstrates how to view a specific model by referencing the model ID.

Note:

To view a model by referencing the model ID, you must first export the model_Id.
Run the following command to export the Model ID to the variable $model_Id:
export model_Id=bc5cf626-d4f6-45ba-8a50-c3e57a008bd7

In this example, bc5cf626-d4f6-45ba-8a50-c3e57a008bd7 is the model_Id.

Run the following cURL command to view the model by referencing the model_Id:
curl -X GET --header "Authorization: Bearer ${token}" "<oml-cloud-service-location-url>/omlmod/v1/models/$model_Id" | jq
The command returns the following information about the model with model_Id bc5cf626-d4f6-45ba-8a50-c3e57a008bd7 :
{
  "version": "1.0",
  "modelType": "OML",
  "createdBy": "OMLUSER",
  "modelId": "bc5cf626-d4f6-45ba-8a50-c3e57a008bd7",
  "modelName": "GLM_MODEL",
  "links": [
    {
      "rel": "self",
      "href": "https://qtraya2braestch-omldb.adb.us-sanjose-1.oraclecloudapps.com/omlmod/v1/models/bc5cf626-d4f6-45ba-8a50-c3e57a008bd7"
    }
  ],
  "namespace": "OML_MODELS",
  "shared": true,
  "storedOn": "2021-11-06T22:16:29.387Z"
}

4: Get a List of Models Filtered by Model Name

This example demonstrates how to get a list of models filtered by model name.

Run the following command to get a list of models filtered by modelName. In this example, the modelName is GLM_MODEL.

curl -X GET --header "Authorization: Bearer $token" "<oml-cloud-service-location-url>/omlmod/v1/models?modelName=GLM_MODEL" | jq
The command returns the following information:
{
  "items": [
    {
      "version": "1.5",
      "modelType": "OML",
      "createdBy": "OMLUSER",
      "modelId": "bc5cf626-d4f6-45ba-8a50-c3e57a008bd7",
      "modelName": "GLM_Model",
      "links": [
        {
          "rel": "self",
          "href": "https://qtraya2braestch-omldb.adb.us-sanjose-1.oraclecloudapps.com/omlmod/v1/models/1b6fed66-bacb-48c7-8549-14542abe2a82"
        }
      ],
      "namespace": "OML_MODELS",
      "shared": true,
      "storedOn": "2021-11-16T20:43:28.733Z"
    },
  }
  ]
}

5: Get a List of Models Filtered by Version and Namespace

This example demonstrates how to get a list of models filtered by version and namespace of a model.

Run the following cURL command to get the list of models filtered by version=1.0 and namespace=OML_MODELS :
curl -X GET --header "Authorization: Bearer $token" "<oml-cloud-service-location-url>/omlmod/v1/models?version=1.0&namespace=OML_MODELS" | jq
The command returns the following information:
{
  "items": [
    {
      "version": "1.0",
      "modelType": "OML",
      "createdBy": "OMLUSER",
      "modelId": "bc5cf626-d4f6-45ba-8a50-c3e57a008bd7",
      "modelName": "GLM_MODEL",
      "links": [
        {
          "rel": "self",
          "href": "https://qtraya2braestch-omldb.adb.us-sanjose-1.oraclecloudapps.com/omlmod/v1/models/bc5cf626-d4f6-45ba-8a50-c3e57a008bd7"
        }
      ],
      "namespace": "OML_MODELS",
      "shared": true,
      "storedOn": "2021-11-06T22:16:29.387Z"
    }
  ],
  "links": [
    {
      "rel": "self",
      "href": "https://qtraya2braestch-omldb.adb.us-sanjose-1.oraclecloudapps.com/omlmod/v1/models"
    }
  ]
}