TDAzurePredictor.predict |teradataml Azure Extension Library | API Integration - TDAzurePredictor.predict Method - Teradata Vantage

Teradata Vantageā„¢ - API Integration Guide for Cloud Machine Learning

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
1.4
Published
September 2023
Language
English (United States)
Last Update
2023-09-28
dita:mapPath
mgu1643999543506.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
mgu1643999543506

Use the TDAzurePredictor.predict method to perform prediction using teradataml DataFrame and Azure Machine Learning endpoint represented by this predictor object.

Required Arguments:
  • input: Specifies the teradataml DataFrame used as input for scoring.
  • mode: Specifies the mode for scoring.
    Permitted values include:
    • 'UDF': Score in database using a Teradata UDF. This is the default value.

      For this mode, the return is a teradataml DataFrame.

      This mode provides faster scoring with the data from Teradata.

    • 'CLIENT': Score at client side using a library.

      For this mode, the return is an array or JSON.

      When using mode, data is pulled from Teradata and serialized for scoring at client.

Optional Argument:
  • options: Specifies the predict method with the following key-value arguments:
    • udf_name: Specifies the name of the UDF used to invoke predict with UDF mode. Default value is 'tapidb.API_Request'.
    • content_type: Specifies content type required for Azure Machine Learning endpoint present in the predictor. Default value is 'json'.
    • key_start_index: Specifies the index in DataFrame columns to be the key for scoring starts. Default value is 0.
    • content_format: Specifies the content format required for Azure Machine Learning endpoint present in the predictor.

Example

  • Import necessary packages.
    from tdapiclient import create_tdapi_context, TDApiClient
  • Create the TDAPI context.
    context = create_tdapi_context("azure", "/td-tables")
  • Create TDApiClient object.
    tdapiclient = TDApiClient(context)
  • Create a SKLearn model.

    ScriptRunConfig takes all the parameters as required by Azure Machine Learning ScriptRunConfig.

    skLearnObject = tdapiclient.ScriptRunConfig()
  • Create teradataml DataFrame for training.
    train = DataFrame(tableName='train_data')
  • Train the model in Azure Machine Learning.
    skLearnObject.fit(mount=True)
  • Deploy model to Vantage.
    predictor = skLearnObject.deploy(model, model_type='pmml', platform='az-webservice')
  • Create teradataml DataFrame for scoring.
    df = DataFrame(tableName='inputTable')
  • Perform scoring.
    output = predictor.predict(df, mode='udf', content_type='json')