Installation

The package is available on pypi. To install, use pip:

$pip install -U ibm-watson-openscale

Requirements

Watson OpenScale service instance, you can create instance using this link. Only Python 3.5 or newer is supported. ibm-cloud-sdk-core >= 1.1 is required to be able to authenticate to the service.

Breaking changes log

  • Watson Machine Learning instances in regions other than US-South (Dallas) are not officially supported.

  • Only one deployment per subscription is supported.

Supported engines

  • Watson Machine Learning

  • Custom Machine Learning (following this specification)

  • Microsoft Azure Machine Learning Studio (deployments of type new)

  • Amazon SageMaker Machine Learning

  • SPSS Collaboration and Deployment Services

API

To start working with the client library you need Watson OpenScale service credentials. Credentials can be found under Credentials tab of your service instance (IBM Cloud). An OpenScale Python SDK v2 uses an ibm-cloud-sdk-core package to authenticate with the service. For more detailed description of the authentication, please visit: IBM Cloud SDK Core

Below is presented the programmatically version of client initialization. All necessary credentials must be provided during APIClient object creation. Only authenticator parameter is required, but have in mind that passing only authenticator parameter, the default options will be used (service_url = “https://api.aiopenscale.cloud.ibm.com” and service_instance_id will be retrieved automatically)

from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_watson_openscale import APIClient

service_credentials = {
                  "apikey": "*****",
                  "url": "https://api.aiopenscale.cloud.ibm.com"
               }

authenticator = IAMAuthenticator(
        apikey=service_credentials['apikey']
    )

# default value of service_url = "https://api.aiopenscale.cloud.ibm.com",
# service_instance_id retrieved automatically
client = APIClient(
        authenticator=authenticator
    )

# or

# service_instance_id retrieved automatically
client = APIClient(
    service_url=service_credentials['url'],
    authenticator=authenticator
)

# or

client = APIClient(
    service_url=service_credentials['url'],
    service_instance_id="230a8e9f-2453-4c2d-a560-2a75399210bf"
    authenticator=authenticator
)

In case of CP4D environments, CloudPakForDataAuthenticator class should be used (instead of IAMAuthenticator)

from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
from ibm_watson_openscale import APIClient

service_credentials = {
                "url": "******",
                "username": "*****",
                "password": "*****"
                }

authenticator = CloudPakForDataAuthenticator(
        url=service_credentials['url'],
        username=service_credentials['username'],
        password=service_credentials['password'],
        disable_ssl_verification=True
    )

# default value of service_url = "https://api.aiopenscale.cloud.ibm.com",
# service_instance_id retrieved automatically
client = APIClient(
        authenticator=authenticator
    )

# or

# service_instance_id retrieved automatically
client = APIClient(
    service_url=service_credentials['url'],
    authenticator=authenticator
)

# or

client = APIClient(
    service_url=service_credentials['url'],
    service_instance_id="230a8e9f-2453-4c2d-a560-2a75399210bf"
    authenticator=authenticator
)

You could initialize the client from environmental variables directly or from configuration file. The service_name must be identical in the configuration file and passed to the new_instance() class method of the client

File with configuration:

# bm-credentials.env
OpenScale_URL=https://api.aiopenscale.cloud.ibm.com
OpenScale_AUTH_TYPE=iam
OpenScale_APIKEY=ncn92u92benfi2nec0292ebicm02
OpenScale_AUTH_URL=https://iam.cloud.ibm.com/identity/token

How to use new_instance() class method:

from ibm_watson_openscale import APIClient
import os

os.environ["IBM_CREDENTIALS_FILE"] = "path_to_credential_file/ibm-credentials.env"
ai_client = APIClient.new_instance(service_name='OpenScale')

Basic SDK’s elements

APIClient

class WatsonOpenScaleV2Adapter(authenticator: Optional[Union[ibm_cloud_sdk_core.authenticators.bearer_token_authenticator.BearerTokenAuthenticator, ibm_cloud_sdk_core.authenticators.cp4d_authenticator.CloudPakForDataAuthenticator, ibm_cloud_sdk_core.authenticators.iam_authenticator.IAMAuthenticator, ibm_watson_openscale.supporting_classes.cp4d_authenticator.CloudPak40ForDataAuthenticator]] = None, service_url: Optional[str] = None, service_instance_id: Optional[str] = None)[source]

Bases: ibm_watson_openscale.base_classes.watson_open_scale_v2.WatsonOpenScaleV2

Watson OpenScale client.

Variables

#:var business_applications: Manages business_applications module #:vartype business_applications: ibm_watson_openscale.business_applications.BusinessApplications

A way you might use me is:

>>> from ibm_watson_openscale import APIClient
>>> client = APIClient(authenticator=authenticator, service_url=service_url) # client will use default service_instance_id
>>> client = APIClient(authenticator, service_url) # client will use default service_url and default service_instance_id
>>> client = APIClient(authenticator=authenticator, service_url=service_url, service_instance_id=service_instance_id)
>>> client = APIClient(authenticator, service_url, service_instance_id)
classmethod new_instance(service_name: Optional[str] = None)ibm_watson_openscale.client.WatsonOpenScaleV2Adapter[source]

This class method should be used only if you have stored your credentials in the separate file or in the ENV variable.

Parameters

service_name – Unique name of the service to configure.

Returns

ibm_watson_openscale.APIClient

A way you might use me is:

>>> from ibm_watson_openscale import APIClient
>>> client = APIClient.new_instance(service_name="openscale-1")
>>> client = APIClient.new_instance(service_name="openscale-2")
>>> client = APIClient.new_instance("openscale")
version

#make use of new authenticator class which works for 3.5.x and 4.0(iamintegration=true) if isinstance(authenticator, CloudPakForDataAuthenticator):

url = authenticator.token_manager.url[0:authenticator.token_manager.url.index(“/”,9)] username = authenticator.token_manager.username password = authenticator.token_manager.password authenticator = CloudPak40ForDataAuthenticator(url=url,

username=username, password=password, disable_ssl_verification=True)

APIClient.data_marts

class DataMarts(ai_client: WatsonOpenScaleV2Adapter)[source]

Bases: ibm_watson_openscale.base_classes.watson_open_scale_v2.DataMarts

Manages Database instance.

show(limit: Optional[int] = 10)None[source]

Show Data marts. By default 10 records will be shown.

Parameters

limit (int) – Maximal number of fetched rows. By default set to 10. (optional)

A way you might use me is:

>>> client.data_marts.show()
>>> client.data_marts.show(limit=20)
>>> client.data_marts.show(limit=None)
add(name: str = None, description: str = None, service_instance_crn: str = None, internal_database: bool = None, database_configuration: DatabaseConfigurationRequest = None, force: bool = None, background_mode: bool = True)DetailedResponse[source]

Add the data mart. Configure database connection for the data mart.

Parameters
  • name (str) – (optional) Name of the data mart.

  • description (str) – (optional) Description of the data mart.

  • service_instance_crn (str) – (optional) Can be omitted if user token is used for authorization.

  • internal_database (bool) – (optional) If true the internal database managed by AI OpenScale is provided for the user.

  • database_configuration (DatabaseConfigurationRequest) – (optional) Database configuration ignored if internal database is requested (internal_database is true).

  • force (bool) – (optional) force update of metadata and db credentials (assumption is that the new database is already prepared and populated).

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataMartDatabaseResponse result

A way you might use me is:

>>> from ibm_watson_openscale import *
>>> client.data_marts.add(
        background_mode=False,
        name="My Data Mart",
        description="Description of the data mart...",
        database_configuration=DatabaseConfigurationRequest(
            database_type='postgresql',
            instance_id='crn:v1:bluemix:public:databases-for-postgresql:us-south:a/***',
            credentials=PrimaryStorageCredentialsLong(
                hostname='some hostname',
                username='some username',
                password='some password',
                db='database name',
                port=50000,
                ssl=True,
                sslmode='verify-full',
                certificate_base64='***'
            ),
            location=LocationSchemaName(
                schema_name='name of the database schema'
            )
        )
     )
delete(data_mart_id: str, force: bool = None, background_mode: bool = True)DetailedResponse[source]

Delete the data mart.

Parameters
  • data_mart_id (str) – ID of the data mart.

  • force (bool) – (optional) force hard delete.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

A way you might use me is:

>>> client.data_marts.delete(
        background_mode=False,
        data_mart_id='id of the datamart',
        force=True
     )
get(data_mart_id: str, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Get data mart with the given id.

Parameters
  • data_mart_id (str) – ID of the data mart.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataMartDatabaseResponse result

list(**kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List all data marts.

The method returns the data mart confugrations as an object.

Parameters

headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataMartDatabaseResponseCollection result

patch(data_mart_id: str, json_patch_operation: List[ibm_watson_openscale.base_classes.watson_open_scale_v2.JsonPatchOperation], **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Update a data mart.

Parameters
  • data_mart_id (str) – ID of the data mart.

  • json_patch_operation (List[JsonPatchOperation]) –

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataMartDatabaseResponse result

APIClient.service_providers

class ServiceProviders(ai_client: WatsonOpenScaleV2Adapter)[source]

Bases: ibm_watson_openscale.base_classes.watson_open_scale_v2.ServiceProviders

Manages Service Provider instance.

show(limit: Optional[int] = 10, show_deleted: Optional[bool] = None, service_type: Optional[str] = None, instance_id: Optional[str] = None, operational_space_id: Optional[str] = None, deployment_space_id: Optional[str] = None, **kwargs)None[source]

Show service providers. By default 10 records will be shown.

Parameters
  • limit (int) – maximal number of fetched rows. By default set to 10. (optional)

  • show_deleted (bool) – (optional) show also resources pending delete.

  • service_type (str) – (optional) Type of service.

  • instance_id (str) – (optional) comma-separeted list of IDs.

  • operational_space_id (str) – (optional) comma-separeted list of IDs.

  • deployment_space_id (str) – (optional) comma-separeted list of IDs.

  • headers (dict) – A dict containing the request headers

A way you might use me is:

>>> client.service_providers.show()
>>> client.service_providers.show(limit=20)
>>> client.service_providers.show(limit=None)
add(name: str, service_type: str = None, description: str = None, credentials: MLCredentials = None, request_headers: object = None, operational_space_id: str = None, deployment_space_id: str = None, background_mode: bool = True)DetailedResponse[source]

Add service provider.

Assosiate external Machine Learning service instance with the OpenScale DataMart.

Parameters
  • name (str) – Name of the ML service instance.

  • service_type (str) – (optional) machine learning service type (azure_machine_learning_studio is a preferred alias for azure_machine_learning and should be used in new service bindings).

  • description (str) – (optional)

  • credentials (MLCredentials) – (optional)

  • request_headers (object) – (optional) map header name to header value.

  • operational_space_id (str) – (optional) Reference to Operational Space. Allowed values are ‘production’ and ‘pre-production’

  • deployment_space_id (str) – (optional) Reference to V2 Space ID

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with ServiceProviderResponse result

A way you may use me when WML is located on same cluster

>>> from ibm_watson_openscale import *
>>> added_service_provider_info = client.service_providers.add(
        background_mode=False,
        name="WML instance",
        service_type=ServiceTypes.WATSON_MACHINE_LEARNING,
        deployment_space_id = <SPACE_ID>,
        operational_space_id = "production"
        credentials=WMLCredentialsCloud(
            url='<URL>',
            username='<USERNAME>',
            password='<PASSWORD>'
        )
     )

A way you may use me when WML is located on different CP4D cluster

>>> from ibm_watson_openscale import *
>>> from ibm_watson_openscale.supporting_classes.enums import *
>>> added_service_provider_info = client.service_providers.add(
        background_mode=False,
        name="WML instance",
        service_type=ServiceTypes.WATSON_MACHINE_LEARNING,
        deployment_space_id = <SPACE_ID>,
        operational_space_id = "production"
        credentials=WMLCredentialsCloud(
            url = '<URL>',
            username='<USERNAME>,
            apikey='APIKEY>',
            wml_location = CP4DWMLLocation.CPD_REMOTE
        )
     )

A way you may use me when WML is located on IBM Cloud

>>> from ibm_watson_openscale import *
>>> from ibm_watson_openscale.supporting_classes.enums import *
>>> added_service_provider_info = client.service_providers.add(
        background_mode=False,
        name="WML instance",
        service_type=ServiceTypes.WATSON_MACHINE_LEARNING,
        deployment_space_id = <SPACE_ID>,
        operational_space_id = "production"
        credentials=WMLCredentialsCloud(
            url = '<URL>',
            apikey='APIKEY>',
            wml_location = CP4DWMLLocation.CLOUD_REMOTE
        )
     )
delete(service_provider_id: str, force: bool = None, background_mode: bool = True)DetailedResponse[source]

Delete service provider.

Detach Machine Learning service provider.

Parameters
  • service_provider_id (str) – ID of the ML service provider.

  • force (bool) – (optional) force hard delete.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

A way you may use me:

>>> client.service_providers.delete(
        background_mode=False,
        service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        force=True
     )
list_assets(data_mart_id: str, service_provider_id: str, deployment_id: Optional[str] = None, deployment_space_id: Optional[str] = None)requests.models.Response[source]

Listing all deployments and assets for specific data_mart and service_provider.

Parameters
  • data_mart_id (str) – ID of the data_mart (required)

  • service_provider_id (str) – ID of the service_provider (required)

  • deployment_id (str) – ID of the deployment (optional), when used, only specific deployment is returned

  • deployment_space_id (str) – (optional) Reference to V2 Space ID

Returns

Response

A way you may use me:

>>> response = client.service_providers.list_assets(
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5'
     )
>>> print(response.result)
 {'count': 1,
 'resources': [{'entity': {'asset': {'asset_id': '997b1474-00d2-4g05-ac02-287ebfc603b5',
                                     'asset_type': 'model',
                                     'created_at': '2020-01-13T09:15:26.586Z',
                                     'name': 'AIOS Spark Credit Risk model',
                                     'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/published_models/997b1474-00d2-4g05-ac02-287ebfc603b5'},
                           'asset_properties': {'asset_revision': '997b1474-00d2-4g05-ac02-287ebfc603b5',
                                                'input_data_schema': {'fields': [{'metadata': {},
                                                                                  'name': 'CheckingStatus',
                                                                                  'nullable': True,
                                                                                  'type': 'string'},
                                                                                 ...
                                                'label_column': 'Risk',
                                                'model_type': 'mllib-2.3',
                                                'runtime_environment': 'spark-2.3',
                                                'training_data_schema': {'fields': [{'metadata': {},
                                                                                     'name': 'CheckingStatus',
                                                                                     'nullable': True,
                                                                                     'type': 'string'},
                                                                                    ...
                           'description': 'Description of deployment',
                           'name': 'AIOS Spark Credit Risk deployment',
                           'scoring_endpoint': {'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5/online'},
                           'type': 'online'},
                'metadata': {'created_at': '2020-01-13T09:15:26.607Z',
                             'guid': '997b1474-00d2-4g05-ac02-287ebfc603b5',
                             'modified_at': '2020-01-13T09:15:26.848Z',
                             'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5'}}]}
>>> response = client.service_providers.list_assets(
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5'
        deployment_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5'
     )
get_deployment_asset(data_mart_id: str, service_provider_id: str, deployment_id: str, deployment_space_id: Optional[str] = None)requests.models.Response[source]

Listing all deployments and assets for specific data_mart and service_provider.

Parameters
  • data_mart_id (str) – ID of the data_mart (required)

  • service_provider_id (str) – ID of the service_provider (required)

  • deployment_id (str) – ID of the deployment (required), when used, only specific deployment is returned

  • deployment_space_id (str) – Reference to V2 Space ID (required)

Returns

Response

A way you may use me:

>>> response = client.service_providers.list_assets(
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5'
     )
>>> print(response.result)
 {'entity': {'asset': {'asset_id': '997b1474-00d2-4g05-ac02-287ebfc603b5',
                                     'asset_type': 'model',
                                     'created_at': '2020-01-13T09:15:26.586Z',
                                     'name': 'AIOS Spark Credit Risk model',
                                     'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/published_models/997b1474-00d2-4g05-ac02-287ebfc603b5'},
                           'asset_properties': {'asset_revision': '997b1474-00d2-4g05-ac02-287ebfc603b5',
                                                'input_data_schema': {'fields': [{'metadata': {},
                                                                                  'name': 'CheckingStatus',
                                                                                  'nullable': True,
                                                                                  'type': 'string'},
                                                                                 ...
                                                'label_column': 'Risk',
                                                'model_type': 'mllib-2.3',
                                                'runtime_environment': 'spark-2.3',
                                                'training_data_schema': {'fields': [{'metadata': {},
                                                                                     'name': 'CheckingStatus',
                                                                                     'nullable': True,
                                                                                     'type': 'string'},
                                                                                    ...
                           'description': 'Description of deployment',
                           'name': 'AIOS Spark Credit Risk deployment',
                           'scoring_endpoint': {'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5/online'},
                           'type': 'online'},
                'metadata': {'created_at': '2020-01-13T09:15:26.607Z',
                             'guid': '997b1474-00d2-4g05-ac02-287ebfc603b5',
                             'modified_at': '2020-01-13T09:15:26.848Z',
                             'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5'}}
>>> response = client.service_providers.get_deployment_asset(
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5'
        deployment_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5'
     )
get(service_provider_id: str, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Get a specific service provider.

Get the assosiated Machine Learning service provider details.

Parameters
  • service_provider_id (str) – ID of the ML service provider.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with ServiceProviderResponse result

list(*, show_deleted: Optional[bool] = None, service_type: Optional[str] = None, instance_id: Optional[str] = None, operational_space_id: Optional[str] = None, deployment_space_id: Optional[str] = None, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List service providers.

List assosiated Machine Learning service instances.

Parameters
  • show_deleted (bool) – (optional) show also resources pending delete.

  • service_type (str) – (optional) Type of service.

  • instance_id (str) – (optional) comma-separeted list of IDs.

  • operational_space_id (str) – (optional) comma-separeted list of IDs.

  • deployment_space_id (str) – (optional) comma-separeted list of IDs.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with ServiceProviderResponseCollection result

update(service_provider_id: str, patch_document: List[ibm_watson_openscale.base_classes.watson_open_scale_v2.PatchDocument], **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Update a service provider.

Update existing service provider.

Parameters
  • service_provider_id (str) – ID of the ML service provider.

  • patch_document (List[PatchDocument]) –

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with ServiceProviderResponse result

APIClient.subscriptions

class Subscriptions(ai_client: WatsonOpenScaleV2Adapter)[source]

Bases: ibm_watson_openscale.base_classes.watson_open_scale_v2.Subscriptions

Manages Subscription instance.

show(limit: Optional[int] = 10, data_mart_id: Optional[str] = None, service_provider_id: Optional[str] = None, asset_asset_id: Optional[str] = None, deployment_deployment_id: Optional[str] = None, deployment_deployment_type: Optional[str] = None, integration_reference_integrated_system_id: Optional[str] = None, integration_reference_external_id: Optional[str] = None, risk_evaluation_status_state: Optional[str] = None, service_provider_operational_space_id: Optional[str] = None, pre_production_reference_id: Optional[str] = None, **kwargs)None[source]

Show service providers. By default 10 records will be shown.

Parameters
  • limit (int) – maximal number of fetched rows. By default set to 10. (optional)

  • data_mart_id (str) – (optional) comma-separeted list of IDs.

  • service_provider_id (str) – (optional) comma-separeted list of IDs.

  • asset_asset_id (str) – (optional) comma-separeted list of IDs.

  • deployment_deployment_id (str) – (optional) comma-separeted list of IDs.

  • deployment_deployment_type (str) – (optional) comma-separeted list of types.

  • integration_reference_integrated_system_id (str) – (optional) comma-separeted list of IDs.

  • integration_reference_external_id (str) – (optional) comma-separeted list of IDs.

  • risk_evaluation_status_state (str) – (optional) comma-separeted list of states.

  • service_provider_operational_space_id (str) – (optional) comma-separeted list of operational space ids (property of service provider object).

  • pre_production_reference_id (str) – (optional) comma-separeted list of IDs.

  • headers (dict) – A dict containing the request headers

A way you might use me is:

>>> client.subscriptions.show()
>>> client.subscriptions.show(limit=20)
>>> client.subscriptions.show(limit=None)
add(data_mart_id: str, service_provider_id: str, asset: Asset, deployment: AssetDeploymentRequest, asset_properties: AssetPropertiesRequest = None, risk_evaluation_status: RiskEvaluationStatus = None, analytics_engine: AnalyticsEngine = None, data_sources: List[DataSource] = None, training_data_stats: dict = None, background_mode: bool = True, **kwargs)Optional[Union[DetailedResponse, dict]][source]

Add a subscription to the model deployment.

Parameters
  • data_mart_id (str) – ID of the data_mart (required)

  • service_provider_id (str) – ID of the service_provider (required)

  • asset (Asset) – an Asset object with asset’s information (required)

  • deployment (AssetDeploymentRequest) – an AssetDeploymentRequest object with deployment’s information (required)

  • asset_properties (AssetPropertiesRequest) – (optional) Additional asset properties (subject of discovery if not provided when creating the subscription).

  • risk_evaluation_status (RiskEvaluationStatus) – (optional)

  • analytics_engine (AnalyticsEngine) – (optional)

  • data_sources (List[DataSource]) – (optional)

  • training_data_stats – Training statistic json generated using training stats notebook (https://github.com/IBM-Watson/aios-data-distribution/blob/master/training_statistics_notebook.ipynb)

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with SubscriptionResponse result

A way you may use me:

>>> from ibm_watson_openscale import *
>>> added_subscription_info = client.subscriptions.add(
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        asset=Asset(...),
        deployment=AssetDeploymentRequest(...),
        asset_properties=AssetPropertiesRequest(...),
     )
delete(subscription_id: str, force: bool = None, background_mode: bool = True)Optional[Union[DetailedResponse, dict]][source]

Delete subscription.

Parameters
  • subscription_id (str) – Unique subscription ID.

  • force (bool) – (optional) force hard delete.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

A way you may use me:

>>> client.subscriptions.delete(
        background_mode=False,
        subscription_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        force=True
     )
get(subscription_id: str, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Get a specific subscription.

Get a specific subscription.

Parameters
  • subscription_id (str) – Unique subscription ID.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with SubscriptionResponse result

list(*, data_mart_id: Optional[str] = None, service_provider_id: Optional[str] = None, asset_asset_id: Optional[str] = None, deployment_deployment_id: Optional[str] = None, deployment_deployment_type: Optional[str] = None, integration_reference_integrated_system_id: Optional[str] = None, integration_reference_external_id: Optional[str] = None, risk_evaluation_status_state: Optional[str] = None, service_provider_operational_space_id: Optional[str] = None, pre_production_reference_id: Optional[str] = None, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List subscriptions.

List subscriptions.

Parameters
  • data_mart_id (str) – (optional) comma-separeted list of IDs.

  • service_provider_id (str) – (optional) comma-separeted list of IDs.

  • asset_asset_id (str) – (optional) comma-separeted list of IDs.

  • deployment_deployment_id (str) – (optional) comma-separeted list of IDs.

  • deployment_deployment_type (str) – (optional) comma-separeted list of types.

  • integration_reference_integrated_system_id (str) – (optional) comma-separeted list of IDs.

  • integration_reference_external_id (str) – (optional) comma-separeted list of IDs.

  • risk_evaluation_status_state (str) – (optional) comma-separeted list of states.

  • service_provider_operational_space_id (str) – (optional) comma-separeted list of operational space ids (property of service provider object).

  • pre_production_reference_id (str) – (optional) comma-separeted list of IDs.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with SubscriptionResponseCollection result

schemas(subscription_id: str, *, input_data: Optional[List[ibm_watson_openscale.base_classes.watson_open_scale_v2.ScoreData]] = None, training_data_reference: Optional[ibm_watson_openscale.base_classes.watson_open_scale_v2.InputDataReference] = None, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Derive model schemas from the training data.

Derive model schemas from the training data. Only “structured” input data type is supported. If the input_data_type field in the subscription (subscription -> entity -> asset -> input_data_type) is not “structured”, an error will be returned.

Parameters
  • subscription_id (str) – Unique subscription ID.

  • input_data (List[ScoreData]) – (optional) Array of score data object. If multiple score data objects are included, the “fields” array (if any) for score purposes will always be taken from the first score data object.

  • training_data_reference (InputDataReference) – (optional) InputDataReference is the same as TrainingDataReference except that neither location nor connection is required. This is needed for the Schemas API and to avoid updating existing APIs.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with SchemaInferenceResponse result

score(subscription_id: str, values: List[str], *, fields: Optional[List[str]] = None, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Computes the bias mitigation/remediation for the specified model.

Computes the bias mitigation/remediation for the specified model. The fairness monitoring debias request payload details must be valid.

Parameters
  • subscription_id (str) – Unique subscription ID.

  • values (List[str]) – The values associated to the fields.

  • fields (List[str]) – (optional) The fields to process debias scoring.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with FairnessMonitoringRemediation result

update(subscription_id: str, patch_document: List[ibm_watson_openscale.base_classes.watson_open_scale_v2.PatchDocument], **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Update a subscription.

Update existing asset (from ML service instance) subscription.

Parameters
  • subscription_id (str) – Unique subscription ID.

  • patch_document (List[PatchDocument]) –

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with SubscriptionResponse result

APIClient.data_sets

class DataSets(ai_client: WatsonOpenScaleV2Adapter)[source]

Bases: ibm_watson_openscale.base_classes.watson_open_scale_v2.DataSets

Manages Data Sets.

show(limit: int = 10, target_target_id: Optional[str] = None, target_target_type: Optional[str] = None, type: Optional[str] = None, managed_by: Optional[str] = None, **kwargs)None[source]

Show data sets. By default 10 records will be shown.

Parameters
  • limit (int) – maximal number of fetched rows. By default set to 10. (optional)

  • target_target_id (str) – (optional) ID of the data set target (e.g. subscription ID, business application ID).

  • target_target_type (str) – (optional) type of the target.

  • type (str) – (optional) type of the data set.

  • managed_by (str) – (optional) ID of the managing entity (e.g. business application ID).

  • headers (dict) – A dict containing the request headers

Returns

None

A way you might use me is:

>>>   client.data_sets.show()
>>>   client.data_sets.show(limit=20)
>>>   client.data_sets.show(limit=None)
add(data_mart_id: str, name: str, type: str, target: Target, data_schema: SparkStruct, description: str = None, schema_update_mode: str = None, location: LocationTableName = None, managed_by: str = None, background_mode: bool = True)Optional[Union[DetailedResponse, dict]][source]

Create Data Set.

Parameters
  • data_mart_id (str) –

  • name (str) –

  • type (str) –

  • target (Target) –

  • data_schema (SparkStruct) –

  • description (str) – (optional)

  • schema_update_mode (str) – (optional)

  • location (LocationTableName) – (optional)

  • managed_by (str) – (optional)

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataSetResponse result

A way you might use me is:

>>> from ibm_watson_openscale import *
>>> target = Target(
         target_id='subscription_id',
          target_type=TargetTypes.SUBSCRIPTION
       )
>>> data_schema = SparkStruct(
          type='struct',
          fields=[
              SparkStructField(
                  name='CheckingStatus',
                  type='string',
                  nullable=True,
                  metadata={'columnInfo': {'columnLength': 64},
                            'measure': 'discrete',
                            'modeling_role': 'feature'}
              ),
              SparkStructField(
                  name='LoanDuration',
                  type='integer',
                  nullable=True,
                  metadata={'modeling_role': 'feature'}
              ),
              SparkStructField(
                  name='asset_revision',
                  type='string',
                  nullable=True,
                  metadata={}
              )
          ]
       )
>>> custom_dataset_info = client.data_sets.add(
          target=target,
          name='custom dataset',
          type='custom',
          data_schema=data_schema,
          data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5'
       )
delete(data_set_id: str, background_mode: bool = True)Optional[Union[DetailedResponse, dict]][source]

Delete Data Set.

Parameters
  • data_set_id (str) – ID of the data set.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

A way you may use me:

>>> client.data_sets.delete(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
store_records(data_set_id: str, request_body: Union[str, BufferedReader, List[PayloadRecord], List[List], List[Dict]], header: bool = None, skip: int = None, limit: int = None, delimiter: str = None, on_error: str = None, csv_max_line_length: float = None, background_mode: bool = True)Optional[Union[DetailedResponse, dict]][source]

Store records to specific data set.

Parameters
  • data_set_id (str) – ID of the data set.

  • scoring_payload_request (list[ScoringPayloadRequest]) –

  • header (bool) – (optional) if not provided service will attempt to automatically detect header in the first line.

  • skip (int) – (optional) skip number of rows from input.

  • limit (int) – (optional) limit for number of processed input rows.

  • delimiter (str) – (optional) delimiter character for data provided as csv.

  • on_error (str) – (optional) expected behaviour on error.

  • csv_max_line_length (float) – (optional) maximum length of single line in bytes (default 10MB).

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with Status result

A way you might use me is:

>>> from ibm_watson_openscale import *
>>> store_record_info = client.data_sets.store_records(
      request_body=[
                {
                  "GENDER": "M",
                  "PRODUCT_LINE": "Golf Equipment",
                  "AGE": 25,
                  "MARITAL_STATUS": "Unspecified",
                  "PROFESSION": "Sales"
                },
                {
                  "GENDER": "M",
                  "PRODUCT_LINE": "Sport shoes",
                  "AGE": 28,
                  "MARITAL_STATUS": "Married",
                  "PROFESSION": "Sales"
                },
                {
                  "GENDER": "F",
                  "PRODUCT_LINE": "Sport shoes",
                  "AGE": 25,
                  "MARITAL_STATUS": "Single",
                  "PROFESSION": "Software Developer"
                }
          ],
      data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
  )
>>> from ibm_watson_openscale.supporting_classes.payload_record import PayloadRecord
>>> store_record_info = client.data_sets.store_records(
      request_body=[PayloadRecord(
           scoring_id='42e62c3ae2244f0d851009dec4754d74',
           request={
              "fields": ["CheckingStatus", "LoanDuration", "CreditHistory", "LoanPurpose",
                  "LoanAmount", "ExistingSavings", "EmploymentDuration", "InstallmentPercent", "Sex",
                  "OthersOnLoan", "CurrentResidenceDuration", "OwnsProperty", "Age", "InstallmentPlans",
                  "Housing", "ExistingCreditsCount", "Job", "Dependents", "Telephone", "ForeignWorker"],
              "values": [["less_0", 4, "all_credits_paid_back", "car_new", 250, "less_100", "less_1", 2,
                  "male", "none", 1, "real_estate", 26, "stores", "rent", 1, "unskilled", 1,
                  "none", "yes"]]
              },
           response={
              "fields": ["CheckingStatus", "LoanDuration", "CreditHistory", "LoanPurpose", "LoanAmount",
                  "ExistingSavings", "EmploymentDuration", "InstallmentPercent", "Sex", "OthersOnLoan",
                  "CurrentResidenceDuration", "OwnsProperty", "Age", "InstallmentPlans", "Housing",
                  "ExistingCreditsCount", "Job", "Dependents", "Telephone", "ForeignWorker",
                  "CheckingStatus_IX", "CreditHistory_IX", "EmploymentDuration_IX", "ExistingSavings_IX",
                  "ForeignWorker_IX", "Housing_IX", "InstallmentPlans_IX", "Job_IX", "LoanPurpose_IX",
                  "OthersOnLoan_IX", "OwnsProperty_IX", "Sex_IX", "Telephone_IX", "features", "rawPrediction",
                  "probability", "prediction", "predictedLabel"],
              "values": [["less_0", 4, "all_credits_paid_back", "car_new", 250, "less_100", "less_1", 2,
                  "male", "none", 1, "real_estate", 26, "stores", "rent", 1, "unskilled", 1, "none", "yes",
                  1.0, 3.0, 3.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 2.0, 0.0, 0.0, [1.0, 3.0, 0.0, 0.0, 3.0,
                  0.0, 0.0, 2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 4.0, 250.0, 2.0, 1.0, 4.0, 26.0, 1.0, 1.0],
                  [19.600662549552556, 0.39933745044744245], [0.9800331274776278, 0.01996687252237212],
                  0.0, "No Risk"]]
              },
           response_time=460
       )],
      data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
  )
>>> csv_buffer_reader = io.open('path_to_csv', mode="rb")
>>> store_record_info = client.data_sets.store_records(
      request_body=csv_buffer_reader,
      delimiter=',',
      header=True,
      limit=100,
      data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
      csv_max_line_length = 8196
  )
get_update_status(data_set_id: str, request_id: str)DetailedResponse[source]

Get status of the specific request.

Parameters
  • data_set_id (str) – ID of the data set.

  • request_id (str) – ID of the request.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with Status result

A way you might use me is:

>>> update_status = client.data_sets.get_update_status(
      data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
      request_id='7843-00d35462-346-ac0672-7357'
   )
get_list_of_records(data_set_id: str, limit: int = 100, start: datetime = None, end: datetime = None, offset: int = None, annotations: List[str] = None, filter: str = None, include_total_count: bool = None, format: str = None, output_type: str = None)Union[DetailedResponse, DataFrame][source]

List data set records.

Parameters
  • data_set_id (str) – ID of the data set.

  • limit (int) – By default it will return 100 records. If the value is greater than 1000 than it will be truncated.

  • start (datetime) – (optional) return records with timestamp greater than or equal to start parameter. Date string should be in the UTC ISO 8601 format. Ex: 2021-06-10T09:43:53.309Z

  • end (datetime) – (optional) return records with timestamp lower than end parameter. Date string should be in the UTC ISO 8601 format. Ex: 2021-06-10T09:43:53.309Z

  • offset (int) – (optional) offset of returned records.

  • annotations (list[str]) – (optional) return record annotations with given names.

  • filter (str) – (optional) return records for which transaction ids in associated data set the condition is met, format: {data_set_id}.{field_name}:{op}:{value}.

  • include_total_count (bool) – (optional) If total_count should be included. It can have performance impact if total_count is calculated.

  • filter – (optional) return records for which transaction ids in associated data set the condition is met, format: {data_set_id}.{field_name}:{op}:{value}.

  • format (str) – (optional) What JSON format to use on output.

  • output_type (str) – (optional) type of the response data to be present, default is ‘dict’, available option is ‘pandas’

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataRecordsResponseCollection result

A way you might use me is:

>>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
>>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
                                                   format=RecordsFormatTypes.DICT
   )
>>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
                                                   format=RecordsFormatTypes.LIST
   )
>>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
                                                   output_type=ResponseTypes.PYTHON
   )
>>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
                                                   output_type=ResponseTypes.PANDAS
   )
show_records(data_set_id: Optional[str] = None, limit: int = 10)None[source]

Show data set records. By default 10 records will be shown.

Parameters
  • data_set_id (str) – ID of the data set.

  • limit (int) – Maximal number of fetched rows. By default set to 10. (optional)

Returns

None

A way you might use me is:

>>> client.data_sets.show_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
print_records_schema(data_set_id: Optional[str] = None)None[source]

Show data set records. By default 10 records will be shown.

Parameters

data_set_id (str) – ID of the data set.

Returns

None

A way you might use me is:

>>> client.data_sets.print_records_schema(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
get_records_count(data_set_id: Optional[str] = None)int[source]

Count data set records.

Parameters

data_set_id – ID of the data set.

Returns

int

A way you might use me is:

>>> number_of_records = client.data_sets.get_records_count(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
get(data_set_id: str, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Get data set with the given id.

Parameters
  • data_set_id (str) – ID of the data set.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataSetResponse result

list(*, target_target_id: Optional[str] = None, target_target_type: Optional[str] = None, type: Optional[str] = None, managed_by: Optional[str] = None, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List all data sets specified by the parameters.

Parameters
  • target_target_id (str) – (optional) ID of the data set target (e.g. subscription ID, business application ID).

  • target_target_type (str) – (optional) type of the target.

  • type (str) – (optional) type of the data set.

  • managed_by (str) – (optional) ID of the managing entity (e.g. business application ID).

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataSetResponseCollection result

update(data_set_id: str, patch_document: List[ibm_watson_openscale.base_classes.watson_open_scale_v2.PatchDocument], **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Update a data set.

Update the data set.

Parameters
  • data_set_id (str) – ID of the data set.

  • patch_document (List[PatchDocument]) –

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataSetResponse result

APIClient.monitor_instances

class MonitorInstances(ai_client: WatsonOpenScaleV2Adapter)[source]

Bases: ibm_watson_openscale.base_classes.watson_open_scale_v2.Instances

Manages Monitor Instances.

run(monitor_instance_id: str, triggered_by: Optional[str] = None, parameters=None, business_metric_context=None, background_mode: bool = True)Any[source]

Trigger monitoring run. :param str monitor_instance_id: Unique monitor instance ID. :param str triggered_by: (optional) An identifier representing the source

that triggered the run request (optional). One of: event, scheduler, user, webhook.

Parameters
  • parameters (MonitorInstanceParameters) – (optional) Monitoring parameters consistent with the parameters_schema from the monitor definition.

  • business_metric_context (MonitoringRunBusinessMetricContext) – (optional) Properties defining the business metric context in the triggered run of AI metric calculation.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitoringRun result

A way you may use me:

>>> monitor_instance_run_info = client.monitor_instances.run(
        background_mode=False,
        monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5'
     )
list(data_mart_id: str = None, monitor_definition_id: str = None, target_target_id: str = None, target_target_type: str = None)DetailedResponse[source]

List monitor instances.

Parameters
  • data_mart_id (str) – (optional) comma-separeted list of IDs.

  • monitor_definition_id (str) – (optional) comma-separeted list of IDs.

  • target_target_id (str) – (optional) comma-separeted list of IDs.

  • target_target_type (str) – (optional) comma-separeted list of types.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorInstanceCollection result

A way you may use me:

>>> monitor_instances_info = client.monitor_instances.list(
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
     )
show(limit: int = 10, data_mart_id: Optional[str] = None, monitor_definition_id: Optional[str] = None, target_target_id: Optional[str] = None, target_target_type: Optional[str] = None)None[source]

Show monitor instances. By default 10 records will be shown.

Parameters
  • limit (int) – Maximal number of fetched rows. By default set to 10. (optional)

  • data_mart_id (str) – (optional) comma-separeted list of IDs.

  • monitor_definition_id (str) – (optional) comma-separeted list of IDs.

  • target_target_id (str) – (optional) comma-separeted list of IDs.

  • target_target_type (str) – (optional) comma-separeted list of types.

Returns

None

A way you might use me is:

>>> client.monitor_instances.show()
>>> client.monitor_instances.show(limit=20)
>>> client.monitor_instances.show(20)
show_metrics(monitor_instance_id: str, limit: int = 10)[source]

Show metrics for monitor instance.

Parameters
  • monitor_instance_id (str) – ID of the monitor instance.

  • limit (int) – maximal number of fetched rows. By default set to 10. (optional)

Returns

None

A way you might use me is:

>>> client.monitor_instances.show_metrics(monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
create(monitor_definition_id: str, target: Target, data_mart_id: str = None, parameters: MonitorInstanceParameters = None, thresholds: List[MetricThresholdOverride] = None, schedule: MonitorInstanceSchedule = None, managed_by: str = None, training_data_stats: dict = None, background_mode: bool = True, **kwargs)Optional[Union[DetailedResponse, dict]][source]

Create monitor instance.

Parameters
  • data_mart_id (str) –

  • monitor_definition_id (str) –

  • target (Target) –

  • parameters (MonitorInstanceParameters) – (optional) Monitoring parameters consistent with the parameters_schema from the monitor definition.

  • thresholds (list[MetricThresholdOverride]) – (optional)

  • schedule (MonitorInstanceSchedule) – (optional) The schedule used to control how frequently the target is monitored. The maximum frequency is once every 30 minutes. Defaults to once every hour if not specified.

  • managed_by (str) – (optional)

  • training_data_stats – Training statistic json generated using training stats notebook (https://github.com/IBM-Watson/aios-data-distribution/blob/master/training_statistics_notebook.ipynb)

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorInstanceResponse result

A way you might use me is:

>>> from ibm_watson_openscale import *
>>> target = Target(
        target_type=TargetTypes.SUBSCRIPTION,
        target_id='997b1474-00d2-4g05-ac02-287ebfc603b5'
     )
>>> parameters = MonitorInstanceParameters(
        min_feedback_data_size=50
     )
>>> thresholds = [
        MetricThresholdOverride(
            metric_id=client.monitor_definitions.MONITORS.QUALITY.METRIC.ACCURACY,
            type=MetricThresholdTypes.LOWER_LIMIT,
            value=0.7
        )
     ]
>>> monitor_instances_info = client.monitor_instances.create(
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        background_mode=False,
        monitor_definition_id=client.monitor_definitions.MONITORS.QUALITY.ID,
        target=target,
        parameters=parameters,
        thresholds=thresholds
     )
delete(monitor_instance_id: str, background_mode: bool = True)Optional[Union[DetailedResponse, dict]][source]

Delete monitor instance.

Parameters
  • monitor_instance_id (str) – Unique monitor instance ID.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

A way you might use me is:

>>> ai_client_v2.monitor_instances.delete(
        background_mode=False,
        monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5'
     )
get(monitor_instance_id: str)DetailedResponse[source]

Get monitor instance details.

Parameters

monitor_instance_id (str) – Unique monitor instance ID.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorInstanceResponse result

A way you might use me is:

>>> monitor_instance_info = client.monitor_instances.get(
        monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5'
     )
update(monitor_instance_id: str, patch_document: List[PatchDocument], update_metadata_only: bool = None)DetailedResponse[source]

Update monitor instance.

Parameters
  • monitor_instance_id (str) – Unique monitor instance ID.

  • patch_document (List[PatchDocument]) –

  • update_metadata_only (bool) – (optional) Flag that allows to control if the underlaying actions related to the monitor reconfiguration should be triggered.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorInstanceResponse result

get_metrics_count(monitor_instance_id: str, start: datetime, end: datetime, interval: str = None, filter: str = None, group: str = None)[source]

Get the count of the metrics.

Parameters
  • monitor_instance_id (str) – Unique monitor instance ID.

  • start (datetime) – Calculations inclusive, internally floored to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.

  • end (datetime) – Calculations exclusive, internally ceiled to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.

  • agg (str) – Comma delimited function list constructed from metric name and function, e.g. agg=metric_name:count,:last that defines aggregations.

  • interval (str) – (optional) Time unit in which metrics are grouped and aggregated, interval by interval.

  • filter (str) – (optional) Filter expression can consist of any metric tag or a common column of string type followed by filter name and optionally a value, all delimited by colon. Supported filters are: in, eq, null and exists. Sample filters are: filter=region:in:[us,pl],segment:eq:sales or filter=region:null,segment:exists.

  • group (str) – (optional) Comma delimited list constructed from metric tags, e.g. group=region,segment to group metrics before aggregations.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataMartGetMonitorInstanceMetrics result

A way you might use me is:

>>> metrics_count = client.monitor_instances.get_metrics_count(
        monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        start=start_time,
        end=end_time,
     )
get_metrics(monitor_instance_id: str, start: datetime, end: datetime, interval: str = None, filter: str = None, group: str = None)[source]

Get all the generated metrics between start and end date for specific monitor instance id

Parameters
  • monitor_instance_id (str) – Unique monitor instance ID.

  • start (datetime) – Calculations inclusive, internally floored to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.

  • end (datetime) – Calculations exclusive, internally ceiled to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.

  • agg (str) – Comma delimited function list constructed from metric name and function, e.g. agg=metric_name:count,:last that defines aggregations.

  • interval (str) – (optional) Time unit in which metrics are grouped and aggregated, interval by interval.

  • filter (str) – (optional) Filter expression can consist of any metric tag or a common column of string type followed by filter name and optionally a value, all delimited by colon. Supported filters are: in, eq, null and exists. Sample filters are: filter=region:in:[us,pl],segment:eq:sales or filter=region:null,segment:exists.

  • group (str) – (optional) Comma delimited list constructed from metric tags, e.g. group=region,segment to group metrics before aggregations.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with DataMartGetMonitorInstanceMetrics result

A way you might use me is:

>>> metrics_count = client.monitor_instances.get_metrics_count(
        monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        start=start_time,
        end=end_time,
     )
upload_drift_model(model_path: str, data_mart_id: str, subscription_id: str, archive_name: str = 'user_drift.tar.gz', enable_data_drift: bool = True, enable_model_drift: bool = True)DetailedResponse[source]

Upload a Drift model to be able to compute Drift monitor.

Parameters
  • model_path (str) – (required) path to the drift model

  • data_mart_id (str) – (required) data_mart ID

  • subscription_id (str) – (required) subscription ID

  • archive_name (str) – (optional) Archive name to use while storing tarball in datamart

  • enable_data_drift (str) – (optional) If data drift is expected to be enabled for this subscription. If set to True, archive is verified to contain a valid data constraints json file.

  • enable_model_drift (str) – (optional) If model drift is expected to be enabled for this subscription. If set to True, archive is verified to contain a valid drift model pickle file.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

A way you might use me is:

>>> client.monitor_instances.upload_drift_model(
        model_path='drift_models/drift_detection_model.tar.gz',
        data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
        subscription_id='997b1474-00d2-4g05-ac02-287ebfc603b5',
     )
download_drift_model(monitor_instance_id: str)DetailedResponse[source]

Downloads the model.

Parameters

monitor_instance_id (str) – (required) The Drift monitor instance ID.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

A way you might use me is:

>>> client.monitor_instances.download_drift_model(
    monitor_instance_id="0a9a4b85-f2bb-46de-850b-f033d7d37d9a"
    )
download_drift_model_metadata(monitor_instance_id: str)DetailedResponse[source]

Downloads the model metadata.

Parameters

monitor_instance_id (str) – (required) The Drift monitor instance ID.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

A way you might use me is:

>>> client.monitor_instances.download_drift_model_metadata(
    monitor_instance_id="0a9a4b85-f2bb-46de-850b-f033d7d37d9a"
    )
list_runs(monitor_instance_id: str, start: Optional[str] = None, limit: Optional[int] = None)[source]

List monitoring runs.

List monitoring runs.

Parameters
  • monitor_instance_id (str) – Unique monitor instance ID.

  • start (str) – (optional) The page token indicating where to start paging from.

  • limit (int) – (optional) The limit of the number of items to return, for example limit=50. If not specified a default of 100 will be used.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitoringRunCollection result

get_run_details(monitor_instance_id: str, monitoring_run_id: str, **kwargs)[source]

Get monitoring run details. :param str monitor_instance_id: Unique monitor instance ID. :param str monitoring_run_id: Unique monitoring run ID. :param dict headers: A dict containing the request headers :return: A DetailedResponse containing the result, headers and HTTP status code. :rtype: DetailedResponse with MonitoringRun result

explanation_tasks(scoring_ids: List[str], input_rows: Optional[List[dict]] = None, explanation_types: Optional[List[str]] = None, subscription_id=None, **kwargs)[source]

Compute explanations.

Submit tasks for computing explanation of predictions.

Parameters
  • scoring_ids (List[str]) – IDs of the scoring transaction.

  • input_rows (List[dict]) – (optional) List of scoring transactions.

  • explanation_types (List[str]) – (optional) Types of explanations to generate.

  • subscription_id (str) – (optional) Unique subscription ID.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with PostExplanationTaskResponse result

get_explanation_tasks(explanation_task_id: str, **kwargs)[source]

Get explanation.

Get explanation for the given explanation task id.

Parameters
  • explanation_task_id (str) – ID of the explanation task.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with GetExplanationTaskResponse result

get_all_explaination_tasks(offset=None, limit=None, subscription_id=None, scoring_id=None, status=None, **kwargs)[source]

List all explanations.

List of all the computed explanations.

Parameters
  • offset (int) – (optional) offset of the explanations to return.

  • limit (int) – (optional) Maximum number of explanations to return.

  • subscription_id (str) – (optional) Unique subscription ID.

  • scoring_id (str) – (optional) ID of the scoring transaction.

  • status (str) – (optional) Status of the explanation task.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with GetExplanationTasksResponse result

get_measurement_details(monitor_instance_id: str, measurement_id: str, **kwargs)[source]

Get Measurement details. Get Measurement info for the given measurement and monitor instance id. :param str monitor_instance_id: ID of the monitor instance. :param str measurement_id: ID of the measurement. :param dict headers: A dict containing the request headers :return: A DetailedResponse containing the result, headers and HTTP status code. :rtype: DetailedResponse with MonitorMeasurementResponse result

APIClient.monitor_definitions

class MonitorDefinitions(ai_client: WatsonOpenScaleV2Adapter)[source]

Bases: ibm_watson_openscale.base_classes.watson_open_scale_v2.Monitors

Manages Monitor Definitions.

add(name: str, metrics: List[MonitorMetricRequest], tags: List[MonitorTagRequest], description: str = None, applies_to: ApplicabilitySelection = None, parameters_schema: object = None, managed_by: str = None, schedule: MonitorInstanceSchedule = None, background_mode: bool = True)Optional[Union[DetailedResponse, dict]][source]

Add custom monitor.

Parameters
  • name (str) – Monitor UI label (must be unique).

  • metrics (List[MonitorMetricRequest]) – A list of metric definition.

  • tags (List[MonitorTagRequest]) – Available tags.

  • description (str) – (optional) Long monitoring description presented in monitoring catalog.

  • applies_to (ApplicabilitySelection) – (optional)

  • parameters_schema (object) – (optional) JSON schema that will be used to validate monitoring parameters when enabled.

  • managed_by (str) – (optional)

  • schedule (MonitorInstanceSchedule) – (optional) The schedule used to control how frequently the target is monitored. The maximum frequency is once every 30 minutes. Defaults to once every hour if not specified.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorDisplayForm result

A way you may use me:

>>>  from ibm_watson_openscale import *
>>>  metrics = [
       MonitorMetricRequest(
           name='sensitivity',
           thresholds=[MetricThreshold(
               type=MetricThresholdTypes.LOWER_LIMIT,
               default=0.8
           )]
       ),
       MonitorMetricRequest(
           name='specificity',
           thresholds=[MetricThreshold(
               type=MetricThresholdTypes.LOWER_LIMIT,
               default=0.75
           )]
       ),
    ]
>>>  tags = [
       MonitorTagRequest(
           name='region',
           description='customer geographical region'
       )
    ]
>>>  my_monitor = client.monitor_definitions.add(
           name='my model performance',
           metrics=metrics,
           tags=tags,
           background_mode=False)
delete(monitor_definition_id: str, background_mode: bool = True)Optional[Union[DetailedResponse, dict]][source]

Delete custom monitor.

Parameters
  • monitor_definition_id (str) – Unique monitor definition ID.

  • background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

A way you may use me:

>>>  client.monitor_definitions.delete(monitor_definition_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
update(monitor_definition_id: str, name: str, metrics: List[MonitorMetricRequest], tags: List[MonitorTagRequest], description: str = None, applies_to: ApplicabilitySelection = None, parameters_schema: object = None, managed_by: str = None, schedule: MonitorInstanceSchedule = None)DetailedResponse[source]

Edit custom monitor.

Update monitor.

Parameters
  • monitor_definition_id (str) – Unique monitor definition ID.

  • name (str) – Monitor UI label (must be unique).

  • metrics (List[MonitorMetricRequest]) – A list of metric definition.

  • tags (List[MonitorTagRequest]) – Available tags.

  • description (str) – (optional) Long monitoring description presented in monitoring catalog.

  • applies_to (ApplicabilitySelection) – (optional)

  • parameters_schema (object) – (optional) JSON schema that will be used to validate monitoring parameters when enabled.

  • managed_by (str) – (optional)

  • schedule (MonitorInstanceSchedule) – (optional) The schedule used to control how frequently the target is monitored. The maximum frequency is once every 30 minutes. Defaults to once every hour if not specified.

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorDisplayForm result

A way you may use me:

>>>  from ibm_watson_openscale import *
>>>  metrics = [
       MonitorMetricRequest(
           name='sensitivity',
           thresholds=[MetricThreshold(
               type=MetricThresholdTypes.LOWER_LIMIT,
               default=0.7
           )]
       ),
       MonitorMetricRequest(
           name='specificity',
           thresholds=[MetricThreshold(
               type=MetricThresholdTypes.LOWER_LIMIT,
               default=0.6
           )]
       ),
    ]
>>>  tags = [
       MonitorTagRequest(
           name='region',
           description='customer geographical region'.upper()
       )
    ]
>>>  my_monitor = client.monitor_definitions.update(
       monitor_definition_id='monitor_definition_id',
       name='my model performance',
       metrics=metrics,
       tags=tags)
show(limit: int = 10)None[source]

Show monitor definitions. By default 10 records will be shown.

Parameters

limit (int) – maximal number of fetched rows. By default set to 10. (optional)

A way you might use me is:

>>>  client.monitor_definitions.show()
>>>  client.monitor_definitions.show(limit=20)
>>>  client.monitor_definitions.show(limit=None)
get(monitor_definition_id: str, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse

Get a specific monitor definition.

Get a specific monitor definition.

Parameters
  • monitor_definition_id (str) – Unique monitor definition ID.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorDisplayForm result

list(*, name: Optional[str] = None, **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse

List available monitors.

List available monitors.

Parameters
  • name (str) – (optional) comma-separeted list of names.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorCollections result

patch(monitor_definition_id: str, json_patch_operation: List[ibm_watson_openscale.base_classes.watson_open_scale_v2.JsonPatchOperation], **kwargs)ibm_cloud_sdk_core.detailed_response.DetailedResponse

Update a monitor definition.

Update a monitor definition.

Parameters
  • monitor_definition_id (str) – Unique monitor definition ID.

  • json_patch_operation (List[JsonPatchOperation]) –

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse with MonitorDisplayForm result

Helper Classes

MetricThreshold

class MetricThreshold(type: str, *, default: Optional[float] = None, default_recommendation: Optional[str] = None, specific_values: Optional[List[ibm_watson_openscale.base_classes.watson_open_scale_v2.MetricSpecificThresholdObject]] = None)[source]

MetricThreshold.

Attr str type

Attr float default

(optional) default value of threshold.

Attr str default_recommendation

(optional)

Attr List[MetricSpecificThresholdObject] specific_values

(optional)

Target

class Target(target_type: str, target_id: str)[source]

Target.

Attr str target_type

Type of the target (e.g. subscription, business application, …).

Attr str target_id

ID of the data set target (e.g. subscription ID, business application ID, …).

DatabaseConfiguration

class DatabaseConfiguration(database_type: str, credentials: ibm_watson_openscale.base_classes.watson_open_scale_v2.SecretCleaned, *, instance_id: Optional[str] = None, name: Optional[str] = None, location: Optional[ibm_watson_openscale.base_classes.watson_open_scale_v2.LocationSchemaName] = None)[source]

Database configuration ignored if internal database is requested (internal_database is true).

Attr str database_type

Attr str instance_id

(optional)

Attr str name

(optional)

Attr SecretCleaned credentials

Attr LocationSchemaName location

(optional)

class DatabaseTypeEnum(value)[source]

database_type.

POSTGRESQL = 'postgresql'
DB2 = 'db2'

AzureCredentials

class AzureCredentials(*, token: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, subscription_id: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, tenant: Optional[str] = None, workspaces: Optional[List[ibm_watson_openscale.base_classes.watson_open_scale_v2.AzureWorkspaceCredentials]] = None, **kwargs)[source]

AzureCredentials.

Attr str token

(optional)

Attr str username

(optional)

Attr str password

(optional)

Attr str subscription_id

(optional)

Attr str client_id

(optional)

Attr str client_secret

(optional)

Attr str tenant

(optional)

Attr List[AzureWorkspaceCredentials] workspaces

(optional)

CustomCredentials

class CustomCredentials(*, url: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, **kwargs)[source]

CustomCredentials.

Attr str url

(optional)

Attr str username

(optional)

Attr str password

(optional)

SageMakerCredentials

class SageMakerCredentials(access_key_id: str, secret_access_key: str, *, region: Optional[str] = None, **kwargs)[source]

SageMakerCredentials.

Attr str access_key_id

Attr str secret_access_key

Attr str region

(optional)

SPSSCredentials

class SPSSCredentials(url: str, username: str, password: str, **kwargs)[source]

SPSSCredentials.

Attr str url

Attr str username

Attr str password

WMLCredentialsCP4D

class WMLCredentialsCP4D(*, url: Optional[str] = None, apikey: Optional[str] = None, username: Optional[str] = None, uid: Optional[str] = None, wml_location: Optional[str] = None, **kwargs)[source]

WMLCredentials format for OpenScale on Cloud Pak for Data.

Attr str url

(optional) Required if wml_location is cpd_remote or cloud_remote.

Attr str apikey

(optional) Required if wml_location is cpd_remote or cloud_remote.

Attr str username

(optional) Required if wml_location is cpd_remote.

Attr str uid

(optional) User ID of a user in the Cloud Pak for Data. If not set, the uid extracted from the access token in Authorization header is used. This parameter is only applicable if wml_location is cpd_local.

Attr str wml_location

(optional) If wml_location is not selected, we treat the service provider as cpd_local for backward compatibility.

class WmlLocationEnum(value)[source]

If wml_location is not selected, we treat the service provider as cpd_local for backward compatibility.

CPD_LOCAL = 'cpd_local'
CPD_REMOTE = 'cpd_remote'
CLOUD_REMOTE = 'cloud_remote'

WMLCredentialsCloud

class WMLCredentialsCloud(url: str, instance_id: str, *, apikey: Optional[str] = None, token: Optional[str] = None, **kwargs)[source]

WMLCredentialsCloud.

Attr str apikey

(optional)

Attr str token

(optional)

Attr str url

Attr str instance_id

Asset

class Asset(asset_id: str, url: str, asset_type: str, *, name: Optional[str] = None, asset_rn: Optional[str] = None, created_at: Optional[str] = None, problem_type: Optional[str] = None, model_type: Optional[str] = None, runtime_environment: Optional[str] = None, input_data_type: Optional[str] = None)[source]

Asset.

Attr str asset_id

Attr str url

Attr str name

(optional)

Attr str asset_type

Attr str asset_rn

(optional) Asset Resource Name (used for integration with 3rd party ML engines).

Attr str created_at

(optional)

Attr str problem_type

(optional)

Attr str model_type

(optional)

Attr str runtime_environment

(optional)

Attr str input_data_type

(optional)

AssetDeploymentRequest

class AssetDeploymentRequest(deployment_id: str, name: str, deployment_type: str, *, deployment_rn: Optional[str] = None, url: Optional[str] = None, description: Optional[str] = None, created_at: Optional[str] = None, scoring_endpoint: Optional[ibm_watson_openscale.base_classes.watson_open_scale_v2.ScoringEndpointRequest] = None)[source]

AssetDeploymentRequest.

Attr str deployment_id

Attr str deployment_rn

(optional) Deployment Resource Name (used for integration with 3rd party ML engines).

Attr str url

(optional)

Attr str name

Attr str description

(optional)

Attr str deployment_type

Deployment type, e.g. online, batch.

Attr str created_at

(optional)

Attr ScoringEndpointRequest scoring_endpoint

(optional) Definition of scoring endpoint in custom_machine_learning.

AssetPropertiesRequest

class AssetPropertiesRequest(*, training_data_reference: Optional[ibm_watson_openscale.base_classes.watson_open_scale_v2.TrainingDataReference] = None, training_data_schema: Optional[ibm_watson_openscale.base_classes.watson_open_scale_v2.SparkStruct] = None, input_data_schema: Optional[ibm_watson_openscale.base_classes.watson_open_scale_v2.SparkStruct] = None, output_data_schema: Optional[ibm_watson_openscale.base_classes.watson_open_scale_v2.SparkStruct] = None, label_column: Optional[str] = None, labels: Optional[List[str]] = None, predicted_target_field: Optional[str] = None, prediction_field: Optional[str] = None, transaction_id_field: Optional[str] = None, dashboard_configuration: Optional[dict] = None, feature_fields: Optional[List[str]] = None, categorical_fields: Optional[List[str]] = None, probability_fields: Optional[List[str]] = None)[source]

Additional asset properties (subject of discovery if not provided when creating the subscription).

Attr TrainingDataReference training_data_reference

(optional)

Attr SparkStruct training_data_schema

(optional)

Attr SparkStruct input_data_schema

(optional)

Attr SparkStruct output_data_schema

(optional)

Attr str label_column

(optional)

Attr List[str] labels

(optional)

Attr str predicted_target_field

(optional) Field with this name will be given modeling_role decoded-target.

Attr str prediction_field

(optional) Field with this name will be given modeling_role prediction.

Attr str transaction_id_field

(optional) Field with this name will have transaction_id_key metadata set to true.

Attr dict dashboard_configuration

(optional)

Attr List[str] feature_fields

(optional) Fields to be given modeling_role feature.

Attr List[str] categorical_fields

(optional) Fields to be given metadata measure of value discrete.

Attr List[str] probability_fields

(optional) Fields to be given modeling_role class_probability (for columns of double data type) or probability (for column of array data type).

PayloadRecord

class PayloadRecord(request: dict, response: Union[dict, str], scoring_id: Optional[str] = None, scoring_timestamp: Optional[str] = None, response_time: Optional[int] = None, asset_revision: Optional[str] = None, multiple_records: bool = True)[source]

Used during payload logging, describes payload record.

Parameters
  • request (dict) – scoring request

  • response (int) – scoring response

  • scoring_id (str) – scoring identifier (optional). If not provided random uid is assigned.

  • scoring_timestamp (str) – scoring request timestamp (optional). If not provided current time is assigned.

  • response_time – scoring response time in ms (optional)

PrimaryStorageCredentialsLong

class PrimaryStorageCredentialsLong(hostname: str, username: str, password: str, db: str, *, port: Optional[int] = None, ssl: Optional[bool] = None, sslmode: Optional[str] = None, certificate_base64: Optional[str] = None, additional_properties: Optional[dict] = None)[source]

PrimaryStorageCredentialsLong.

Attr str hostname

Attr str username

Attr str password

Attr str db

Attr int port

(optional)

Attr bool ssl

(optional)

Attr str sslmode

(optional) (postgresql only).

Attr str certificate_base64

(optional) DER-encoded certificate in Base64 encoding. The decoded content must be bound at the beginning by —–BEGIN CERTIFICATE—– and at the end by —–END CERTIFICATE—–.

Attr dict additional_properties

(optional) any additional properties to be included in connection url.

JsonPatchOperation

class JsonPatchOperation(op: str, path: str, *, from_: Optional[str] = None, value: Optional[object] = None)[source]

This model represents an individual patch operation to be performed on a JSON document, as defined by RFC 6902.

Attr str op

The operation to be performed.

Attr str path

The JSON Pointer that identifies the field that is the target of the operation.

Attr str fromfrom_

(optional) The JSON Pointer that identifies the field that is the source of the operation.

Attr object value

(optional) The value to be used within the operation.

Enums

class InputDataType[source]

Bases: object

Describes possible model input data types.

Contains: [STRUCTURED, UNSTRUCTURED_IMAGE, UNSTRUCTURED_TEXT, UNSTRUCTURED_AUDIO, UNSTRUCTURED_VIDEO]

STRUCTURED = 'structured'
UNSTRUCTURED_IMAGE = 'unstructured_image'
UNSTRUCTURED_TEXT = 'unstructured_text'
UNSTRUCTURED_AUDIO = 'unstructured_audio'
UNSTRUCTURED_VIDEO = 'unstructured_video'
class DeploymentTypes[source]

Bases: object

Describes possible model deployment types.

Contains: [ONLINE]

ONLINE = 'online'
class RecordsFormatTypes[source]

Bases: object

Describes possible format types for getting list of records.

Contains: [DICT, LIST]

DICT = 'dict'
LIST = 'list'
class FeedbackType(value)[source]

Bases: enum.Enum

Describes supported types of feedback format.

Contains: [WML, DICT, CSV]

WML = 'WML'
DICT = 'DICT'
CSV = 'CSV'
PAYLOAD = 'PAYLOAD'
LIST_OF_DICT = 'LIST_OF_DICT'
classmethod has_value(value)[source]
class ServiceTypes[source]

Bases: object

Describes supported types of service.

Contains: [WATSON_MACHINE_LEARNING, AMAZON_SAGEMAKER,

AZURE_MACHINE_LEARNING, CUSTOM_MACHINE_LEARNING, SPSS_COLLABORATION_AND_DEPLOYMENT_SERVICES]

WATSON_MACHINE_LEARNING = 'watson_machine_learning'
AMAZON_SAGEMAKER = 'amazon_sagemaker'
AZURE_MACHINE_LEARNING = 'azure_machine_learning'
CUSTOM_MACHINE_LEARNING = 'custom_machine_learning'
SPSS_COLLABORATION_AND_DEPLOYMENT_SERVICES = 'spss_collaboration_and_deployment_services'
class ResponseTypes[source]

Bases: object

Describes supported types of output format.

Contains: [PANDAS, PYTHON]

PANDAS = 'pandas'
PYTHON = 'python'
class TargetTypes[source]

Bases: object

Describes supported types of target format.

Contains: [SUBSCRIPTION, BUSINESS_APPLICATION, INSTANCE, DATA_MART]

SUBSCRIPTION = 'subscription'
BUSINESS_APPLICATION = 'business_application'
INSTANCE = 'instance'
DATA_MART = 'data_mart'
class FormatTypes[source]

Bases: object

Format of the returned data. full format compared to compact is additive and contains sources part.

COMPACT = 'compact'
FULL = 'full'
class IntervalTypes[source]

Bases: object

Time unit in which metrics are grouped and aggregated, interval by interval.

MINUTE = 'minute'
HOUR = 'hour'
DAY = 'day'
WEEK = 'week'
MONTH = 'month'
YEAR = 'year'
class AggregationTypes[source]

Bases: object

Comma delimited function list constructed from metric name and function, e.g. agg=metric_name:count,:last that defines aggregations.

LAST = 'last'
FIRST = 'first'
MAX = 'max'
MIN = 'min'
SUM = 'sum'
AVG = 'avg'
COUNT = 'count'
STDDEV = 'stddev'
class OnErrorTypes[source]

Bases: object

expected behaviour on error.

STOP = 'stop'
CONTINUE = 'continue'
class ContentTypes[source]

Bases: object

The type of the input. A character encoding can be specified by including a charset parameter. For example, ‘text/csv;charset=utf-8’.

APPLICATION_JSON = 'application/json'
TEXT_CSV = 'text/csv'
class DataSetTypes[source]

Bases: object

type of the data set.

MANUAL_LABELING = 'manual_labeling'
PAYLOAD_LOGGING = 'payload_logging'
FEEDBACK = 'feedback'
BUSINESS_PAYLOAD = 'business_payload'
CUSTOM = 'custom'
class MetricThresholdTypes[source]

Bases: object

LOWER_LIMIT = 'lower_limit'
UPPER_LIMIT = 'upper_limit'
class StatusStateType[source]

Bases: object

ACTIVE = 'active'
RUNNING = 'running'
FINISHED = 'finished'
PREPARING = 'preparing'
SUCCESS = 'success'
COMPLETED = 'completed'
FAILURE = 'failure'
FAILED = 'failed'
ERROR = 'error'
CANCELLED = 'cancelled'
CANCELED = 'canceled'
class DatabaseType[source]

Bases: object

Describes possible options of choosing database type.

Contains: [POSTGRESQL, DB2]

POSTGRESQL = 'postgresql'
DB2 = 'db2'
class Choose[source]

Bases: object

Describes possible options of choosing result from table filtering when only one result is required.

Contains: [FIRST, LAST, RANDOM]

FIRST = 'first'
LAST = 'last'
RANDOM = 'random'
class ProblemType[source]

Bases: object

Describes possible model (problem) types.

Contains: [regression, binary, multiclass]

REGRESSION = 'regression'
BINARY_CLASSIFICATION = 'binary'
MULTICLASS_CLASSIFICATION = 'multiclass'
class AssetTypes[source]

Bases: object

MODEL = 'model'
FUNCTION = 'function'
class ExpectedDirectionTypes[source]

Bases: object

the indicator specifying the expected direction of the monotonic metric values.

INCREASING = 'increasing'
DECREASING = 'decreasing'
UNKNOWN = 'unknown'
class SchemaUpdateModeTypes[source]

Bases: object

NONE = 'none'
AUTO = 'auto'
class IntegratedSystemTypes[source]

Bases: object

OPEN_PAGES = 'open_pages'
WATSON_DATA_CATALOG = 'watson_data_catalog'
SLACK = 'slack'
class OperationTypes[source]

Bases: object

The operation to be performed.

ADD = 'add'
REMOVE = 'remove'
REPLACE = 'replace'
MOVE = 'move'
COPY = 'copy'
TEST = 'test'
class ScheduleRepeatTypes[source]

Bases: object

The type of interval to monitor the target.

MINUTE = 'minute'
HOUR = 'hour'
DAY = 'day'
WEEK = 'week'
MONTH = 'month'
YEAR = 'year'
class TriggerTypes[source]

Bases: object

An identifier representing the source that triggered the run request (optional). One of: event, scheduler, user, webhook.

EVENT = 'event'
SCHEDULER = 'scheduler'
USER = 'user'
WEBHOOK = 'webhook'
BKPI_MANAGER = 'bkpi_manager'
class NotificationServiceTypes[source]

Bases: object

The messaging service to use, for example, slack or email, or list_ref to indicate a previously created notification list.

SLACK = 'slack'
EMAIL = 'email'
LIST_REF = 'list_ref'
class MessageFormatTypes[source]

Bases: object

The format of the message text.

TEXT = 'text'
HTML = 'html'
class PayloadFieldTypes[source]

Bases: object

STRING = 'string'
NUMBER = 'number'
class TrainingDataReferenceType[source]

Bases: object

Type of the storage.

DB2 = 'db2'
COS = 'cos'
class CP4DWMLLocation[source]

Bases: object

CP4D WML Location.

CPD_LOCAL = 'cpd_local'
CPD_REMOTE = 'cpd_remote'
CLOUD_REMOTE = 'cloud_remote'

Sample Monitor Instance Payloads

Quality

    target = Target(
                target_type=TargetTypes.SUBSCRIPTION,
                target_id=<SUBSCRIPTION_ID>
            )
    parameters =  {
                "min_feedback_data_size": 200
            }
        thresholds =  [{
                "metric_id": "area_under_roc",
                "type": "lower_limit",
                "value": 0.75
            }]
    ai_client.monitor_instances.create(
    data_mart_id=<DATAMART_ID>,
    background_mode=False,
    monitor_definition_id=ai_client.monitor_definitions.MONITORS.QUALITY.ID,
    target=target,
    parameters=parameters,
    thresholds=thresholds
)

Drift

    target = Target(
    target_type=TargetTypes.SUBSCRIPTION,
    target_id=<SUBSCRIPTION_ID>
    )
    parameters = {
        "min_samples": 1000,
        "drift_threshold": 0.1,
        "train_drift_model": True,
        "enable_data_drift": True,
        "enable_model_drift": True,
        "model_name": "<archive_name_to_be_used>"
}
ai_client.monitor_instances.create(
    data_mart_id=<DATAMART_ID>,
    background_mode=False,
    monitor_definition_id=ai_client.monitor_definitions.MONITORS.DRIFT.ID,
    target=target,
    parameters=parameters,
    thresholds=thresholds
)

Explanation

target = Target(
    target_type=TargetTypes.SUBSCRIPTION,
    target_id=<SUBSCRIPTION_ID>
    )
parameters = {
    "enabled":True
}
ai_client.monitor_instances.create(
    data_mart_id=<DATAMART_ID>,
    background_mode=False,
    monitor_definition_id=ai_client.monitor_definitions.MONITORS.EXPLAINABILITY.ID,
    target=target,
    parameters=parameters
)

Fairness

    parameters =  {
    "class_label": "predictedLabel",
    "favourable_class": [
        "No Risk"
    ],
    "features": [{
        "feature": "Age",
        "majority": [
            [
                19,
                43
            ]
        ],
        "minority": [
            [
                44,
                67
            ]
        ]
    }],
    "unfavourable_class": [
        "Risk"
    ],
    "min_records": 100
}

thresholds =  [{
    "metric_id": "fairness_value",
    "specific_values": [{
        "applies_to": [{
            "key": "feature",
            "type": "tag",
            "value": "Age"
        }],
        "value": 90.0
    }],
    "type": "lower_limit",
    "value": 90.0
}]

target = Target(
    target_type=TargetTypes.SUBSCRIPTION,
    target_id=<SUBSCRIPTION_ID>
    )
ai_client.monitor_instances.create(
    data_mart_id=<DATAMART_ID>,
    background_mode=False,
    monitor_definition_id=ai_client.monitor_definitions.MONITORS.FAIRNESS.ID,
    target=target,
    parameters=parameters,
    thresholds=thresholds )