Skip to content

Instantly share code, notes, and snippets.

@sdwfrost
Created March 4, 2021 14:48
Show Gist options
  • Save sdwfrost/921658ad32df4370e0426cc64231060d to your computer and use it in GitHub Desktop.
Save sdwfrost/921658ad32df4370e0426cc64231060d to your computer and use it in GitHub Desktop.
mogp example in Surrogates.jl
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vikram-s-narayan
Copy link

vikram-s-narayan commented Apr 10, 2022

@sdwfrost
A new surrogate - AbstractGPSurrogate - has been added to surrogates.jl.

The following code where we replace the Kriging surrogate with AbstractGPSurrogate:

using AbstractGPs #necessary to define kernel - GP(SqExponentialKernel())

gp = AbstractGPSurrogate(simulation_points, simulation_output, gp=GP(SqExponentialKernel()), Σy=0.01)
@time gp_output = gp.(simulation_points);
scatter(simulation_output,gp_output,xlabel="Observed",ylabel="Predicted",legend=false,title="Training")
n_valid = 10
validation_points = sample(n_valid, lower_bound, upper_bound, LatinHypercubeSample());
validation_output = simulator.(validation_points);
@time predictions = gp.(validation_points);
scatter(validation_output,predictions,xlabel="Observed",ylabel="Predicted",legend=false,title="Testing")
n_predict = 10000
prediction_points = sample(n_predict, lower_bound, upper_bound, LatinHypercubeSample());
prediction_output = gp.(prediction_points);
prediction_se = std_error_at_point.(gp, prediction_points);
prediction_implausibility = abs.(prediction_output .- 2000)./(prediction_se .+ sqrt(400));
sum(prediction_implausibility .> 3.0)
scatter(prediction_points,markersize=5.0,group=prediction_implausibility .< 3.0)

produces a plot like this:

Screenshot 2022-04-10 at 12 51 29 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment