| |
Methods defined here:
- __init__(self, data=None, target_column=None, source=None, threshold=None, output_column='distance', output_target='target', print_source='source', accumulate=None, data_sequence_column=None, data_order_column=None)
- DESCRIPTION:
The LevenshteinDistance function computes the Levenshtein
distance between two text values. The Levenshtein distance
(or edit distance) is the number of edits needed to
transform one string into the other. An edit is an insertion,
deletion, or substitution of a single character.
PARAMETERS:
data:
Required Argument.
Specifies the teradataml DataFrame containing the input data.
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)
target_column:
Required Argument.
Specifies the name of the input teradataml DataFrame column that contains
the target text.
Types: str
source:
Required Argument.
Specifies the names of the input teradataml DataFrame columns that contain
the source text.
Types: str OR list of Strings (str)
threshold:
Optional Argument.
Specifies the value that determines whether to return the Levenshtein
distance for a source-target pair. The threshold must be a positive
integer. The function returns the Levenshtein distance for a pair if
it is less than or equal to threshold; otherwise, the function
returns -1. By default, the function returns the Levenshtein distance
of every pair.
Types: int
output_column:
Optional Argument.
Specifies the name of the output column that contains the Levenshtein
distance for a source-target pair.
Default Value: "distance"
Types: str
output_target:
Optional Argument.
Specifies the name of the output column that contains the compared
target text.
Default Value: "target"
Types: str
print_source:
Optional Argument.
Specifies the name of the output column that contains the compared
source text.
Default Value: "source"
Types: str
accumulate:
Optional Argument.
Specifies the names of the input teradataml DataFrame columns to copy to
the output table.
Types: str OR list of Strings (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 LevenshteinDistance.
Output teradataml DataFrames can be accessed using attribute
references, such as LevenshteinDistanceObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
result
RAISES:
TeradataMlException
EXAMPLES:
# Load example data.
load_example_data("levenshteindistance", "levendist_input")
# Create teradataml DataFrame objects.
levendist_input = DataFrame.from_table("levendist_input")
# Example 1 - This function computes the Levenshtein distance between two input text values.
levenshtein_distance_out = LevenshteinDistance(data=levendist_input,
target_column = "tar_text",
source = ["src_text1", "src_text2"],
threshold = 10,
accumulate = "id"
)
# Print the result DataFrame
print(levenshtein_distance_out.result)
- __repr__(self)
- Returns the string representation for a LevenshteinDistance 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.
|