Skip to content

Commit 6d422b7

Browse files
committed
Make encoder_kwargs itself a kwarg
1 parent 7c78765 commit 6d422b7

20 files changed

Lines changed: 111 additions & 55 deletions

File tree

docs/src/data_processing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ complex_schedule = [
2828
In this (rather unrealistic) chain;
2929
1. The inputs are decorrelated with their sample mean and covariance (and projected to low dimensional subspace if necessary) i.e PCA
3030
2. The scaled inputs are then subject to a "Robust" univariate scaling, mapping 1st-3rd quartiles to [0,1]
31-
3. The outputs are decorrelated using an "output structure matrix" (provided to the emulator in the `encoder_kwargs` parameter, e.g. as `(; obs_cov_noise =)`). Furthermore, apply a dimension-reduction to a space that retains 95% of the total variance.
31+
3. The outputs are decorrelated using an "output structure matrix" (provided to the emulator in the `encoder_kwargs` keyword parameter, e.g. as `(; obs_cov_noise =)`). Furthermore, apply a dimension-reduction to a space that retains 95% of the total variance.
3232
4. In the reduced input-output space, a canonical correlation analysis is performed. Data is oriented and reduced (if necessary) maximize the joint correlation between inputs and outputs.
3333

3434
!!! note "Default Encoder schedule"
@@ -44,9 +44,9 @@ The schedule is then passed into the Emulator, along with the data and desired s
4444
```julia
4545
emulator = Emulator(
4646
machine_learning_tool,
47-
input_output_pairs,
48-
(; obs_noise_cov = obs_noise_cov);
47+
input_output_pairs;
4948
encoder_schedule = complex_schedule,
49+
encoder_kwargs = (; obs_noise_cov = obs_noise_cov),
5050
)
5151
```
5252
Note that due to the item `(decorrelate_structure_mat(retain_var=0.95), "out")` in the schedule, we must provide an output structure matrix. In this case, we provide `obs_noise_cov`.

docs/src/emulate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Wrapping a predefined machine learning tool, e.g. a Gaussian process `gauss_proc
1616
```julia
1717
emulator = Emulator(
1818
gauss_proc,
19-
input_output_pairs,
20-
(; obs_noise_cov = Γy); # optional arguments after this
19+
input_output_pairs; # optional arguments after this
2120
encoder_schedule = encoder_schedule,
21+
encoder_kwargs = (; obs_noise_cov = Γy),
2222
)
2323
```
2424
The optional arguments above relate to the data processing, which is described [here](@ref data-proc)

examples/Cloudy/Cloudy_emulate_sample.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ function main()
171171
# build emulator
172172
emulator = Emulator(
173173
mlt,
174-
input_output_pairs,
175-
(; prior_cov = cov(priors), obs_noise_cov = Γy);
174+
input_output_pairs;
176175
encoder_schedule = encoder_schedule,
176+
encoder_kwargs = (; prior_cov = cov(priors), obs_noise_cov = Γy),
177177
)
178178

179179
optimize_hyperparameters!(emulator)

examples/Darcy/emulate_sample.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ function main()
9292
@save joinpath(data_save_directory, "input_output_pairs.jld2") input_output_pairs
9393

9494
# data processing
95-
encoding_schedule = (decorrelate_structure_mat(), "in_and_out")
95+
encoder_schedule = (decorrelate_structure_mat(), "in_and_out")
9696

9797
emulator = Emulator(
9898
mlt,
99-
input_output_pairs,
100-
(; prior_cov = cov(prior), obs_noise_cov = Γy);
101-
encoding_schedule = encoding_schedule,
99+
input_output_pairs;
100+
encoder_schedule = encoder_schedule,
101+
encoder_kwargs = (; prior_cov = cov(prior), obs_noise_cov = Γy),
102102
)
103103
optimize_hyperparameters!(emulator, kernbounds = [fill(-1e2, n_params + 1), fill(1e2, n_params + 1)])
104104

examples/EDMF_data/emulator-rank-test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ function main()
257257
emulator = Emulator(
258258
mlt,
259259
train_pairs,
260-
(; prior_cov = cov(prior), obs_noise_cov = truth_cov);
261260
encoder_schedule = encoder_schedule,
261+
encoder_kwargs = (; prior_cov = cov(prior), obs_noise_cov = truth_cov),
262262
)
263263

264264
# Optimize the GP hyperparameters for better fit

examples/EDMF_data/uq_for_edmf.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ function main()
231231
emulator = Emulator(
232232
mlt,
233233
input_output_pairs,
234-
(; prior_cov = cov(prior), obs_noise_cov = truth_cov);
235234
encoder_schedule = encoder_schedule,
235+
encoder_kwargs = (; prior_cov = cov(prior), obs_noise_cov = truth_cov),
236236
)
237237

238238
# Optimize the GP hyperparameters for better fit

examples/Emulator/G-function/emulate-test-n-features.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ function main()
151151

152152
# Emulate
153153
ttt[f_idx, rep_idx] = @elapsed begin
154-
emulator =
155-
Emulator(mlt, iopairs, (; obs_noise_cov = Γ * I); encoder_schedule = deepcopy(encoder_schedule))
154+
emulator = Emulator(
155+
mlt,
156+
iopairs;
157+
encoder_schedule = deepcopy(encoder_schedule),
158+
encoder_kwargs = (; obs_noise_cov = Γ * I),
159+
)
156160
optimize_hyperparameters!(emulator)
157161
end
158162

examples/Emulator/G-function/emulate.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ function main()
142142

143143
# Emulate
144144
times[rep_idx] = @elapsed begin
145-
emulator = Emulator(mlt, iopairs, (; obs_noise_cov = Γ * I); encoder_schedule = deepcopy(encoder_schedule))
145+
emulator = Emulator(
146+
mlt,
147+
iopairs;
148+
encoder_schedule = deepcopy(encoder_schedule),
149+
encoder_kwargs = (; obs_noise_cov = Γ * I),
150+
)
146151
optimize_hyperparameters!(emulator)
147152
end
148153

examples/Emulator/Ishigami/emulate.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ function main()
123123
end
124124

125125
# Emulate
126-
emulator = Emulator(mlt, iopairs, (; obs_noise_cov = Γ * I); encoder_schedule = deepcopy(encoder_schedule))
126+
emulator = Emulator(
127+
mlt,
128+
iopairs;
129+
encoder_schedule = deepcopy(encoder_schedule),
130+
encoder_kwargs = (; obs_noise_cov = Γ * I),
131+
)
127132
optimize_hyperparameters!(emulator)
128133

129134
# get EKP errors - just stored in "optimizer" box for now

examples/Emulator/L63/emulate.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,12 @@ function main()
215215
else
216216
encoder_schedule = (decorrelate_structure_mat(), "out")
217217
end
218-
emulator = Emulator(mlt, iopairs, (; obs_noise_cov = Γy); encoder_schedule = deepcopy(encoder_schedule))
218+
emulator = Emulator(
219+
mlt,
220+
iopairs;
221+
encoder_schedule = deepcopy(encoder_schedule),
222+
encoder_kwargs = (; obs_noise_cov = Γy),
223+
)
219224
optimize_hyperparameters!(emulator)
220225

221226
# diagnostics

0 commit comments

Comments
 (0)