|
7 | 7 | #' |
8 | 8 | #' @param newdata a data.frame to predict |
9 | 9 | #' @param ... optional arguments not used. |
10 | | -#' @param n.cores number of cores to use for prediction of anomaly score. Must |
11 | | -#' be compiled with openmp. Defaults to 1. |
12 | 10 | #' @param nodes if true return nobs x ntrees dim matrix with terminal node ids |
13 | 11 | #' @param sparse if true return sparse Matrix of dimension nobs x nTerminalNodes. |
14 | 12 | #' Each column represents a terminal node. There are as many ones in each row |
|
23 | 21 | #' correspond to more isolated observations. If sparse or nodes are set to TRUE, |
24 | 22 | #' a matrix of the requested type is returned. |
25 | 23 | #' @examples |
26 | | -#' \donttest{ |
27 | 24 | #' mod <- iForest(iris, phi=16, nt=5) |
28 | 25 | #' score <- predict(mod, newdata = iris) |
29 | | -#' } |
| 26 | +#' @return A numeric vector of length \code{nrow(newdata)} containing values between zero and one. |
| 27 | +#' Values closer to zero are less likely to be anomalous. |
30 | 28 | #' @import Matrix |
31 | 29 | #' @importFrom parallel detectCores |
32 | 30 | #' @export |
33 | | -predict.iForest <- function(object, newdata, ..., n.cores=1, nodes = FALSE, sparse = FALSE, replace_missing=TRUE, sentinel=-9999999999) { |
| 31 | +predict.iForest <- function(object, newdata, ..., nodes = FALSE, sparse = FALSE, replace_missing=TRUE, sentinel=-9999999999) { |
34 | 32 |
|
35 | 33 | if (!is.data.frame(newdata)) newdata <- as.data.frame(newdata) |
36 | 34 |
|
@@ -71,7 +69,6 @@ predict.iForest <- function(object, newdata, ..., n.cores=1, nodes = FALSE, spar |
71 | 69 | } else if (nodes) { |
72 | 70 | predict_iForest_nodes_cpp(newdata, object) |
73 | 71 | } else { |
74 | | - num_cores = as.integer(max(1, min(n.cores, detectCores()))) |
75 | | - predict_iForest_pathlength_cpp(newdata, object, num_cores) |
| 72 | + predict_iForest_pathlength_cpp(newdata, object) |
76 | 73 | } |
77 | 74 | } |
0 commit comments