Teradata Python Package Function Reference - CCM - 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.CCM = class CCM(builtins.object)
     Methods defined here:
__init__(self, data=None, sequence_id_column=None, time_column=None, cause_columns=None, effect_columns=None, library_size=[100], embedding_dimension=[2], time_step=1, bootstrap_iterations=100, predict_step=1, self_predict=False, seed=None, point_select_rule='DistanceOnly', mode='Single', data_sequence_column=None)
DESCRIPTION:
    The CCM function takes two or more time series as input and evaluates
    potential cause-effect relationships between them. Each time series
    column can be a single, long time series or a set of shorter
    subsequences that represent the same process. The function returns an
    effect size for each cause-effect pair.
 
 
PARAMETERS:
    data:
        Required Argument.
        teradataml DataFrame containing the input data.
 
    sequence_id_column:
        Required Argument.
        Specifies column containing the sequence ids. A sequence is a sample of the
        time series.
        Types: str OR list of Strings (str)
 
    time_column:
        Required Argument.
        Specifies column containing the timestamps.
        Types: str OR list of Strings (str)
 
    cause_columns:
        Required Argument.
        Specifies column to be evaluated as potential causes.
        Types: str OR list of Strings (str)
 
    effect_columns:
        Required Argument.
        Specifies column to be evaluated as potential effects.
        Types: str OR list of Strings (str)
 
    library_size:
        Optional Argument.
        The CCM algorithm works by using "libraries" of randomly selected
        points along the potential effect time series to predict values of
        the cause time series. A causal relationship is said to exist if the
        correlation between the predicted values of the cause time series and
        the actual values increases as the size of the library increases.
        Each input value must be greater than 0.
        Default Value: [100]
        Types: int
 
    embedding_dimension:
        Optional Argument.
        The embedding dimension is an estimate of the number of past values
        to use when predicting a given value of the time series. The input
        value must be greater than 0.
        Default Value: [2]
        Types: int
 
    time_step:
        Optional Argument.
        The time_step parameter indicates the number of time steps between
        past values to use when predicting a given value of the time series.
        The input value must be greater than 0.
        Default Value: 1
        Types: int
 
    bootstrap_iterations:
        Optional Argument.
        The number of bootstrap iterations used to predict. The bootstrap
        process is used to estimate the uncertainty associated with the
        predicted values. The input value must be greater than 0.
        Default Value: 100
        Types: int
 
    predict_step:
        Optional Argument.
        If the best embedding dimension is needed to choose, the predict
        step is used for specify the number of time steps into the
        future to make predictions from past observations.
        Default Value: 1
        Types: int
 
    self_predict:
        Optional Argument.
        If self_predict is set to true, the CCM function will attempt to
        predict each attribute using the attribute itself. If an attribute
        can predict its own time series well, the signal-to-noise ratio is
        too low for the CCM algorithm to work effectively.
        Default Value: False
        Types: bool
 
    seed:
        Optional Argument.
        Specifies the random seed used to initialize the algorithm.
        Types: int
 
    point_select_rule:
        Optional Argument.
        The rules to select nearest points if the best embedding dimension
        is needed to choose. Two options are provided. One is
        DistanceAndTime. The other one is DistanceOnly.
        Default Value: "DistanceOnly"
        Permitted Values: DistanceAndTime, DistanceOnly
        Types: str
 
    mode:
        Optional Argument.
        Specifies the execution mode. CCM can be executed in single mode and
        distribute node.
        Default Value: "Single"
        Permitted Values: Single, Distribute
        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 CCM.
    Output teradataml DataFrames can be accessed using attribute
    references, such as CCMObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load example data.
    load_example_data("CCM", ["ccmexample", "ccm_input", "ccm_input2", "ccmprepare_input"])
 
    # Create teradataml DataFrame objects.
    ccmexample = DataFrame.from_table("ccmexample")
    ccm_input = DataFrame.from_table("ccm_input")
    ccm_input2 = DataFrame.from_table("ccm_input2")
    ccmprepare_input = DataFrame.from_table("ccmprepare_input")
 
    # Example 1 -  Identify the optimal value for embedding_dimension.
    # In this call, the cause_columns and effect_columns arguments must
    # have the same value, the argument self_predict must have the value
    # 'true', and the library_size argument must be omitted.
    ccm_out1 = CCM(data = ccmexample,
                  sequence_id_column = "seqid",
                  time_column = "t",
                  cause_columns = ["b"],
                  effect_columns = ["b"],
                  embedding_dimension = [2,3,4,5,6,7,8,9,10],
                  self_predict = True
                  )
 
    # Print the result teradataml DataFrame
    print(ccm_out1)
 
    # Example 2 - Check for a causal relationship between the two time
    # series. This call uses the optimal value for embedding_dimension
    # identified in Example 1.
    ccm_out2 = CCM(data = ccmexample,
                  sequence_id_column = "seqid",
                  time_column = "t",
                  cause_columns = ["a","b"],
                  effect_columns = ["a","b"],
                  embedding_dimension = 2
                  )
 
    # Print the result teradataml DataFrame
    print(ccm_out2.result)
 
    # Example 3 - Find causal-effect relationship between income,
    # expenditure and investiment fields.
    ccm_out3 = CCM(data = ccm_input,
                   sequence_id_column = 'id',
                   time_column = 'period',
                   cause_columns = ['income'],
                   effect_columns = ['expenditure','investment'],
                   seed = 0
                   )
 
    # Print the result teradataml DataFrame
    print(ccm_out3)
 
    # Example 4 - Another example to find the cause-effect relation on
    # a sample market time series data.
    ccm_out4 = CCM(data = ccm_input2,
                   sequence_id_column = 'id',
                   time_column = 'period',
                   cause_columns = ['marketindex','indexval'],
                   effect_columns = ['indexdate','indexchange'],
                   library_size = 10,
                   seed = 0
                   )
 
    # Print the result teradataml DataFrame
    print(ccm_out4.result)
 
    # Example 5 - Alternatively, the below example produces the same
    # output as above by making use of CCMPrepare and then using
    # its output object for CCM.
    ccmprepare_out = CCMPrepare(data=ccmprepare_input,
                        data_partition_column='id'
                        )
 
    ccm_out5 = CCM(data = ccmprepare_out.result,
                   sequence_id_column = 'id',
                   time_column = 'period',
                   cause_columns = 'income',
                   effect_columns = ["expenditure","investment"],
                   seed = 0
                   )
    print(ccm_out5)
__repr__(self)
Returns the string representation for a CCM class instance.