predict.iForest: predict.iForest

Description Usage Arguments Details Value Examples

View source: R/predict.R

Description

return predictions of various types for the isolation forest object

Usage

1
2
3
## S3 method for class 'iForest'
predict(object, newdata, ..., nodes = FALSE,
  sparse = FALSE, replace_missing = TRUE, sentinel = -9999999999)

Arguments

object

an iForest object

newdata

a data.frame to predict

...

optional arguments not used.

nodes

if true return nobs x ntrees dim matrix with terminal node ids

sparse

if true return sparse Matrix of dimension nobs x nTerminalNodes. Each column represents a terminal node. There are as many ones in each row as there are trees in the forest. Each observation can only belong to one terminal node per tree. Useful for further modeling or to identify predictive interactions.

replace_missing

if TRUE, replaces missing factor levels with "." and missing numeric values with the sentinel argument

sentinel

value to use as stand-in for missing numeric values

Details

By default the predict function returns an anomaly score. The anomaly score is a [0,1] scaled measure of isolation. Higher scores correspond to more isolated observations. If sparse or nodes are set to TRUE, a matrix of the requested type is returned.

Value

A numeric vector of length nrow(newdata) containing values between zero and one. Values closer to zero are less likely to be anomalous.

Examples

1
2
mod <- iForest(iris, phi=16, nt=5)
score <- predict(mod, newdata = iris)

Zelazny7/isofor documentation built on Aug. 28, 2019, 7:12 p.m.