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

Teradata® Python Package User Guide

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-29
dita:mapPath
rkb1531260709148.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

Teradata Python Package 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 Python Package 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.