Description
The HMMEvaluator function measures the probabilities of sequences, with respect to each trained HMM.
Usage
td_hmm_evaluator_mle (
init.state.prob = NULL,
state.transition.prob = NULL,
emission.prob = NULL,
observation = NULL,
state.model.key = NULL,
state.key = NULL,
state.prob.key = NULL,
trans.model.key = NULL,
trans.from.key = NULL,
trans.to.key = NULL,
trans.prob.key = NULL,
emit.model.key = NULL,
emit.state.key = NULL,
emit.observed.key = NULL,
emit.prob.key = NULL,
model.key = NULL,
sequence.key = NULL,
observed.key = NULL,
incremental = TRUE,
show.rate.change = TRUE,
seq.prob.key = NULL,
skip.key = NULL,
accumulate = NULL,
observation.sequence.column = NULL,
init.state.prob.sequence.column = NULL,
state.transition.prob.sequence.column = NULL,
emission.prob.sequence.column = NULL,
observation.partition.column = NULL,
init.state.prob.partition.column = NULL,
state.transition.prob.partition.column = NULL,
emission.prob.partition.column = NULL,
observation.order.column = NULL,
init.state.prob.order.column = NULL,
state.transition.prob.order.column = NULL,
emission.prob.order.column = NULL
)
Arguments
init.state.prob |
Required Argument. |
init.state.prob.partition.column |
Required Argument. |
init.state.prob.order.column |
Optional Argument. |
state.transition.prob |
Required Argument. |
state.transition.prob.partition.column |
Required Argument. |
state.transition.prob.order.column |
Optional Argument. |
emission.prob |
Required Argument. |
emission.prob.partition.column |
Required Argument. |
emission.prob.order.column |
Optional Argument. |
observation |
Required Argument. |
observation.partition.column |
Required Argument. |
observation.order.column |
Required Argument. |
state.model.key |
Required Argument. |
state.key |
Required Argument. |
state.prob.key |
Required Argument. |
trans.model.key |
Required Argument. |
trans.from.key |
Required Argument. |
trans.to.key |
Required Argument. |
trans.prob.key |
Required Argument. |
emit.model.key |
Required Argument. |
emit.state.key |
Required Argument. |
emit.observed.key |
Required Argument. |
emit.prob.key |
Required Argument. |
model.key |
Required Argument. |
sequence.key |
Required Argument. |
observed.key |
Required Argument. |
incremental |
Optional Argument. |
show.rate.change |
Optional Argument. |
seq.prob.key |
Optional Argument. |
skip.key |
Optional Argument. |
accumulate |
Optional Argument. |
observation.sequence.column |
Optional Argument. |
init.state.prob.sequence.column |
Optional Argument. |
state.transition.prob.sequence.column |
Optional Argument. |
emission.prob.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_hmm_evaluator_mle" which is a
named list containing object of class "tbl_teradata".
Named list member can be referenced directly with the "$" operator
using name: result.
Examples
# Get the current context/connection
con <- td_get_context()$connection
# Load example data.
loadExampleData("hmmunsupervised_example", "loan_prediction")
loadExampleData("hmmevaluator_example", "Pi_loan", "A_loan", "B_loan",
"test_loan_prediction")
# Create object(s) of class "tbl_teradata".
pi_loan <- tbl(con, "Pi_loan")
A_loan <- tbl(con, "A_loan")
B_loan <- tbl(con, "B_loan")
test_loan_prediction <- tbl(con, "test_loan_prediction")
loan_prediction <- tbl(con, "loan_prediction")
# Train a td_hmm_unsupervised_mle() function on the loan prediction dataset
td_hmm_unsupervised_out <- td_hmm_unsupervised_mle(vertices = loan_prediction,
vertices.partition.column = c("model_id", "seq_id"),
vertices.order.column = c("seq_vertex_id"),
model.key = "model_id",
sequence.key = "seq_id",
observed.key = "observed_id",
hidden.states.num = 3,
init.methods = c("random")
)
# Use the output of the trained model to make the evaluation for probabilities of sequences.
# Note: Similarly, output of a trained td_hmm_supervised_mle() function can also be used
# to make evaluation.
td_hmm_evaluator_out <- td_hmm_evaluator_mle(
init.state.prob = td_hmm_unsupervised_out$output.initialstate.table,
init.state.prob.partition.column = c("model_id"),
state.transition.prob = td_hmm_unsupervised_out$output.statetransition.table,
state.transition.prob.partition.column = c("model_id"),
emission.prob = td_hmm_unsupervised_out$output.emission.table,
emission.prob.partition.column = c("model_id"),
observation = test_loan_prediction,
observation.partition.column = c("model_id "),
observation.order.column = c("seq_id", "seq_vertex_id"),
state.model.key = "model_id",
state.key = "state",
state.prob.key = "probability",
trans.model.key = "model_id",
trans.from.key = "from_state",
trans.to.key = "to_state",
trans.prob.key = "probability",
emit.model.key = "model_id",
emit.state.key = "state",
emit.observed.key = "observed",
emit.prob.key = "probability",
model.key = "model_id",
sequence.key = "seq_id",
observed.key = "observed_id"
)
# Alternatively, load the trained model data from the Vantage Advanced SQL Engine tables
# to make the evaluations.
td_hmm_evaluator_out1 <- td_hmm_evaluator_mle(init.state.prob = pi_loan,
init.state.prob.partition.column = c("model_id"),
state.transition.prob = A_loan,
state.transition.prob.partition.column = c("model_id"),
emission.prob = B_loan,
emission.prob.partition.column = c("model_id"),
observation = test_loan_prediction,
observation.partition.column = c("model_id "),
observation.order.column = c("seq_id", "seq_vertex_id"),
state.model.key = "model_id",
state.key = "state",
state.prob.key = "probability",
trans.model.key = "model_id",
trans.from.key = "from_state",
trans.to.key = "to_state",
trans.prob.key = "probability",
emit.model.key = "model_id",
emit.state.key = "state",
emit.observed.key = "observed",
emit.prob.key = "probability",
model.key = "model_id",
sequence.key = "seq_id",
observed.key = "observed_id"
)