Using Teradata Vantage Analytic Functions with Teradata Package for Python - Using Teradata Vantage Analytic Functions with Teradata Package for Python - Teradata Package for Python

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2022-01-14
dita:mapPath
bol1585763678431.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

Teradata Package for Python provides a Python interface to all of the analytic functions in Vantage: ML Engine analytic functions and Advanced SQL Engine in-database analytic functions.

The teradataml analytics package includes two subpackages:
  • teradataml.analytics.mle
  • teradataml.analytics.sqle
All teradataml analytic functions are in either of these two subpackages.
Teradata recommends importing the desired analytic function in one of the following two ways:
  • For best practice, import from the teradataml package.
    For example:
    # import DecisionTreePredict from the teradataml package (recommended)
    from teradataml import DecisionTreePredict
  • To choose the engine where the analytic function is used, import from the desired subpackage.
    For example:
    # import DecisionTreePredict from the teradataml.analytics.sqle package
    from teradataml.analytics.sqle import DecisionTreePredict

Older versions of teradataml placed all analytic functions in a single package (teradataml.analytics), with each analytic function in it’s own module.

From release 16.20.00.01, the analytic functions are in either of the two subpackages above, with each analytic function in it’s own module.

Instead of using the old modules in the teradataml.analytics package, Teradata recommends importing the desired analytic function in one of the ways listed above.

Instantiating an analytic function from the old module in the teradataml.analytics package gives a DeprecationWarning.

For example:
>>> from teradataml.analytics.KMeans import KMeans
>>> KMeans(*args, **kw)
 
DeprecationWarning:
The "teradataml.analytics.KMeans.KMeans" class has moved to a new package in version 16.20.00.02.
Import from the teradataml package, teradataml.analytics package, or directly from the teradataml.analytics.mle.KMeans module.
See the teradataml 16.20.00.02 User Guide for more information.

This section shows examples of how the Teradata Package for Python enables users to run a selection of these analytic functions through a Python interface.

In this section, assume you have the connection to the Advanced SQL Engine as user "tdapUser", where the target database is "tdapUserDB".

See Testing Connection to Vantage for details on how to set up a connection and import the teradataml module.