R/h2o.extendedIsolationForest.R
step_outliers_h2o.extendedIsolationForest.Rd
step_outliers_h2o.extendedIsolationForest
creates a specification of a recipe
step that will calculate the outlier score using h2o.extendedIsolationForest from h2o
.
step_outliers_h2o.extendedIsolationForest(
recipe,
...,
role = NA,
trained = FALSE,
outlier_score = NULL,
columns = NULL,
name_mutate = ".outliers_h2o.extendedIsolationForest",
options = list(extension_level = "max"),
init_options = list(),
skip = TRUE,
id = rand_id("outliers_h2o.extendedIsolationForest")
)
# S3 method for step_outliers_h2o.extendedIsolationForest
tidy(x, ...)
A recipe object. The step will be added to the sequence of operations for this recipe.
One or more selector functions to choose variables
for this step. See selections()
for more details.
not defined for this function
A logical to indicate if the quantities for preprocessing have been estimated.
a placeholder for the exit of this function don't change
A character string of variable names that will be populated (eventually) by the terms argument.
the name of the generated column with h2o.extendedIsolationForest scores
a list with arguments to h2o::h2o.extendedIsolationForest function.
a list with parameters to h2o::h2o.init
A logical. Should the step be skipped when the
recipe is baked by bake()
? While all operations are baked
when prep()
is run, some operations may not be able to be
conducted on new data (e.g. processing the outcome variable(s)).
Care should be taken when using skip = TRUE
as it may affect
the computations for subsequent operations.
A character string that is unique to this step to identify it.
A step_outliers_h2o.extendedIsolationForest
object.
An updated version of recipe
with the new step
added to the sequence of existing steps (if any), with the name on name_mutate
and the scores calculated. For the
tidy
method, a tibble with columns index
(the row indexes of the tibble) and outlier_score
(the scores).
All columns in the data are sampled and returned by juice()
and bake()
.
When used in modeling, users should strongly consider using the
option skip = TRUE
so that this operation is not
conducted outside of the training set.
library(recipes)
library(tidy.outliers)
rec <-
recipe(mpg ~ ., data = mtcars) %>%
step_outliers_h2o.extendedIsolationForest(all_predictors()) %>%
prep(mtcars)
#>
#> H2O is not running yet, starting it now...
#>
#> Note: In case of errors look at the following log files:
#> /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpAkhFmm/file21a0138aa5d7/h2o_runner_started_from_r.out
#> /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpAkhFmm/file21a0738dd046/h2o_runner_started_from_r.err
#>
#>
#> Starting H2O JVM and connecting: ... Connection successful!
#>
#> R is connected to the H2O cluster:
#> H2O cluster uptime: 4 seconds 80 milliseconds
#> H2O cluster timezone: UTC
#> H2O data parsing timezone: UTC
#> H2O cluster version: 3.38.0.1
#> H2O cluster version age: 4 months and 26 days !!!
#> H2O cluster name: H2O_started_from_R_runner_yrs698
#> H2O cluster total nodes: 1
#> H2O cluster total memory: 3.10 GB
#> H2O cluster total cores: 3
#> H2O cluster allowed cores: 3
#> H2O cluster healthy: TRUE
#> H2O Connection ip: localhost
#> H2O Connection port: 54321
#> H2O Connection proxy: NA
#> H2O Internal Security: FALSE
#> R Version: R version 4.2.2 (2022-10-31)
#> Warning:
#> Your H2O cluster version is too old (4 months and 26 days)!
#> Please download and install the latest version from http://h2o.ai/download/
#>
#>
|
| | 0%
|
|======================================================================| 100%
#>
|
| | 0%
|
|======================================================================| 100%
#>
|
| | 0%
|
|======================================================================| 100%
bake(rec, new_data = NULL)
#> # A tibble: 32 × 12
#> cyl disp hp drat wt qsec vs am gear carb mpg .outliers…¹
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 6 160 110 3.9 2.62 16.5 0 1 4 4 21 0.390
#> 2 6 160 110 3.9 2.88 17.0 0 1 4 4 21 0.389
#> 3 4 108 93 3.85 2.32 18.6 1 1 4 1 22.8 0.414
#> 4 6 258 110 3.08 3.22 19.4 1 0 3 1 21.4 0.440
#> 5 8 360 175 3.15 3.44 17.0 0 0 3 2 18.7 0.448
#> 6 6 225 105 2.76 3.46 20.2 1 0 3 1 18.1 0.435
#> 7 8 360 245 3.21 3.57 15.8 0 0 3 4 14.3 0.451
#> 8 4 147. 62 3.69 3.19 20 1 0 4 2 24.4 0.473
#> 9 4 141. 95 3.92 3.15 22.9 1 0 4 2 22.8 0.406
#> 10 6 168. 123 3.92 3.44 18.3 1 0 4 4 19.2 0.401
#> # … with 22 more rows, and abbreviated variable name
#> # ¹.outliers_h2o.extendedIsolationForest
tidy(rec, number = 1)
#> # A tibble: 32 × 3
#> index outlier_score id
#> <int> <dbl> <chr>
#> 1 1 0.390 outliers_h2o.extendedIsolationForest_bAnZj
#> 2 2 0.389 outliers_h2o.extendedIsolationForest_bAnZj
#> 3 3 0.414 outliers_h2o.extendedIsolationForest_bAnZj
#> 4 4 0.440 outliers_h2o.extendedIsolationForest_bAnZj
#> 5 5 0.448 outliers_h2o.extendedIsolationForest_bAnZj
#> 6 6 0.435 outliers_h2o.extendedIsolationForest_bAnZj
#> 7 7 0.451 outliers_h2o.extendedIsolationForest_bAnZj
#> 8 8 0.473 outliers_h2o.extendedIsolationForest_bAnZj
#> 9 9 0.406 outliers_h2o.extendedIsolationForest_bAnZj
#> 10 10 0.401 outliers_h2o.extendedIsolationForest_bAnZj
#> # … with 22 more rows