Description
The HMMSupervisedLearner function is available on SQL-Graph platform.
The function can produce multiple HMM models simultaneously, where
each model is learned from a set of sequences and where each sequence
represents a vertex.
Usage
td_hmm_supervised_mle (
vertices = NULL,
model.key = NULL,
sequence.key = NULL,
observed.key = NULL,
state.key = NULL,
skip.key = NULL,
batch.size = NULL,
vertices.sequence.column = NULL,
vertices.partition.column = NULL,
vertices.order.column = NULL
)
Arguments
vertices |
Required Argument.
Specifies a tbl_teradata that contains the input vertex information.
|
vertices.partition.column |
Required Argument.
Specifies the Partition By columns for "vertices".
Values to this argument can be provided as vector, if multiple
columns are used for partition.
Note:
1. This argument must contain the name of the column
specified in "sequence.key" argument.
2. This argument should contain the name of the column
specified in "model.key", if "model.key" argument is
used, and it must be the first column followed by the
name of the column specified in "sequence.key".
Types: character OR vector of Strings (character)
|
vertices.order.column |
Required Argument.
Specifies the Order By columns for "vertices".
Values to this argument can be provided as vector, if multiple
columns are used for ordering.
Note: This argument must contain the name of the column, containing
time ordered sequence, as one of its columns.
Types: character OR vector of Strings (character)
|
model.key |
Optional Argument.
Specifies the name of the column that contains the model attribute.
The values in the column can be integers or strings.
Note: The "vertices.partition.column" argument should contain the name
of the column specified in this argument.
Types: character
|
sequence.key |
Required Argument.
Specifies the name of the column that contains the sequence
attribute. It must match one of the columns specified in the
"vertices.partition.column" argument. A sequence (value in this column)
must contain more than two observation symbols. Each sequence represent
a vertex.
Types: character
|
observed.key |
Required Argument.
Specifies the name of the column that contains the observed symbols. The
function scans the input tbl_teradata to find all possible observed
symbols.
Note: Observed symbols are case-sensitive.
Types: character
|
state.key |
Required Argument.
Specifies the state attributes. You can specify multiple states. The states are
case-sensitive.
Types: character
|
skip.key |
Optional Argument.
Specifies the name of the column whose values determine whether the function
skips the row. The function skips the row if the value is "true",
"yes", "y", or "1". The function does not skip the row if the value
is "false", "f", "no", "n", "0", or NULL.
Types: character
|
batch.size |
Optional Argument.
Specifies the number of models to process. The size must be positive. If the
batch size is not specified, the function avoids out-of-memory errors
by determining the appropriate size. If the batch size is specified
and there is insufficient free memory, the function reduces the batch
size. The function determines the batch size dynamically based on the memory
conditions. For example, the batch size is set to 1000, at time T1, it might
be adjusted to 980, and at time T2, it might be adjusted to 800.
Types: integer
|
vertices.sequence.column |
Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row
of the input argument "vertices". The argument is used to ensure
deterministic results for functions which produce results that vary
from run to run.
Types: character OR vector of Strings (character)
|
Value
Function returns an object of class "td_hmm_supervised_mle" which is a
named list containing objects of class "tbl_teradata".
Named list members can be referenced directly with the "$" operator
using following names:
output.initialstate.table
-
output.statetransition.table
output.emission.table
output
Examples
# Get the current context/connection
con <- td_get_context()$connection
# Load example data.
loadExampleData("hmmsupervised_example", "customer_loyalty")
# Create object(s) of class "tbl_teradata".
customer_loyalty <- tbl(con, "customer_loyalty")
# Example 1 - Train a td_hmm_supervised_mle() function on the customer loyalty dataset
td_hmm_supervised_out <- td_hmm_supervised_mle(vertices = customer_loyalty,
vertices.partition.column = c("user_id", "seq_id"),
vertices.order.column = c("user_id", "seq_id",
"purchase_date"),
model.key = "user_id",
sequence.key = "seq_id",
observed.key = "observation",
state.key = "loyalty_level"
)