Skip to content

Commit c2bb3a7

Browse files
authored
Merge pull request #51 from lbl-camera/feature/fvgp-4.8
Feature/fvgp 4.8
2 parents 539a8be + 735d902 commit c2bb3a7

13 files changed

Lines changed: 1334 additions & 807 deletions

docs/source/api/overview.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ To get to know gpCAM, check out the [examples](../examples/index.md), download t
2525
repository and look in `./tests`, or visit the project
2626
[website](https://gpcam.lbl.gov/).
2727

28+
## New in fvgp 4.8 (gpCAM 8.4)
29+
30+
Because the optimizers inherit from `fvgp.GP`, the following fvgp 4.8 additions are
31+
available directly on any `GPOptimizer`/`fvGPOptimizer` instance and are listed on the
32+
[gpOptimizer](gpOptimizer.md) / [fvgpOptimizer](fvgpOptimizer.md) pages:
33+
34+
- **Model-validation metrics**`mae`, `mape`, `msll`, `interval_score`, `mpiw`, and
35+
`coverage_curve` for quantifying predictive accuracy and calibration, plus
36+
`plot_observed_vs_predicted` for a quick diagnostic plot.
37+
- **New kernels**`bump` and `sle_kernel` (in addition to the existing library), all
38+
re-exported through `gpcam.kernels` and documented on the [Kernels](kernels.md) page.
39+
- **Linear-algebra modes** — the `linalg_mode` argument now accepts `CholInv`/`Inv`
40+
(the replacement for the removed `calc_inv` option) and preconditioned sparse solvers
41+
such as `sparseCGpre`/`sparseMINRESpre` for large gp2Scale problems.
42+
2843
## See Also
2944

3045
- [Repository](https://github.com/lbl-camera/gpCAM/)

examples/1dSingleTaskAcqFuncTest.ipynb

Lines changed: 410 additions & 199 deletions
Large diffs are not rendered by default.

examples/GPOptimizer_Minimal.ipynb

Lines changed: 67 additions & 18 deletions
Large diffs are not rendered by default.

examples/GPOptimizer_MultiTaskTest.ipynb

Lines changed: 81 additions & 96 deletions
Large diffs are not rendered by default.

examples/GPOptimizer_NonEuclideanInputSpaces.ipynb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
},
1414
{
1515
"cell_type": "code",
16-
"execution_count": 1,
16+
"execution_count": 2,
1717
"id": "61c3f3bd",
1818
"metadata": {},
1919
"outputs": [],
2020
"source": [
2121
"# Install the newest version of gpcam\n",
22-
"#!pip install gpcam==8.3.5"
22+
"#!pip install gpcam==8.4.0"
2323
]
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 2,
27+
"execution_count": 3,
2828
"id": "b5399565",
2929
"metadata": {},
3030
"outputs": [],
@@ -39,25 +39,25 @@
3939
},
4040
{
4141
"cell_type": "code",
42-
"execution_count": 3,
42+
"execution_count": 4,
4343
"id": "b91e69d3",
4444
"metadata": {},
4545
"outputs": [
4646
{
4747
"name": "stderr",
4848
"output_type": "stream",
4949
"text": [
50-
"/home/marcus/VirtualEnvironments/gpcam_dev/lib/python3.11/site-packages/fvgp/gp.py:310: UserWarning: No noise function or measurement noise provided. Noise variances will be set to (0.01 * mean(|y_data|))^2.\n",
50+
"/home/marcus/Coding/fvGP/fvgp/gp.py:406: UserWarning: No noise function or measurement noise provided. Noise variances will be set to (0.01 * mean(|y_data|))^2.\n",
5151
" self.likelihood = GPlikelihood(self.data,\n"
5252
]
5353
},
5454
{
5555
"name": "stdout",
5656
"output_type": "stream",
5757
"text": [
58-
"hyperparameters: [49.31361296 26.90240104]\n",
59-
"prediction : 2.0046357760678624\n",
60-
"uncertainty: [0.97016186]\n"
58+
"hyperparameters: [38.94724232 36.39665454]\n",
59+
"prediction : 1.9934264485792332\n",
60+
"uncertainty: [0.64431805]\n"
6161
]
6262
}
6363
],
@@ -105,7 +105,7 @@
105105
},
106106
{
107107
"cell_type": "code",
108-
"execution_count": 4,
108+
"execution_count": 5,
109109
"id": "a5644ec5",
110110
"metadata": {},
111111
"outputs": [
@@ -116,11 +116,11 @@
116116
" ['who'],\n",
117117
" ['be'],\n",
118118
" ['it']], dtype='<U5'),\n",
119-
" 'f_a(x)': array([0.82710967, 0.8218738 , 0.65115158, 0.43813236]),\n",
119+
" 'f_a(x)': array([0.55032781, 0.54008504, 0.42359206, 0.29020021]),\n",
120120
" 'opt_obj': None}"
121121
]
122122
},
123-
"execution_count": 4,
123+
"execution_count": 5,
124124
"metadata": {},
125125
"output_type": "execute_result"
126126
}
@@ -140,7 +140,7 @@
140140
},
141141
{
142142
"cell_type": "code",
143-
"execution_count": 5,
143+
"execution_count": 6,
144144
"id": "f78b2e6b-68be-47f0-99db-82382eeb7944",
145145
"metadata": {},
146146
"outputs": [
@@ -166,7 +166,7 @@
166166
},
167167
{
168168
"cell_type": "code",
169-
"execution_count": 6,
169+
"execution_count": 7,
170170
"id": "401a8d86-6205-4944-b9ed-e0397172b03f",
171171
"metadata": {},
172172
"outputs": [
@@ -197,7 +197,7 @@
197197
},
198198
{
199199
"cell_type": "code",
200-
"execution_count": 7,
200+
"execution_count": 8,
201201
"id": "19bccdab-1444-4dc4-bb44-dd88340f541e",
202202
"metadata": {},
203203
"outputs": [],
@@ -235,7 +235,7 @@
235235
},
236236
{
237237
"cell_type": "code",
238-
"execution_count": 8,
238+
"execution_count": 9,
239239
"id": "a8b3c342-6829-42f7-bf9f-90cf3d9bf069",
240240
"metadata": {},
241241
"outputs": [
@@ -249,10 +249,10 @@
249249
{
250250
"data": {
251251
"text/plain": [
252-
"array([ 2.54827723, 15.05228436])"
252+
"array([0.12880405, 9.12339126])"
253253
]
254254
},
255-
"execution_count": 8,
255+
"execution_count": 9,
256256
"metadata": {},
257257
"output_type": "execute_result"
258258
}
@@ -261,7 +261,7 @@
261261
"my_gp2 = fvGPOptimizer(x_data,y_data,init_hyperparameters=np.ones((2)),\n",
262262
" kernel_function=kernel\n",
263263
" )\n",
264-
"print(\"Global Training in progress\")\n",
264+
"print(\"MCMC Training in progress\")\n",
265265
"#use the next two lines if kernel `mkernel` is used\n",
266266
"#if not a default deep kernel will be used that will set initi hyperparameters and bounds\n",
267267
"#hps_bounds = np.array([[0.001,10000.],[1.,1000.]])\n",
@@ -273,18 +273,18 @@
273273
},
274274
{
275275
"cell_type": "code",
276-
"execution_count": 9,
276+
"execution_count": 10,
277277
"id": "b94b089a-332b-4c31-9535-2adb8ecd6f7a",
278278
"metadata": {},
279279
"outputs": [
280280
{
281281
"data": {
282282
"text/plain": [
283283
"{'x': ['dwed', 'dwe'],\n",
284-
" 'm(x)': array([[0.25466475, 0.25466475, 0.25466475, 0.25466475],\n",
285-
" [0.29003775, 0.29003775, 0.29003775, 0.29003775]]),\n",
286-
" 'm(x)_flat': array([0.25466475, 0.29003775, 0.25466475, 0.29003775, 0.25466475,\n",
287-
" 0.29003775, 0.25466475, 0.29003775]),\n",
284+
" 'm(x)': array([[0.53874768, 0.53874768, 0.53874768, 0.53874768],\n",
285+
" [0.57401672, 0.57401672, 0.57401672, 0.57401672]]),\n",
286+
" 'm(x)_flat': array([0.53874768, 0.57401672, 0.53874768, 0.57401672, 0.53874768,\n",
287+
" 0.57401672, 0.53874768, 0.57401672]),\n",
288288
" 'x_pred': [['dwed', np.int64(0)],\n",
289289
" ['dwe', np.int64(0)],\n",
290290
" ['dwed', np.int64(1)],\n",
@@ -295,7 +295,7 @@
295295
" ['dwe', np.int64(3)]]}"
296296
]
297297
},
298-
"execution_count": 9,
298+
"execution_count": 10,
299299
"metadata": {},
300300
"output_type": "execute_result"
301301
}
@@ -307,7 +307,7 @@
307307
},
308308
{
309309
"cell_type": "code",
310-
"execution_count": 10,
310+
"execution_count": 11,
311311
"id": "0ca94f3f-452f-4173-a37b-22fae5ed9f19",
312312
"metadata": {},
313313
"outputs": [
@@ -318,11 +318,11 @@
318318
" ['who'],\n",
319319
" ['it'],\n",
320320
" ['be']], dtype='<U5'),\n",
321-
" 'f_a(x)': array([1.46161733, 0.72355182, 0.72355182, 0.28535747]),\n",
321+
" 'f_a(x)': array([0.17396565, 0.0962287 , 0.0962287 , 0.05897216]),\n",
322322
" 'opt_obj': None}"
323323
]
324324
},
325-
"execution_count": 10,
325+
"execution_count": 11,
326326
"metadata": {},
327327
"output_type": "execute_result"
328328
}
@@ -364,7 +364,7 @@
364364
"name": "python",
365365
"nbconvert_exporter": "python",
366366
"pygments_lexer": "ipython3",
367-
"version": "3.11.14"
367+
"version": "3.11.15"
368368
}
369369
},
370370
"nbformat": 4,

examples/GPOptimizer_Optimization.ipynb

Lines changed: 15 additions & 7 deletions
Large diffs are not rendered by default.

examples/GPOptimizer_SingleTaskTest.ipynb

Lines changed: 331 additions & 212 deletions
Large diffs are not rendered by default.

examples/GPOptimizer_gp2ScaleTest.ipynb

Lines changed: 25 additions & 38 deletions
Large diffs are not rendered by default.

gpcam/autonomous_experimenter.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,6 @@ class AutonomousExperimenterGP:
139139
newly suggested data points will be communicated. The default is False.
140140
compute_device : str, optional
141141
One of `cpu` or `gpu`, determines how linear algebra computations are executed. The default is `cpu`.
142-
calc_inv : bool, optional
143-
If True, the algorithm calculates and stores the inverse of the covariance
144-
matrix after each training or update of the dataset or hyperparameters,
145-
which makes computing the posterior covariance faster (3-10 times).
146-
For larger problems (>2000 data points), the use of inversion should be avoided due
147-
to computational instability and costs. The default is
148-
False. Note, the training will not use the
149-
inverse for stability reasons. Storing the inverse is
150-
a good option when the dataset is not too large and the posterior covariance is heavily used.
151-
Caution: this option, together with `append=True` in `tell()` will mean that the inverse of
152-
the covariance is updated, not recomputed, which can lead to instability.
153-
In application where data is appended many times, it is recommended to either turn
154-
`calc_inv` off, or to regularly force the recomputation of the inverse via `gp_rank_n_update` in
155-
`update_gp_data`.
156142
training_dask_client : distributed.client.Client, optional
157143
A Dask Distributed Client instance for distributed training. If None is provided, a new
158144
`dask.distributed.Client` instance is constructed.
@@ -198,11 +184,10 @@ def __init__(self,
198184
x_data=None, y_data=None, noise_variances=None, dataset=None,
199185
communicate_full_dataset=False,
200186
compute_device="cpu",
201-
calc_inv=False,
202187
training_dask_client=None,
203188
acq_func_opt_dask_client=None,
204189
gp2Scale=False,
205-
gp2Scale_dask_client=None,
190+
dask_client=None,
206191
gp2Scale_batch_size=10000,
207192
ram_economy=True,
208193
args=None
@@ -337,20 +322,6 @@ class AutonomousExperimenterFvGP(AutonomousExperimenterGP):
337322
newly suggested data points will be communicated. The default is False.
338323
compute_device : str, optional
339324
One of `cpu` or `gpu`, determines how linear algebra computations are executed. The default is `cpu`.
340-
calc_inv : bool, optional
341-
If True, the algorithm calculates and stores the inverse of the covariance
342-
matrix after each training or update of the dataset or hyperparameters,
343-
which makes computing the posterior covariance faster (3-10 times).
344-
For larger problems (>2000 data points), the use of inversion should be avoided due
345-
to computational instability and costs. The default is
346-
False. Note, the training will not use the
347-
inverse for stability reasons. Storing the inverse is
348-
a good option when the dataset is not too large and the posterior covariance is heavily used.
349-
Caution: this option, together with `append=True` in `tell()` will mean that the inverse of
350-
the covariance is updated, not recomputed, which can lead to instability.
351-
In application where data is appended many times, it is recommended to either turn
352-
`calc_inv` off, or to regularly force the recomputation of the inverse via `gp_rank_n_update` in
353-
`update_gp_data`.
354325
training_dask_client : distributed.client.Client, optional
355326
A Dask Distributed Client instance for distributed training. If None is provided, a new
356327
`dask.distributed.Client` instance is constructed.
@@ -396,11 +367,10 @@ def __init__(self,
396367
x_data=None, y_data=None, noise_variances=None, dataset=None,
397368
communicate_full_dataset=False,
398369
compute_device="cpu",
399-
calc_inv=False,
400370
training_dask_client=None,
401371
acq_func_opt_dask_client=None,
402372
gp2Scale=False,
403-
gp2Scale_dask_client=None,
373+
dask_client=None,
404374
gp2Scale_batch_size=10000,
405375
ram_economy=True,
406376
args=None

0 commit comments

Comments
 (0)