Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sparse grid Gaussian processes

NotificationsYou must be signed in to change notification settings

CollinErickson/CGGP

Repository files navigation

CRAN_Status_BadgecodecovCRAN-RStudio-mirror-downloadsR-CMD-check

The goal of CGGP is to provide a sequential design of experimentalgorithm that can efficiently use many points and interpolate exactly.

Installation

You can install CGGP from GitHub with:

# install.packages("devtools")devtools::install_github("CollinErickson/CGGP")

Example

To create a CGGP object:

## basic example codelibrary(CGGP)d<-4CG<- CGGPcreate(d=d,200)print(CG)#> CGGP object#>    d = 4#>    output dimensions = 1#>    CorrFunc = PowerExponential#>    number of design points             = 193#>    number of unevaluated design points = 193#>    Available functions:#>      - CGGPfit(CGGP, Y) to update parameters with new data#>      - CGGPpred(CGGP, xp) to predict at new points#>      - CGGPappend(CGGP, batchsize) to add new design points#>      - CGGPplot<name>(CGGP) to visualize CGGP model

A newCGGP object has design points that should be evaluated next,either fromCG$design orCG$design_unevaluated.

f<-function(x) {x[1]^2*cos(x[3])+4*(0.5-x[2])^3*(1-x[1]/3)+x[1]*sin(2*2*pi*x[3]^2)}Y<- apply(CG$design,1,f)

Once you have evaluated the design points, you can fit the object withCGGPfit.

CG<- CGGPfit(CG,Y)CG#> CGGP object#>    d = 4#>    output dimensions = 1#>    CorrFunc = PowerExponential#>    number of design points             = 193#>    number of unevaluated design points = 0#>    Available functions:#>      - CGGPfit(CGGP, Y) to update parameters with new data#>      - CGGPpred(CGGP, xp) to predict at new points#>      - CGGPappend(CGGP, batchsize) to add new design points#>      - CGGPplot<name>(CGGP) to visualize CGGP model

If you want to use the model to make predictions at new input points,you can useCGGPpred.

xp<-matrix(runif(10*CG$d),ncol=CG$d)CGGPpred(CG,xp)#> $mean#>              [,1]#>  [1,] -0.52367139#>  [2,] -0.31521070#>  [3,]  0.05781108#>  [4,]  0.94199482#>  [5,]  0.98578179#>  [6,] -0.22661334#>  [7,]  0.17936738#>  [8,] -0.16986576#>  [9,]  0.73173845#> [10,] -0.15488181#>#> $var#>               [,1]#>  [1,] 0.0092572099#>  [2,] 0.0221140651#>  [3,] 0.0094446082#>  [4,] 0.0134280357#>  [5,] 0.0012771995#>  [6,] 0.0002103327#>  [7,] 0.0035323769#>  [8,] 0.0149844852#>  [9,] 0.0170830979#> [10,] 0.0183621344

To add new design points to the already existing design, useCGGPappend. It will use the data already collected to find the mostuseful set of points to evaluate next.

# To add 100 pointsCG<- CGGPappend(CG,100)

Now you will need to evaluate the points added toCG$design, and refitthe model.

ynew<- apply(CG$design_unevaluated,1,f)CG<- CGGPfit(CG,Ynew=ynew)

Plot functions

There are a few functions that will help visualize the CGGP design.

CGGPplotblocks

CGGPplotblocks shows the block structure when projected down to allpairs of two dimensions. The plot is symmetric. The facet labels be alittle bit confusing. The first column has the label 1, and it lookslike it is saying that the x-axis for each plot in that column is forX1, but it is actually the y-axis that isX1 for each plot in thatcolumn.

CGGPplotblocks(CG)

CGGPplotheat

CGGPplotheat is similar toCGGPplotblocks and can be easier to readsince it is only a single plot. The$(i,j)$ entry shows the maximumvalue for which a block was selected with$X_i$ and$X_j$ at least thatlarge. The diagonal entries,$(i, i)$, show the maximum depth for$X_i$.A diagonal entry must be at least as large as any entry in its column orrow. This plot is also symmetric.

CGGPplotheat(CG)

CGGPhist

CGGPhist shows histograms of the block depth in each direction. Thedimensions that have more large values are dimensions that have beenexplored more. These should be the more active dimensions.

CGGPplothist(CG)#> Warning: Transformation introduced infinite values in continuous y-axis#> Warning: Removed 12 rows containing missing values (`geom_bar()`).

CGGPplotcorr

CGGPplotcorr gives an idea of what the correlation structure in eachdimension is. The values plotted do not represent the actual data givento CGGP. Each wiggly line represents a random Gaussian process drawnusing the correlation parameters for that dimension from the given CGGPmodel. Dimensions that are more wiggly and have higher variance are themore active dimensions. Dimensions with nearly flat lines mean that thecorresponding input dimension has a relatively small effect on theoutput.

CGGPplotcorr(CG)

CGGPplotvariogram

CGGPplotvariogram shows something similar to the semi-variogram forthe correlation parameters found for each dimension. Really it is justshowing how the correlation function decays for points that are furtheraway. It should always start aty=1 forx=0 and decrease iny asx gets larger

CGGPplotvariogram(CG)

CGGPplotslice

CGGPplotslice shows what the predicted model along each individualdimension when the other input dimensions are held constant, i.e., aslice along a single dimension. By default the slice is done holding allother inputs at 0.5, but this can be changed by changing the argumentproj. The black dots are the data points that are in that slice If youchangeproj to have values not equal to 0.5, you probably won’t seeany black dots. The pink regions are the 95% prediction intervals.

This plot is the best for giving an idea of what the higher dimensionfunction look like. You can see how the output changes as each input isvaried.

CGGPplotslice(CG)

The next plot changes so that all the other dimensions are held constantat 0.15 for each slice plot. When moving from the center line, the errorbounds generally should be larger since it is further from the data, butwe should see similar patterns unless the function is highly nonlinear.

CGGPplotslice(CG,proj= rep(.15,CG$d))

CGGPplottheta

CGGPplottheta is useful for getting an idea of how the samples for thecorrelation parameters (theta) vary compared to the maximum a posteriori(MAP). This may be helpful when usingUCB orTS inCGGPappend toget an idea of how much uncertainty there is in the parameters. Notethat there are likely multiple parameters for each input dimension.

CGGPplottheta(CG)

CGGPplotsamplesneglogpost

CGGPplotsamplesneglogpost shows the negative log posterior for each ofthe different samples for theta. The value for the MAP is shown as ablue line. It should be at the far left edge if it is the true MAP.

CGGPplotsamplesneglogpost(CG)

About

Sparse grid Gaussian processes

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp