| wrap_ranger | R Documentation |
Fits a 'ranger' random forest with a consistent interface. Supports both classification (factor 'y') and regression (numeric 'y').
wrap_ranger(x, y, ...)
## S3 method for class 'wrap_ranger'
predict(object, newx, type = c("class", "prob"), ...)
## S3 method for class 'wrap_ranger'
print(x, ...)
x |
A matrix or data.frame of features. |
y |
A factor or character vector for classification, numeric for regression. |
... |
Additional arguments passed to [ranger::ranger()]. |
object |
A fitted 'wrap_ranger' object. |
newx |
A matrix or data.frame of new observations. |
type |
'"class"' (default) for class labels, '"prob"' for a probability matrix. Ignored for regression. |
An object of class 'wrap_ranger' with fields:
fit |
The fitted ranger model. |
levels |
Class levels (NULL for regression). |
task |
"classification" or "regression". |
X <- as.matrix(iris[, 1:4])
y <- iris$Species
mod <- wrap_ranger(X, y, num.trees = 100L)
predict(mod, newx = X, type = "class")
predict(mod, newx = X, type = "prob")
X <- as.matrix(iris[, 1:4])
y <- iris$Species
mod <- wrap_ranger(X, y, num.trees = 100L)
predict(mod, newx = X, type = "class")
predict(mod, newx = X, type = "prob")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.