predict.gpcm: Predict class probability at newdata for a Gaussian Process...

View source: R/gpcmStruct.R

predictR Documentation

Predict class probability at newdata for a Gaussian Process Classification (GPC) model

Description

Predicted probability of class 1. Optionally, conditional covariance based on a gpcm model and 95% quantiles of the probability of class 1 are returned.

Usage

## S3 method for class 'gpcm'
predict(object, newdata, nsimu = NULL, 
light.return = FALSE, checkNames=FALSE, seed = NULL, ...)

Arguments

object

an object of class gpcm.

newdata

a vector, matrix of points to be predicted.

nsimu

an optional integer indicating whether to resample latent GP at observation points and how many samples are required. If NULL, current samples are used. Default is NULL.

light.return

an optional boolean. If TRUE, only prob is returned. Default is FALSE.

checkNames

an optional boolean. If TRUE, a consistency test is performed between the names of newdata and the names of the experimental design (contained in object@Xf). Default is FALSE.

seed

to fix the seed (used if nsimu is not NULL). Default is NULL.

...

no other argument for this method

Value

prob

the (averaged) probability of class 1 at newdata.

lower95, upper95

95% confidence bounds for the probability at newdata.

probs

a matrix of sample predicted probabilities.

Zsimu_var, Zsimu_mean

conditional variance vector and mean matrix of the latent GP at newdata.

cov

conditional covariance matrix at newdata.

c

an auxiliary matrix, containing all the covariances between newdata and design points Xf.

lambda

an auxiliary vector, product of the inverse covariance matrix invK returned by object and the unconditional covariance matrix c between newdata and design points Xf.

kz

an auxiliary matrix, corresponding to the unconditional covariance matrix at newdata.

Author(s)

Morgane MENZ, Céline HELBERT, Victor PICHENY, François BACHOC. Contributors: Naoual SERRAJI.

References

Bachoc, F., Helbert, C. & Picheny, V. Gaussian process optimization with failures: classification and convergence proof. J Glob Optim 78, 483–506 (2020). \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s10898-020-00920-0")}.

Roustant, O., Ginsbourger, D. & Deville, Y. Contributors: Chevalier, C. , Richet, Y. DiceKriging: Kriging Methods for Computer Experiments. R package version 1.6.0. https://CRAN.R-project.org/package=DiceKriging.

Examples

# ----------------------------------
# A 2D example - Branin-Hoo function
# ----------------------------------

# 30-points DoE, and the corresponding response
d <- 2
nb_PX <- 30
require(DiceDesign)
X <- lhsDesign(nb_PX, d, seed = 123)$design
Xopt <- maximinSA_LHS(X, T0 = 10, c = 0.99, it = 1000)
x <- Xopt$design
require(DiceKriging)
fx <- apply(x, 1, branin)
s <- ifelse(fx < 14, -1, 1)
f <- s
Xf <- as.matrix(x)

# Bulding GPC model
GPCmodel <- gpcm(f = f, Xf = Xf, coef.m = -0.1, coef.cov=c(0.8,0.5))

# Graphics - Predict probabilities
ngrid <- 50
x.grid <- seq(0, 1., length.out = ngrid)
grid <- as.matrix(expand.grid(x.grid, x.grid))
probabilities <- predict(object = GPCmodel, newdata = grid)$prob
filled.contour(x.grid, x.grid, matrix(probabilities, ngrid, ngrid),
               color.palette = function(n) hcl.colors(n, "RdYlBu", rev = FALSE),
               main = "probabilities map",
               plot.axes = {
                 axis(1)
                 axis(2)
                 points(Xf[f == 1, 1], Xf[f == 1, 2], col = "blue", pch = 21, bg = "blue")
                 points(Xf[f == -1, 1], Xf[f == -1, 2], col = "red", pch = 21, bg = "red")
               }
)

GPCsign documentation built on April 4, 2025, 1:55 a.m.