buildTreeModel: buildTreeModel

View source: R/buildTree.R

buildTreeModelR Documentation

buildTreeModel

Description

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

Usage

buildTreeModel(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, currently not used.

Value

an object of class spotTreeModel, with a predict method and a print method.

Examples

## Create design points
set.seed(1)
x <- cbind(runif(20)*15-5, runif(20)*15)
## Compute observations at design points (for Branin function)
y <- funBranin(x)
## Create model
fit <- buildTreeModel(x,y)
## Print model parameters
print(fit)
## Predict at new location
predict(fit,cbind(1,2))
## True value at location
funBranin(matrix( c(1,2), 1, ))
## 
set.seed(123)
x <- seq(-1,1,1e-2)
y0 <- c(-10,10)
sfun0  <- stepfun(0, y0, f = 0)
y <- sfun0(x)
fit <- buildTreeModel(x,y)
# plot(fit)
# plot(x,y, type = "l")
yhat <- predict(fit, newdata = 1)
yhat$y == 10

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