Predict from a apd_isolation
# S3 method for apd_isolation
score(object, new_data, type = "numeric", ...)
A apd_isolation
object.
A data frame or matrix of new samples.
A single character. The type of predictions to generate. Valid options are:
"numeric"
for numeric predictions.
Not used, but required for extensibility.
A tibble of predictions. The number of rows in the tibble is guaranteed
to be the same as the number of rows in new_data
. The score
column is the
raw prediction from isotree::predict.isolation_forest()
while score_pctl
compares this value to the reference distribution of the score created by predicting the training set. A value of X means that X percent of the training data have scores less than the predicted value.
About the score
if (FALSE) { # interactive()
if (rlang::is_installed(c("isotree", "modeldata"))) {
library(dplyr)
data(cells, package = "modeldata")
cells_tr <- cells %>% filter(case == "Train") %>% select(-case, -class)
cells_te <- cells %>% filter(case != "Train") %>% select(-case, -class)
if_mod <- apd_isolation(cells_tr, ntrees = 10, nthreads = 1)
score(if_mod, cells_te)
}
}