| |
Methods defined here:
- __init__(self, data=None, data_optional=None, conversion_data=None, excluding_data=None, optional_data=None, model1_type=None, model2_type=None, event_column=None, timestamp_column=None, window_size=None, data_partition_column=None, data_optional_partition_column=None, data_order_column=None, data_optional_order_column=None, conversion_data_order_column=None, excluding_data_order_column=None, optional_data_order_column=None, model1_type_order_column=None, model2_type_order_column=None)
- DESCRIPTION:
The Attribution function is used in web page analysis, where it lets
companies assign weights to pages before certain events, such as
buying a product.
PARAMETERS:
data:
Required Argument.
Specifies the teradataml DataFrame that contains the click stream data,
which the function uses to compute attributions.
data_partition_column:
Required Argument.
Specifies Partition By columns for data.
Values to this argument can be provided as a 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 a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
data_optional:
Optional Argument.
Specifies the teradataml DataFrame that contains the click stream data,
which the function uses to compute attributions.
data_optional_partition_column:
Optional Argument.
Required if the data_optional teradataml DataFrame is used.
Specifies Partition By columns for data_optional.
Values to this argument can be provided as a list, if multiple
columns are used for partition.
Types: str OR list of Strings (str)
data_optional_order_column:
Optional Argument.
Required if the data_optional teradataml DataFrame is used.
Specifies Order By columns for data_optional.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
conversion_data:
Required Argument.
Specifies the teradataml DataFrame that contains one varchar column
(conversion_events) containing conversion event values.
conversion_data_order_column:
Optional Argument.
Specifies Order By columns for conversion_data.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
excluding_data:
Optional Argument.
Specifies the teradataml DataFrame that contains one varchar column
(excluding_events) containing excluding cause event values.
excluding_data_order_column:
Optional Argument.
Specifies Order By columns for excluding_data.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
optional_data:
Optional Argument.
Specifies the teradataml DataFrame that contains one varchar column
(optional_events) containing optional cause event values.
optional_data_order_column:
Optional Argument.
Specifies Order By columns for optional_data.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
model1_type:
Required Argument.
Specifies the teradataml DataFrame that defines the type and
specification of the first model.
For example:
model1_data ("EVENT_REGULAR", "email:0.19:LAST_CLICK:NA",
"impression:0.81:WEIGHTED:0.4,0.3,0.2,0.1")
model1_type_order_column:
Optional Argument.
Specifies Order By columns for model1_type.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
model2_type:
Optional Argument.
Specifies the teradataml DataFrame that defines the type and
distributions of the second model.
For example:
model2_data ("EVENT_OPTIONAL", "OrganicSearch:0.5:UNIFORM:NA",
"Direct:0.3:UNIFORM:NA", "Referral:0.2:UNIFORM:NA")
model2_type_order_column:
Optional Argument.
Specifies Order By columns for model2_type.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
event_column:
Required Argument.
Specifies the name of the input column that contains the clickstream
events.
Types: str
timestamp_column:
Required Argument.
Specifies the name of the input column that contains the timestamps
of the clickstream events.
Types: str
window_size:
Required Argument.
Specifies how to determine the maximum window size for the
attribution calculation:
rows:K :
Consider the maximum number of events to be attributed,
excluding events of types specified in excluding_data,
which means assigning attributions to at most K effective
events before the current impact event.
seconds:K :
Consider the maximum time difference between the current
impact event and the earliest effective event to be attributed.
rows:K&seconds:K2 :
Consider both constraints and comply with the stricter one.
Types: str
RETURNS:
Instance of Attribution.
Output teradataml DataFrames can be accessed using attribute
references, such as AttributionObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
result
RAISES:
TeradataMlException
EXAMPLES:
# Load the data to run the example
load_example_data("attribution", ["attribution_sample_table1",
"attribution_sample_table2" , "conversion_event_table",
"optional_event_table", "model1_table", "model2_table"])
# Create teradataml DataFrame objects
attribution_sample_table1 = DataFrame.from_table("attribution_sample_table1")
attribution_sample_table2 = DataFrame.from_table("attribution_sample_table2")
conversion_event_table = DataFrame.from_table("conversion_event_table")
optional_event_table = DataFrame.from_table("optional_event_table")
model1_table = DataFrame.from_table("model1_table")
model2_table = DataFrame.from_table("model2_table")
# Execute function
attribution_out = Attribution(data=attribution_sample_table1,
data_partition_column="user_id",
data_order_column="time_stamp",
data_optional=attribution_sample_table2,
data_optional_partition_column='user_id',
data_optional_order_column='time_stamp',
event_column="event",
conversion_data=conversion_event_table,
optional_data=optional_event_table,
timestamp_column = "time_stamp",
window_size = "rows:10&seconds:20",
model1_type=model1_table,
model2_type=model2_table
)
# Print the results
print(attribution_out.result)
- __repr__(self)
- Returns the string representation for a Attribution 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.
|