Creating and Training Models

A model is managed resource in the Anomaly Detection service that allows you to train machine learning models as HTTP endpoints in OCI.

The API performs anomaly detection to:


The anomaly detection model using the provided raw data with a connection to your data. For example, using an ATP database.


The anomalies for the data contained in the request using the stored model.

Using the Console

  1. Open the navigation menu and click Analytics & AI. Under Artificial Intelligence, click Anomaly Detection.
  2. Click Create and Train Model
  3. Select an existing data asset if any exist or click Create a new data asset.
  4. Click Next.
  5. You can select a different compartment to store your model in instead of the default.
  6. Select a compartment for the resource.
  7. Enter a unique name (255 character limit) for the project. If you don't provide a name, a name is automatically generated for you. For example, aiproject20210108222435.
  8. Enter a description (400 character limit) for the project. If you don't add a description, it remains empty.
  9. Set the target False Alarm Probability (FAP) in the 0 to 0.05 range.

    FAP indicates model performance. Lower FAP indicates better model performance.

  10. Set the training fraction ratio in the 0.5 to 0.8 range.

    Training Fraction Ratio indicates the split ratio between training data and validation data

  11. Add tags to easily locate and track resources by selecting a tag namespace, then entering the key and value. To add more than one tag, click +Additional Tags.

    Tagging describes the various tags that you can use organize and find resources including cost-tracking tags.

  12. Click Create.
    Training a model can take awhile. The page is automatically refreshed every 20 seconds.

Using the API

This is the recommended approach when you want to integrate anomaly detection into your existing applications to implement in production.

  1. Download and configure OCI CLI or SDK as described in existing OCI documentation.
  2. As an authenticated user, upload a .csv or .json file with your training data to Object Storage in your tenancy.
  3. Use the CLI or SDK create the train work request, with the path to the object store.
  4. As an authenticated user make the HTTP work request to train.
  5. Check the status of the training request by periodically querying the work request.

    When of the training request completes, the response contains the model detection endpoint.

  6. To use this trained model, create an HTTP POST request and make the request to the endpoint received in the previous step.
  7. Parse the HTTP response to get the results and use in your applications.

Example API Calls

You can use the following Anomaly Detection service API calls to help you to create, train, and detect results.

  1. Create an AI project:

     Method: POST
                 "displayName":"Test Anomaly Detection",
                 "compartmentId": "ocid1.compartment.oc1..aaaaaaaaaqf4b7xq6kxrr…..jpbdfmcjmzdufz6sy52pra",
                 "description" : "PROJECT FOR ANOMALY DETECTION"
  2. Create a data assets, which assumes that your data is already in OCI Object Storage:

        Method: POST
           "displayName" : "sample dataAsset",
           "compartmentId" : "ocid1.compartment.oc1..aaaaaaaaaqf4b7xq6kxrrbl…..pbdfmcjmzdufz6sy52pra",
           "projectId" : "ocid1.aiproject.oc1.iad.amaaaaaaor7l3jiauulbiu5dtqga….eksq3ophqwxsiyuf4q",
           "description" : "oracle object storage data asset",
           "dataSourceDetails" :
                 "dataSourceType" : "ORACLE_OBJECT_STORAGE",
                 "bucketName" : "mset_service_model_storage",
                 "namespace" : "namespace_bucket",
                 "objectName" : "ValidTrainingData.json"
  3. Train the model.

     Method: POST
        "compartmentId" : "ocid1.compartment.oc1..aaaaaaaaaqf4b7xq6kxrrb…..rcmjpbdfmcjmzdufz6sy52pra",
        "displayName" : "Test",
        "description" : "Test training",
        "projectId" : "ocid1.aiproject.oc1.iad.amaaaaaaor7l3….43ztvryp2sweksq3ophqwxsiyuf4q",
        "modelCreationDetails" :
              "modelType" : "ANOMALY_MULTIVARIATE",
              "fap" : 0.01,
              "trainingFraction" : 0.7,
              "dataAssets" :
  4. Get the model:

     Method: GET
  5. Detect with data:

     Method: POST
        "modelId": "ocid1.aimodel.oc1.phx.amaaaaaaor7l3jialglh5vnt2w3nj6zly4dpcjfex6lktujo24t5aklmn2ta",
        "requestType": "INLINE",
        "signalNames":["sensor1", "sensor2", "sensor3", "sensor4", "sensor5", "sensor6", "sensor7", "sensor8", "sensor9", "sensor10", "sensor11"],
            {"timestamp":"2020-07-13T20:44:46Z","values": [1,-9.6193,0.3208,0.6199,-0.4936,5.0697,-0.5063,0.4253,0.4864,-0.0798,0.0446]},
            {"timestamp":"2020-07-13T20:45:46Z","values": [1,9.4101,-0.3522,0.0942,-0.0564,null,0.0263,-0.3787,-0.8164,-0.6446,0.5502]},
            {"timestamp":"2020-07-13T20:46:46Z","values": [1,5.3969,-0.472,0.75,0.3282,6.5583,0.0238,-0.2817,-0.3909,0.8025,0.5054]},
            {"timestamp":"2020-07-13T20:47:46Z","values": [1,0.2148,-0.516,-0.0296,0.2276,5.7661,0.5468,0.534,0.2702,-0.4179,0.0011]}