| |
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.
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.
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.
Types: str OR list of Strings (str)
mapping_data:
Required Argument.
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:
Required Argument.
Specifies Partition By columns for "mapping_data".
Values to this argument can be provided as list, if multiple
columns are used for partition.
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.
Note: If these columns contain NaN or infinity values, then
those should be removed.
Types: str OR 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.
Note: If these columns contain NaN or infinity values, then
those should be removed.
Types: str OR list of Strings (str)
timeseries_id:
Required Argument.
Specifies the names of the columns by which the "data" is
partitioned. These columns comprise the unique ID for a time
series in "data".
Types: str OR list of Strings (str)
template_id:
Required Argument.
Specifies the names of the columns by which the "template_data"
is ordered. These columns comprise the unique ID for a time
series in "template_data".
Types: str OR list of Strings (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"],
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.
|