Teradata Python Package Function Reference - Correlation - Teradata Python Package - Look here for syntax, methods and examples for the functions included in the Teradata Python Package.

Teradata® Python Package Function Reference

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-07-17
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.mle.Correlation = class Correlation(builtins.object)
     Methods defined here:
__init__(self, data=None, group_by_columns=None, target_columns=None, key_name=None, data_sequence_column=None, data_partition_column='ANY', data_order_column=None, reduce_partition_column=None)
DESCRIPTION:
    The Correlation function, which is composed of the Correlation Reduce and
    Correlation Map functions, computes global correlations between specified
    pairs of teradataml DataFrame columns. Measuring correlation lets you
    determine if the value of one variable is useful in predicting the
    value of another.
 
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the input teradataml DataFrame that contains the Xi and Yi pairs.
 
    data_partition_column:
        Optional Argument.
        Specifies Partition By columns for data.
        Values to this argument can be provided as list, if multiple columns
        are used for partition.
        Default Value: ANY
        Types: str OR list of Strings (str)
 
    reduce_partition_column:
        Required Argument.
        Specifies Partition By columns for data for Correlation Reduce.
        Values to this argument can be provided as list, if multiple columns
        are used for partition. If group_by_columns argument is provided,
        value must be [key_name, group_by_columns]. If group_by_columns
        is not provided, value must be key_name argument value.
        Types: str OR list of Strings (str)
 
    data_order_column:
        Optional Argument.
        Specifies Order By columns for data.
        Values to this argument can be provided as list, if multiple columns
        are used for ordering.
        Types: str OR list of Strings (str)
 
    group_by_columns:
        Optional Argument.
        Specifies the names of the input columns that define the group for
        correlation calculation. By default, all input columns belong to a
        single group, for which the function calculates correlation. If group_by_columns
        is specified, columns provided to this argument should also appear in
        'data_partition_column' and 'reduce_partition_column'.
        Types: str OR list of Strings (str)
 
    target_columns:
        Required Argument.
        Specifies pairs of columns for which to calculate correlations. For
        each column pair, "col_name1:col_name2", the function calculates the
        correlation between col_name1 and col_name2. For each column range,
        "[col_index1:col_index2]", the function calculates the correlation
        between every pair of columns in the range. For example, if you
        specify "[1:3]", the function calculates the correlation between the
        pairs (1,2), (1,3), (2,3), (1,1), (2,2) and (3,3). The minimum value of
        col_index1 is 0, and col_index1 must be less than col_index2.
        Types: str OR list of strs
 
    key_name:
        Required Argument.
        Specifies the name for the Correlation output teradataml DataFrame
        column that contains the correlations, and by which the Correlation
        output teradataml DataFrame is partitioned.
        Types: str
 
    data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "data". The argument is used to ensure
        deterministic results for functions which produce results that vary
        from run to run.
        Types: str OR list of Strings (str)
 
RETURNS:
    Instance of Correlation.
    Output teradataml DataFrames can be accessed using attribute
    references, such as CorrelationObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
 
    # Load the data to run the example.
    load_example_data("correlation","corr_input")
 
    # Create teradataml DataFrame
    corr_input = DataFrame.from_table("corr_input")
 
    # Example 1: Include PARTITION BY Clause and input columns that
    # define the group for correlation calculation
    correlation_output1 = Correlation(data=corr_input,
                            data_partition_column='state',
                            group_by_columns='state',
                            key_name='test',
                            target_columns='[2:3]',
                            data_sequence_column='state',
                            reduce_partition_column=['test', 'state']
                            )
 
    # Print the result DataFrame
    print(correlation_output1.result)
 
    # Example 2: Specifying all input columns for correlation calculation.
    # By default, if group_by_columns is not mentioned all input columns belong to a single group,
    # for which the function calculates correlation
    correlation_output2 = Correlation(data=corr_input,
                            key_name='test',
                            target_columns='[2:3]',
                            data_sequence_column='state',
                            reduce_partition_column=['test']
                            )
    # Print the result DataFrame
    print(correlation_output2.result)
__repr__(self)
Returns the string representation for a Correlation class instance.