Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Teradata ML Extensions

Extensions to the core teradataml library by Teradata Consulting to aid in field development work around BYOM, STO, RTO and AnalyticOps solutions.

Installation

You can install via pip.

pip install tdextension

Usage

You must use the same version of python on your client side as is used in Teradata (3.6+ at the time of writing). The reason for this is due to differences in serialization between versions of python (e.g. between 3.5 and 3.6).

from teradataml.dataframe.dataframe import DataFrame
from tdextensions.distributed import DistDataFrame, DistMode
from teradataml import create_context
import pandas as pd
import numpy as np

pd.options.display.max_colwidth = 250

engine = create_context(host="localhost", username="ivsm_user", password="ivsm_user")

A simple map row example where we multiple the value of two columns on a row by row basis

def my_fun(row):
    return np.array([row.idx, row.sepal_length * row.sepal_width])

df = DistDataFrame("iris_train", dist_mode=DistMode.STO, sto_id="my_dumb_map")
df = df.map(lambda row: my_fun(row), 
            returns=[["idx", "INTEGER"], ["my_derived_col", "INTEGER"]])

df.head()

A more advanced example where we train a different model for each partition of a dataset

from sklearn.ensemble import RandomForestClassifier
import base64
import dill

def train(partition):
    X = partition[['sepal_length', 'sepal_width', 'petal_length', 'petal_width']]
    y = partition[['species']]

    clf = RandomForestClassifier()
    clf.fit(X, y.values.ravel())

    return np.array([[partition.species.iloc[0], "my_model_id", base64.b64encode(dill.dumps(clf))]])

df = DistDataFrame("iris_train", dist_mode=DistMode.STO, sto_id="my_model_train")
df = df.map_partition(lambda partition: train(partition), 
                      partition_by="species", 
                      returns=[["partition_id", "VARCHAR(255)"], 
                               ["model_id", "VARCHAR(255)"],
                               ["model_artefact", "CLOB"]])
df.to_pandas().head()

Permissions

SET SESSION SEARCHUIFDBPATH = <database>;
GRANT EXECUTE procedure on <db> to <user>;
GRANT EXECUTE procedure on SYSUIF to <user>;
GRANT CREATE external procedure on <db> to <user>;
GRANT EXECUTE FUNCTION ON TD_SYSFNLIB.SCRIPT to <user>;
GRANT EXECUTE ON  SYSUIF.DEFAULT_AUTH TO <user>;

Metadata

Release files for tdextensions 1.0.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tdextensions 1.0.0rc1
File Size Uploaded
tdextensions-1.0.0rc1.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tdextensions 1.0.0rc1
File Interpreter ABI Platform
tdextensions-1.0.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / tdextensions-1.0.0rc1.tar.gz

Download URL tdextensions-1.0.0rc1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a0f1143501f491522a587f11e86880e9fa6219cac5c58bfa37d3bedf1daffd7e
BLAKE2b-256 checksum
How to use checksums
a7a836c9fc4532ca1c29e9f0d25f73f7b5d8fa3b7715d2864eee4093b8044515
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.12

Release files / tdextensions-1.0.0rc1-py3-none-any.whl

Download URL tdextensions-1.0.0rc1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff541707fc959de7920ef550152449b6d3fba99b9848b2403756676ab612301d
BLAKE2b-256 checksum
How to use checksums
e5bc373457bbbd9f3756e2d1aef8c3a9dc754df34bd33f2ce9b224e3dadac18f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.12

Release history Release notifications | RSS feed

This release

1.0.0rc1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page