buildRanger: ranger Interface

View source: R/buildRanger.R

buildRangerR Documentation

ranger Interface

Description

This is a simple wrapper for the ranger function from the ranger package. The purpose of this function is to provide an interface as required by SPOT, to enable modeling and model-based optimization with ranger.

Usage

buildRanger(x, y, control = list())

Arguments

x

matrix of input parameters. Rows for each point, columns for each parameter.

y

one column matrix of observations to be modeled.

control

list of control parameters. These are all configuration parameters of the ranger function, and will be passed on to it.

Value

an object of class spotRanger, with a predict method and a print method. #'

Examples


## Create a simple training data set
testfun <- function (x) x[1]^2
x <- cbind(sort(runif(30)*2-1))
y <- as.matrix(apply(x,1,testfun))
## test data:
xt <- cbind(sort(runif(3000)*2-1))
## Example with default model (standard randomforest)
fit <- buildRanger(x,y)
yt <- predict(fit,data.frame(x=xt))
plot(xt,yt$y,type="l")
points(x,y,col="red",pch=20)
## Example with extra trees, an interpolating model
fit <- buildRanger(x,y,
                   control=list(rangerArguments = 
                                list(replace = FALSE,
                                   sample.fraction=1,
                                   min.node.size = 1,
                                   splitrule = "extratrees")))
yt <- predict(fit,data.frame(x=xt))
plot(xt,yt$y,type="l")
points(x,y,col="red",pch=20)


SPOT documentation built on June 26, 2022, 1:06 a.m.