TDPredictor.predict Method |teradataml AWS Extension Library | API Integration - TDPredictor.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 TDPredictor.predict method to perform prediction using teradataml DataFrame and SageMaker 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 SageMaker endpoint present in the predictor. Default value is 'csv'.
    • key_start_index: Specifies the index in DataFrame columns to be the key for scoring starts. Default value is 0.

Example

from tdapiclient import create_tdapi_context, TDApiClient
from teradataml import DataFrame
context = create_tdapi_context("aws", "s3_bucket")
tdapiclient = TDApiClient(context)
# SKlearn takes all parameters that AWS SageMaker Library requires
skLearnObject = tdapiclient.SKLearn()
df = DataFrame(tableName='t')
skLearnObject.fit(df)
predictor = skLearnObject.deploy(sagemaker_kw_args={"instance_type": "ml.m5.large", "initial_instance_count": 1})
df = DataFrame(tableName='inputTable')
outputDF = predictor.predict(df, mode='UDF', content_type='csv')