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.
- 'UDF': Score in database using a Teradata UDF. This is the default value.
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')