| |
Methods defined here:
- __init__(self, data=None, tran_item_columns=None, tran_id_columns=None, patterns_or_rules='both', group_by_columns=None, pattern_distribution_key_column=None, rule_distribution_key_column=None, compress='nocompress', group_size=4, min_support=0.05, min_confidence=0.8, max_pattern_length='2', antecedent_count_range='1-INFINITE', consequence_count_range='1-1', delimiter=',', data_sequence_column=None)
- DESCRIPTION:
The FPGrowth (frequent pattern growth) function uses an FP-growth
algorithm to create association rules from patterns in a data set,
and then determines their interestingness.
PARAMETERS:
data:
Required Argument.
Specifies the name of the teradataml DataFrame that contains the data
set.
tran_item_columns:
Required Argument.
Specifies the names of the columns that contain transaction items to
analyze.
Types: str OR list of Strings (str)
tran_id_columns:
Required Argument.
Specifies the names of the columns that contain identifiers for the
transaction items.
Types: str OR list of Strings (str)
patterns_or_rules:
Optional Argument.
Specifies whether the function outputs patterns, rules, or both. An
example of a pattern is {onions, potatoes, hamburger}.
Default Value: "both"
Permitted Values: both, patterns, rules
Types: str
group_by_columns:
Optional Argument.
Specifies the names of columns that define the partitions into which
the function groups the input data and calculates output for it. At
least one column must be usable as a distribution key. If you omit
this argument, then the function considers all input data to be in a
single partition.
Note: Do not specify the same column in both this
argument and the tran_id_columns argument, because this causes
incorrect counting in the partitions.
Types: str OR list of Strings (str)
pattern_distribution_key_column:
Optional Argument.
Specifies the name of the column to use as the distribution key for
output_pattern_table.
The default value is the first column name - "pattern_<tran_item_columns>"
as generated in the "output_pattern_table" table.
Note: only one column name can be specified.
Types: str
rule_distribution_key_column:
Optional Argument.
Specifies the name of the column to use as the distribution key for
output_rule_table.
The default value is the first column name - "antecedent_<tran_item_columns>"
as generated in the "output_rule_table" table.
Note: only one column name can be specified.
Types: str
compress:
Optional Argument.
Specifies the compression level the output tables. Realized
compression ratios depend on both this value and the data
characteristics. These ratios typically range from 3x to 12x.
Default Value: "nocompress"
Permitted Values: low, medium, high, nocompress
Types: str
group_size:
Optional Argument.
Specifies the number of transaction items to be assigned to each
worker. This value must be an int in the range from 1 to the number
of distinct transaction items, inclusive. For a machine with limited
RAM, use a relatively small value.
Default Value: 4
Types: int
min_support:
Optional Argument.
Specifies the minimum support value of returned patterns (including
the specified support value). This value must be a DECIMAL in the
range [0, 1].
Default Value: 0.05
Types: float
min_confidence:
Optional Argument.
Specifies the minimum confidence value of returned patterns
(including the specified confidence value). This value must be a
DECIMAL in the range [0, 1].
Default Value: 0.8
Types: float
max_pattern_length:
Optional Argument.
Specifies the maximum length of returned patterns. The length of a
pattern is the sum of the item numbers in the antecedent and
consequence columns. This value must be an int greater than 2.
max_pattern_length also limits the length of
returned rules to this value.
Default Value: "2"
Types: str
antecedent_count_range:
Optional Argument.
Specifies the range for na, the number of items in the antecedent.
The function returns only patterns for which na is in the range
[lower_bound, upper_bound]. The lower_bound must be greater an
integer greater than 0. The lower_bound and upper_bound can be equal.
Default Value: "1-INFINITE"
Types: str
consequence_count_range:
Optional Argument.
Specifies the range for nc, the number of items in the consequence.
The function returns only patterns for which nc is in the range
[lower_bound, upper_bound]. The lower_bound must be greater an
integer greater than 0. The lower_bound and upper_bound can be equal.
Default Value: "1-1"
Types: str
delimiter:
Optional Argument.
Specifies the delimiter that separates items in the output.
Default Value: ","
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 FPGrowth.
Output teradataml DataFrames can be accessed using attribute
references, such as FPGrowthObj.<attribute_name>.
Output teradataml DataFrame attribute names are:
1. output_pattern_table
2. output_rule_table
3. output
Note:
Based on the value passed to 'patterns_or_rules', output teradataml
DataFrames are created.
- When value is 'BOTH', all three output teradataml dataframes are
created.
- When it is 'PATTERNS', 'output_rule_table' output teradataml
dataframe is not created.
- When it is 'RULES', 'output_pattern_table' output teradataml
dataframe is not created.
RAISES:
TeradataMlException
EXAMPLES:
# Load example data.
load_example_data("fpgrowth", "sales_transaction")
# Create teradataml DataFrame objects.
# Sales transaction data of an office supply chain store.
# The column "product" specifies the items that are purchased by a
# customer in a given transaction (column "orderid")
sales_transaction = DataFrame.from_table("sales_transaction")
# Example - Compute association rules based on the pattern in the "product" column
FPGrowth_out = FPGrowth(data = sales_transaction,
tran_item_columns = ["product"],
tran_id_columns = ["orderid"],
patterns_or_rules = "both",
group_by_columns = ["region"],
min_support = 0.01,
min_confidence = 0.0,
max_pattern_length = "4"
)
# Print the results.
print(FPGrowth_out)
- __repr__(self)
- Returns the string representation for a FPGrowth 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.
|