Skip to content

Commit

Permalink
example to produce comparable figs
Browse files Browse the repository at this point in the history
  • Loading branch information
odunbar committed Oct 4, 2022
1 parent c0a49d9 commit 26a7de3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions examples/Emulator/GaussianProcess/plot_GP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ if !isdir(output_directory)
end

#create the machine learning tools: Gaussian Process
gppackage = GPJL()
gppackage = SKLJL()
pred_type = YType()
gaussian_process = GaussianProcess(gppackage, noise_learn = true)
gaussian_process = GaussianProcess(gppackage, noise_learn = false)

# Generate training data (x-y pairs, where x ∈ ℝ ᵖ, y ∈ ℝ ᵈ)
# x = [x1, x2]: inputs/predictors/features/parameters
Expand All @@ -92,7 +92,7 @@ gx[2, :] = g2x

# Add noise η
μ = zeros(d)
Σ = 0.1 * [[0.8, 0.0] [0.0, 0.5]] # d x d
Σ = 0.1 * [[0.8, 0.1] [0.1, 0.5]] # d x d
noise_samples = rand(MvNormal(μ, Σ), n)
# y = G(x) + η
Y = gx .+ noise_samples
Expand Down Expand Up @@ -182,9 +182,9 @@ println("GP trained")

# Plot mean and variance of the predicted observables y1 and y2
# For this, we generate test points on a x1-x2 grid.
n_pts = 50
x1 = range(0.0, stop = 2 * π, length = n_pts)
x2 = range(0.0, stop = 2 * π, length = n_pts)
n_pts = 200
x1 = range(0.0, stop = (4.0/5.0) * 2 * π, length = n_pts)
x2 = range(0.0, stop = (4.0/5.0) * 2 * π, length = n_pts)
X1, X2 = meshgrid(x1, x2)
# Input for predict has to be of size N_samples x input_dim
inputs = permutedims(hcat(X1[:], X2[:]), (2, 1))
Expand Down
6 changes: 3 additions & 3 deletions examples/Emulator/RandomFeature/optimize_and_plot_RF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ n_features = 200

# hyperparameter prior
μ_l = 5.0
σ_l = 10.0
σ_l = 5.0
prior_lengthscale = constrained_gaussian("lengthscale", μ_l, σ_l, 0.0, Inf, repeats = p)

srfi = ScalarRandomFeatureInterface(n_features,prior_lengthscale)
Expand All @@ -138,8 +138,8 @@ optimize_hyperparameters!(emulator) # although RF already optimized
# Plot mean and variance of the predicted observables y1 and y2
# For this, we generate test points on a x1-x2 grid.
n_pts = 200
x1 = range(0.0, stop = 2 * π, length = n_pts)
x2 = range(0.0, stop = 2 * π, length = n_pts)
x1 = range(0.0, stop = 4.0/5.0* 2 * π, length = n_pts)
x2 = range(0.0, stop = 4.0/5.0* 2 * π, length = n_pts)
X1, X2 = meshgrid(x1, x2)
# Input for predict has to be of size N_samples x input_dim
inputs = permutedims(hcat(X1[:], X2[:]), (2, 1))
Expand Down

0 comments on commit 26a7de3

Please sign in to comment.