create_model

MachineLearningApi.create_model(role_id, model_data, content_type=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)

Register a SageMaker ML model

Creates an Amorphic ML model from either ArtifactsLocation (custom SageMaker model) or ExistingModelResource (tag an existing SageMaker model). Provide exactly one of those two fields.

Parameters:
  • role_id (str) – Role identifier used for authorization. Missing this header returns AUTH-1001. (required)

  • model_data (ModelData) – (required)

  • content_type (str)

  • _request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

  • _request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.

  • _content_type (str, Optional) – force content-type for the request.

  • _headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.

  • _host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.

Return type:

ModelCreateOutput

Returns:

Returns the result object.

Request and Response Examples

HTTP: POST /models

Request

Custom model from a temp-bucket artifact path

{
  "ModelName": "sales-blazingtext",
  "Description": "Classifies product review sentiment",
  "Keywords": [
    "nlp"
  ],
  "ArtifactsLocation": "s3://example-ml-temp/ml-models/7f3a2c1e-9b44-4d21-8c0a-1a2b3c4d5e6f/sampleFile.gz",
  "OutputType": "metadata",
  "AlgorithmUsed": "BlazingText",
  "SupportedFileFormats": [
    "csv",
    "parquet",
    "txt"
  ],
  "PreProcessedGlueJobs": "custom_role_job",
  "PostProcessedGlueJobs": "custom_role_job"
}

datasetdata output with input and output schemas

{
  "ModelName": "sales-forecast",
  "Description": "Forecasts daily sales quantities",
  "Keywords": [
    "forecast"
  ],
  "ArtifactsLocation": "s3://example-ml-temp/ml-models/8a4b5c6d-1e2f-4a3b-9c0d-2e3f4a5b6c7d/model.tar",
  "OutputType": "datasetdata",
  "AlgorithmUsed": "DeepARForecasting",
  "SupportedFileFormats": [
    "csv"
  ],
  "PreProcessedGlueJobs": "custom_role_job",
  "PostProcessedGlueJobs": "custom_role_job",
  "InputSchema": [
    {
      "name": "timestamp",
      "type": "timestamp",
      "description": "Observation time"
    },
    {
      "name": "target",
      "type": "float",
      "description": "Quantity sold"
    }
  ],
  "OutputSchema": [
    {
      "name": "predicted_qty",
      "type": "float",
      "description": "Predicted quantity"
    }
  ]
}

Success (HTTP 200)

Model registered. Message is Model created successfully and ModelId is the new identifier (SageMaker model name for custom creates).

Request / response example

{
  "Message": "Model created successfully",
  "ModelId": "7f3a2c1e-9b44-4d21-8c0a-1a2b3c4d5e6f"
}

Errors

Documented error codes: IPV-1038, MDL-1001, IPV-1004, IPV-1018, GE-1008.

HTTP 400

Invalid body. Typical cases include missing required keys (IPV-1038), both or neither artifact fields (IPV-1038), invalid OutputType (MDL-1001), invalid ModelName (IPV-1004), or duplicate name (IPV-1018).

Required keys missing

{
  "Message": "IPV-1038 - Request body doesn't have required keys ['Keywords'] to carryout this operation"
}

ModelName fails the 3-50 alphanumeric and hyphen pattern

{
  "Message": "IPV-1004 - ModelName must be 3-50 alphanumeric, hyphen characters only."
}

OutputType is not metadata or datasetdata

{
  "Message": "MDL-1001 - Output type of a model cannot be image and can only be one of metadata and datasetdata"
}

HTTP 500

Unexpected failure while creating the model (GE-1008).

Request / response example

{
  "Message": "GE-1008 - Could not complete the request. Please try again."
}