TD_SimpleImputeFit

Missing data can have a significant impact on analytics and machine learning outcomes. TD_SimpleImputeFit helps address this by calculating appropriate replacement values, such as a mean, median, or fixed value, and storing them for use by TD_SimpleImputeTransform.

For Teradata customers, data preparation can be performed directly within the platform, avoiding the need to move data to external tools. This simplifies data pipelines, reduces data movement, and allows large datasets to be processed using Teradata's parallel architecture.

Whether supporting reporting, analytics, or AI workloads, TD_SimpleImputeFit provides a simple and repeatable way to improve data quality before further analysis.

TD_SimpleImputeFit (
    ON { table | view | (query) } AS InputTable
    [ OUT [ PERMANENT | VOLATILE ] TABLE OutputTable (output_table) ]
    USING
    {
        { literal_specification | stats_specification }
        | literal_specification
        | stats_specification
    }
)

TD_SimpleImputeFit Syntax • Database Engine 20 In-Database Analytic Functions • Reader • Teradata Documentation

1. Create Sample Data

The first step creates a sample banking customer dataset containing missing values. These gaps in the data will be used to demonstrate how Teradata can calculate and apply replacement values using the imputation functions.

CREATE TABLE simpleimputefit_input (
    customer_id INTEGER,
    account_type VARCHAR(12) CHARACTER SET UNICODE,
    credit_score INTEGER,
    annual_income DECIMAL(10,2),
    defaulted INTEGER
);

INSERT INTO simpleimputefit_input
VALUES (3, NULL, NULL, NULL, 1);

SELECT *
FROM simpleimputefit_input
ORDER BY customer_id;

2. Generate Replacement Values

The TD_SimpleImputeFit function analyses the source data and determines which values should be used to replace missing data. In this example, missing account types are replaced with the literal value 'checking', while missing credit scores and annual incomes are replaced using the mean and median respectively. The generated values are stored in a fit table ready for the transform step.

CREATE TABLE fit_table AS (
    SELECT *
    FROM TD_SimpleImputeFit (
        ON simpleimputefit_input AS InputTable
        USING
        ColsForLiterals ('account_type')
        Literals ('checking')
        ColsForStats (
            'credit_score',
            'annual_income'
        )
        Stats (
            'mean',
            'median'
        )
    ) AS dt
) WITH DATA;

SELECT *
FROM fit_table
ORDER BY TD_INDEX_SIMFIT;

3. Apply Replacement Values

Once the fit table has been created, TD_SimpleImputeTransform applies the calculated replacement values to the source dataset. Because no partition column was specified during the fit operation, the transform uses PARTITION BY ANY and references the fit table as a dimension table.

SELECT *
FROM TD_SimpleImputeTransform (
    ON simpleimputefit_input
        AS InputTable
        PARTITION BY ANY
    ON fit_table
        AS FitTable
        DIMENSION
) AS dt
ORDER BY customer_id;
Previous
Previous

TD_SimpleImputeTransform

Next
Next

TD_OutlierFilterTransform