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

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.mle.DTW = class DTW(builtins.object)
     Methods defined here:
__init__(self, data=None, template_data=None, mapping_data=None, input_columns=None, template_columns=None, timeseries_id=None, template_id=None, radius=10, dist_method='EuclideanDistance', warp_path=False, data_sequence_column=None, template_data_sequence_column=None, mapping_data_sequence_column=None, data_partition_column=None, mapping_data_partition_column=None, data_order_column=None, template_data_order_column=None, mapping_data_order_column=None)
DESCRIPTION:
    The DTW function performs dynamic time warping (DTW), which
    measures the similarity (warp distance) between two time series
    that vary in time or speed. You can use DTW to analyze any data
    that can be represented linearly - for example, video, audio, and
    graphics.
    For example:
        • In two videos, DTW can detect similarities in walking
          patterns, even if in one video the person is walking slowly
          and in another, the same person is walking fast.
        • In audio, DTW can detect similarities in different speech
          speeds (and is therefore very useful in speech recognition
          applications).
 
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the teradataml DataFrame that contains the time
        series information.
 
    data_partition_column:
        Required Argument.
        Specifies Partition By columns for "data".
        Values to this argument can be provided as list, if multiple
        columns are used for partition.
        Note: When teradataml is connected to Vantage 1.3 or later
              versions, this argument accepts only one column which
              is specified using the "timeseries_id" argument.
        Types: str OR list of Strings (str)
 
    data_order_column:
        Required Argument.
        Specifies Order By columns for "data".
        Values to this argument can be provided as list, if multiple
        columns are used for ordering.
        Note: When teradataml is connected to Vantage 1.3 or later
              versions, this argument accepts only one column containing
              timestamp values in the "data" teradataml DataFrame.
        Types: str OR list of Strings (str)
 
    template_data:
        Required Argument.
        Specifies the teradataml DataFrame that contains the template
        information.
 
    template_data_order_column:
        Required Argument.
        Specifies Order By columns for "template_data".
        Values to this argument can be provided as list, if multiple
        columns are used for ordering.
        Note: When teradataml is connected to Vantage 1.3 or later
              versions, this argument must include the column specified
              using the "template_id" argument following the name of the
              column containing timestamp values in "template_data".
        Types: str OR list of Strings (str)
 
    mapping_data:
        Optional Argument. Required if teradataml is connected to Vantage 1.1.1
        or earlier versions.
        Specifies the teradataml DataFrame that contains the mapping
        between the rows in "data" teradataml DataFrame and the rows in
        the "template_data" teradataml DataFrame.
 
    mapping_data_partition_column:
        Optional Argument. Required when "mapping_data" is used.
        Specifies Partition By columns for "mapping_data".
        Values to this argument can be provided as list, if multiple
        columns are used for partition.
        Note: When teradataml is connected to Vantage 1.3 or later
              versions, this argument accepts only one column containing
              a unique ID for a time series in "mapping_data".
        Types: str OR list of Strings (str)
 
    mapping_data_order_column:
        Optional Argument.
        Specifies Order By columns for "mapping_data".
        Values to this argument can be provided as list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    input_columns:
        Required Argument.
        Specifies the names of the "data" columns that contain the
        values and timestamps of the time series , in that order.
        Note: If these columns contain NaN or infinity values, then
              those should be removed.
        Types: list of Strings (str)
 
    template_columns:
        Required Argument.
        Specifies the names of the "template_data" columns that contain
        the values and timestamps of the time series, in that order.
        Note: If these columns contain NaN or infinity values, then
              those should be removed.
        Types: list of Strings (str)
 
    timeseries_id:
        Required Argument.
        Specifies the name of the column by which the "data" is
        partitioned. This column must comprise the unique ID for a time
        series in "data".
        Types: str
 
    template_id:
        Required Argument.
        Specifies the name of the column by which the "template_data"
        is ordered. This column must comprise the unique ID for a time
        series in "template_data".
        Types: str
 
    radius:
        Optional Argument.
        Specifies the integer value that determines the projected warp
        path from a previous resolution.
        Default Value: 10
        Types: int
 
    dist_method:
        Optional Argument.
        Specifies the metric for computing the warping distance.
        Note: These values are case-sensitive.
        Default Value: "EuclideanDistance"
        Permitted Values: EuclideanDistance, BinaryDistance,
                          ManhattanDistance
        Types: str
 
    warp_path:
        Optional Argument.
        Determines whether to output the warping path.
        Default Value: False
        Types: bool
 
    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)
 
    template_data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each
        row of the input argument "template_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)
 
    mapping_data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each
        row of the input argument "mapping_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 DTW.
    Output teradataml DataFrames can be accessed using attribute
    references, such as DTWObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # This example compares a time series to a common template and
    # vice-versa. Time series represents stock prices (in table
    # 'timeseriesdata') and the template represents a series of stock
    # index prices (in table 'templatedata'). The mapping of
    # 'timeseriesdata' and 'templatedata' is given in table
    # 'mappingdata'.
 
    # Load example data.
    load_example_data("dtw", ["timeseriesdata", "templatedata", "mappingdata"])
 
    # Create teradataml DataFrame objects.
    timeseriesdata = DataFrame.from_table("timeseriesdata")
    templatedata = DataFrame.from_table("templatedata")
    mappingdata = DataFrame.from_table("mappingdata")
 
    # Example 1 : DTW compares "stockprice" in 'timeseriesdata'
    #             DataFrame with "indexprice" of 'templatedata'
    #             DataFrame using mapping information and generates
    #             the result DataFrame containing mapping information
    #             along with "wrap_distance" which indicates the
    #             similarity between the two columns' timeseries
    #             information.
 
    DTW_out = DTW(data = timeseriesdata,
                  data_partition_column = ["timeseriesid"],
                  data_order_column = ["timestamp1"],
                  template_data = templatedata,
                  template_data_order_column = ["timestamp2", "templateid"],
                  mapping_data = mappingdata,
                  mapping_data_partition_column = ["timeseriesid"],
                  input_columns = ["stockprice", "timestamp1"],
                  template_columns = ["indexprice", "timestamp2"],
                  timeseries_id = "timeseriesid",
                  template_id = "templateid"
                  )
    # Print the results
    print(DTW_out.result)
__repr__(self)
Returns the string representation for a DTW class instance.
get_build_time(self)
Function to return the build time of the algorithm in seconds.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
get_prediction_type(self)
Function to return the Prediction type of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
get_target_column(self)
Function to return the Target Column of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
show_query(self)
Function to return the underlying SQL query.
When model object is created using retrieve_model(), then None is returned.