This is a simple wrapper for the randomForest function from the randomForest package. The purpose of this function is to provide an interface as required by SPOT, to enable modeling and model-based optimization with random forest.
buildRandomForest(x, y, control = list())
matrix of input parameters. Rows for each point, columns for each parameter.
one column matrix of observations to be modeled.
list of control parameters, currently not used.
an object of class "spotRandomForest"
, with a predict
method and a print
method.
# NOT RUN {
## Test-function:
braninFunction <- function (x) {
(x[2] - 5.1/(4 * pi^2) * (x[1] ^2) + 5/pi * x[1] - 6)^2 +
10 * (1 - 1/(8 * pi)) * cos(x[1] ) + 10
}
## Create design points
set.seed(1)
x <- cbind(runif(20)*15-5,runif(20)*15)
## Compute observations at design points (for Branin function)
y <- as.matrix(apply(x,1,braninFunction))
## Create model
fit <- buildRandomForest(x,y,control = list(algTheta=optimLHD))
## Print model parameters
print(fit)
## Predict at new location
predict(fit,cbind(1,2))
## True value at location
braninFunction(c(1,2))
# }
Run the code above in your browser using DataLab