View source: R/5-classifier-model-functions.R
predict.sevt | R Documentation |
Predict class values from a staged event tree model.
## S3 method for class 'sevt' predict(object, newdata = NULL, class = NULL, prob = FALSE, log = FALSE, ...)
object |
an object of class |
newdata |
the newdata to perform predictions |
class |
character, the name of the variable to use as
the class variable, if NULL the first element |
prob |
logical, if |
log |
logical, if |
... |
additional parameters, see details |
Predict the most probable a posterior value for the class variable given all the other variables in the model. Ties are broken at random and if, for a given vector of predictor variables, all conditional probabilities are 0, NA is returned.
if prob = TRUE
, a matrix with number of rows equals to the number of
rows in the newdata
and number of columns as the number of levels of the
class
variable is returned. if log = TRUE
, log-probabilities are returned.
if prob = FALSE
, a vector of length as the number of rows in the newdata
with the level with higher estimated probability for each new observations is returned.
A vector of predictions or the corresponding matrix of probabilities.
DD <- generate_xor_dataset(n = 4, 600) order <- c("C", "X1", "X2", "X3", "X4") train <- DD[1:500, order] test <- DD[501:600, order] model <- full(train) model <- stages_bhc(model) pr <- predict(model, newdata = test, class = "C") table(pr, test$C) # class values: predict(model, newdata = test, class = "C") # probabilities: predict(model, newdata = test, class = "C", prob = TRUE) # log-probabilities: predict(model, newdata = test, class = "C", prob = TRUE, log = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.