View source: R/predict.PPtreeExtclass.R
| predict.PPtreeExtclass | R Documentation |
Predicts class labels for new observations using a fitted projection pursuit classification tree and optionally calculates prediction error when true class labels are provided.
## S3 method for class 'PPtreeExtclass'
predict(object, newdata, true.class = NULL, ...)
object |
An object of class |
newdata |
A data frame or matrix containing the predictor variables for which predictions are to be made. Must contain the same variables (in the same order) as used in the training data, but without the class variable. |
true.class |
Optional vector of true class labels for the test data.
If provided, prediction error will be calculated. Can be either numeric or
factor. Default is |
... |
Additional arguments (currently not used). |
A list with two components:
predict.class |
A character vector of predicted class labels for each
observation in |
predict.error |
Integer count of prediction errors (misclassifications).
Only computed when |
data(penguins)
penguins <- na.omit(penguins[, -c(2,7, 8)])
require(rsample)
penguins_spl <- rsample::initial_split(penguins, strata=species)
penguins_train <- training(penguins_spl)
penguins_test <- testing(penguins_spl)
penguins_ppt <- PPtreeExtclass(species~bill_len + bill_dep +
flipper_len + body_mass, data = penguins_train, PPmethod = "LDA", tot =nrow
(penguins_train), tol=0.5)
predict(object = penguins_ppt, newdata = penguins_test[,-1], true.class = penguins_test$species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.