physbo 2.0.2__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. {physbo-2.0.2 → physbo-2.1.0}/PKG-INFO +2 -2
  2. {physbo-2.0.2 → physbo-2.1.0}/physbo/__init__.py +1 -1
  3. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/core/model.py +3 -1
  4. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/inf/exact.py +2 -0
  5. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/predictor.py +8 -3
  6. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/core/model.py +4 -2
  7. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/core/prior.py +5 -2
  8. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/cov/gauss.py +3 -1
  9. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/inf/exact.py +4 -1
  10. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/predictor.py +4 -1
  11. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/discrete/policy.py +35 -5
  12. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/discrete_multi/policy.py +41 -3
  13. {physbo-2.0.2 → physbo-2.1.0}/physbo.egg-info/PKG-INFO +2 -2
  14. {physbo-2.0.2 → physbo-2.1.0}/setup.cfg +1 -1
  15. {physbo-2.0.2 → physbo-2.1.0}/README.md +0 -0
  16. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/__init__.py +0 -0
  17. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/basis/__init__.py +0 -0
  18. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/basis/fourier.py +0 -0
  19. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/core/__init__.py +0 -0
  20. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/inf/__init__.py +0 -0
  21. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/lik/__init__.py +0 -0
  22. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/lik/_src/__init__.py +0 -0
  23. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/lik/_src/cov.py +0 -0
  24. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/lik/gauss.py +0 -0
  25. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/lik/linear.py +0 -0
  26. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/prior/__init__.py +0 -0
  27. {physbo-2.0.2 → physbo-2.1.0}/physbo/blm/prior/gauss.py +0 -0
  28. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/__init__.py +0 -0
  29. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/core/__init__.py +0 -0
  30. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/core/learning.py +0 -0
  31. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/cov/__init__.py +0 -0
  32. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/cov/_src/__init__.py +0 -0
  33. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/cov/_src/enhance_gauss.pyx +0 -0
  34. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/inf/__init__.py +0 -0
  35. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/lik/__init__.py +0 -0
  36. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/lik/gauss.py +0 -0
  37. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/mean/__init__.py +0 -0
  38. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/mean/const.py +0 -0
  39. {physbo-2.0.2 → physbo-2.1.0}/physbo/gp/mean/zero.py +0 -0
  40. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/__init__.py +0 -0
  41. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/_src/__init__.py +0 -0
  42. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/_src/cholupdate.pyx +0 -0
  43. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/_src/diagAB.pyx +0 -0
  44. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/_src/logsumexp.pyx +0 -0
  45. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/_src/traceAB.pyx +0 -0
  46. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/centering.py +0 -0
  47. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/gauss_elim.py +0 -0
  48. {physbo-2.0.2 → physbo-2.1.0}/physbo/misc/set_config.py +0 -0
  49. {physbo-2.0.2 → physbo-2.1.0}/physbo/opt/__init__.py +0 -0
  50. {physbo-2.0.2 → physbo-2.1.0}/physbo/opt/adam.py +0 -0
  51. {physbo-2.0.2 → physbo-2.1.0}/physbo/predictor.py +0 -0
  52. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/__init__.py +0 -0
  53. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/discrete/__init__.py +0 -0
  54. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/discrete/results.py +0 -0
  55. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/discrete_multi/__init__.py +0 -0
  56. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/discrete_multi/results.py +0 -0
  57. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/pareto.py +0 -0
  58. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/score.py +0 -0
  59. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/score_multi.py +0 -0
  60. {physbo-2.0.2 → physbo-2.1.0}/physbo/search/utility.py +0 -0
  61. {physbo-2.0.2 → physbo-2.1.0}/physbo/variable.py +0 -0
  62. {physbo-2.0.2 → physbo-2.1.0}/physbo.egg-info/SOURCES.txt +0 -0
  63. {physbo-2.0.2 → physbo-2.1.0}/physbo.egg-info/dependency_links.txt +0 -0
  64. {physbo-2.0.2 → physbo-2.1.0}/physbo.egg-info/not-zip-safe +0 -0
  65. {physbo-2.0.2 → physbo-2.1.0}/physbo.egg-info/requires.txt +0 -0
  66. {physbo-2.0.2 → physbo-2.1.0}/physbo.egg-info/top_level.txt +0 -0
  67. {physbo-2.0.2 → physbo-2.1.0}/pyproject.toml +0 -0
  68. {physbo-2.0.2 → physbo-2.1.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: physbo
3
- Version: 2.0.2
3
+ Version: 2.1.0
4
4
  Summary: optimization tool for PHYSics based on Bayesian Optimization
5
5
  Home-page: https://github.com/issp-center-dev/PHYSBO
6
6
  Author: PHYSBO developers
@@ -14,4 +14,4 @@ from . import predictor
14
14
  from .predictor import base_predictor
15
15
  from .variable import variable
16
16
 
17
- __version__ = "2.0.2"
17
+ __version__ = "2.1.0"
@@ -218,13 +218,15 @@ class model:
218
218
  Returns
219
219
  =======
220
220
  numpy.ndarray
221
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
222
+ where num_points is the number of points in X.
221
223
 
222
224
  See also
223
225
  ========
224
226
  physbo.blm.inf.exact.get_post_fcov
225
227
  """
226
228
  if self.method == "exact":
227
- fcov = inf.exact.get_post_fcov(self, X, Psi, diag=True)
229
+ fcov = inf.exact.get_post_fcov(self, X, Psi, diag=diag)
228
230
  else:
229
231
  pass
230
232
  return fcov
@@ -170,6 +170,8 @@ def get_post_fcov(blm, X, Psi=None, diag=True):
170
170
  Returns
171
171
  =======
172
172
  numpy.ndarray
173
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
174
+ where num_points is the number of points in X.
173
175
  """
174
176
  if Psi is None:
175
177
  Psi = blm.lik.linear.basis.get_basis(X)
@@ -101,12 +101,14 @@ class predictor(physbo.predictor.base_predictor):
101
101
  Returns
102
102
  =======
103
103
  numpy.ndarray
104
+ Returned shape is (num_points),
105
+ where num_points is the number of points in test.
104
106
  """
105
107
  if self.blm.stats is None:
106
108
  self.prepare(training)
107
109
  return self.blm.get_post_fmean(test.X, test.Z)
108
110
 
109
- def get_post_fcov(self, training, test):
111
+ def get_post_fcov(self, training, test, diag=True):
110
112
  """
111
113
  calculates posterior variance-covariance matrix of model
112
114
 
@@ -116,14 +118,17 @@ class predictor(physbo.predictor.base_predictor):
116
118
  training dataset. If already trained, the model does not use this.
117
119
  test: physbo.variable
118
120
  inputs
119
-
121
+ diag: bool
122
+ If true, only variances (diagonal elements) are returned.
120
123
  Returns
121
124
  =======
122
125
  numpy.ndarray
126
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
127
+ where num_points is the number of points in test.
123
128
  """
124
129
  if self.blm.stats is None:
125
130
  self.prepare(training)
126
- return self.blm.get_post_fcov(test.X, test.Z)
131
+ return self.blm.get_post_fcov(test.X, test.Z, diag)
127
132
 
128
133
  def get_post_params(self, training, test):
129
134
  """
@@ -269,11 +269,13 @@ class model:
269
269
  params: numpy.ndarray
270
270
  Parameters
271
271
  diag: bool
272
- If X is the diagonalization matrix, true.
272
+ If true, only variances (diagonal elements) are returned.
273
273
 
274
274
  Returns
275
275
  -------
276
- physbo.gp.inf.exact.get_post_fcov
276
+ numpy.ndarray
277
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
278
+ where num_points is the number of points in X.
277
279
 
278
280
  """
279
281
  if params is None:
@@ -19,7 +19,7 @@ class prior:
19
19
  ----------
20
20
  mean: numpy.ndarray
21
21
  mean values of prior
22
- cov: numpy.ndarray
22
+ cov: physbo.gp.cov.gauss
23
23
  covariance matrix of priors
24
24
  """
25
25
  self.mean = mean
@@ -94,10 +94,13 @@ class prior:
94
94
  params: numpy.ndarray
95
95
  Parameters.
96
96
  diag: bool
97
- If X is the diagonalization matrix, true.
97
+ If true, only variances (diagonal elements) are returned.
98
+
98
99
  Returns
99
100
  -------
100
101
  numpy.ndarray
102
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
103
+ where num_points is the number of points in X.
101
104
  """
102
105
  if params is None:
103
106
  params = np.copy(self.params)
@@ -149,12 +149,14 @@ class gauss:
149
149
  Parameters
150
150
 
151
151
  diag: bool
152
- If X is the diagonalization matrix, true.
152
+ If true, only variances (diagonal elements) are returned.
153
153
 
154
154
  Returns
155
155
  -------
156
156
  G: numpy.ndarray
157
157
  covariant matrix
158
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
159
+ where num_points is the number of points in X.
158
160
  """
159
161
  params, width, scale = self.prepare(params)
160
162
  scale2 = scale**2
@@ -203,10 +203,13 @@ def get_post_fcov(gp, X, Z, params=None, diag=True):
203
203
  params: numpy.ndarray
204
204
  Parameters.
205
205
  diag: bool
206
- If X is the diagonalization matrix, true.
206
+ If true, only variances (diagonal elements) are returned.
207
+
207
208
  Returns
208
209
  -------
209
210
  numpy.ndarray
211
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
212
+ where num_points is the number of points in X.
210
213
  """
211
214
 
212
215
  lik_params, prior_params = gp.decomp_params(params)
@@ -115,10 +115,13 @@ class predictor(physbo.predictor.base_predictor):
115
115
  test: physbo.variable
116
116
  inputs
117
117
  diag: bool
118
- Diagonlization flag in physbo.exact.get_post_fcov function.
118
+ If true, only variances (diagonal elements) are returned.
119
+
119
120
  Returns
120
121
  -------
121
122
  numpy.ndarray
123
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false,
124
+ where num_points is the number of points in test.
122
125
 
123
126
  """
124
127
  if self.model.stats is None:
@@ -348,7 +348,21 @@ class policy:
348
348
  print(" before calling {}.".format(method_name))
349
349
 
350
350
  def get_post_fmean(self, xs):
351
- """Calculate mean value of predictor (post distribution)"""
351
+ """
352
+ Calculate mean value of predictor (post distribution)
353
+
354
+ Parameters
355
+ ----------
356
+ xs: physbo.variable or np.ndarray
357
+ input parameters to calculate mean value
358
+ shape is (num_points, num_parameters)
359
+
360
+ Returns
361
+ -------
362
+ fmean: numpy.ndarray
363
+ Mean value of the post distribution.
364
+ Returned shape is (num_points).
365
+ """
352
366
  X = self._make_variable_X(xs)
353
367
  if self.predictor is None:
354
368
  self._warn_no_predictor("get_post_fmean()")
@@ -360,18 +374,34 @@ class policy:
360
374
  self._update_predictor()
361
375
  return self.predictor.get_post_fmean(self.training, X)
362
376
 
363
- def get_post_fcov(self, xs):
364
- """Calculate covariance of predictor (post distribution)"""
377
+ def get_post_fcov(self, xs, diag=True):
378
+ """
379
+ Calculate covariance of predictor (post distribution)
380
+
381
+ Parameters
382
+ ----------
383
+ xs: physbo.variable or np.ndarray
384
+ input parameters to calculate covariance
385
+ shape is (num_points, num_parameters)
386
+ diag: bool
387
+ If true, only variances (diagonal elements) are returned.
388
+
389
+ Returns
390
+ -------
391
+ fcov: numpy.ndarray
392
+ Covariance matrix of the post distribution.
393
+ Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false.
394
+ """
365
395
  X = self._make_variable_X(xs)
366
396
  if self.predictor is None:
367
397
  self._warn_no_predictor("get_post_fcov()")
368
398
  predictor = gp_predictor(self.config)
369
399
  predictor.fit(self.training, 0)
370
400
  predictor.prepare(self.training)
371
- return predictor.get_post_fcov(self.training, X)
401
+ return predictor.get_post_fcov(self.training, X, diag)
372
402
  else:
373
403
  self._update_predictor()
374
- return self.predictor.get_post_fcov(self.training, X)
404
+ return self.predictor.get_post_fcov(self.training, X, diag)
375
405
 
376
406
  def get_score(
377
407
  self,
@@ -294,6 +294,23 @@ class policy(discrete.policy):
294
294
  return np.array(chosen_actions)
295
295
 
296
296
  def get_post_fmean(self, xs):
297
+ """
298
+ Calculate mean value of predictors (post distribution)
299
+
300
+ Parameters
301
+ ----------
302
+ xs: physbo.variable or np.ndarray
303
+ input parameters to calculate covariance
304
+ shape is (num_points, num_parameters)
305
+ diag: bool
306
+ If true, only variances (diagonal elements) are returned.
307
+
308
+ Returns
309
+ -------
310
+ fcov: numpy.ndarray
311
+ Covariance matrix of the post distribution.
312
+ Returned shape is (num_points, num_objectives).
313
+ """
297
314
  if self.predictor_list == [None] * self.num_objectives:
298
315
  self._warn_no_predictor("get_post_fmean()")
299
316
  predictor_list = []
@@ -312,7 +329,24 @@ class policy(discrete.policy):
312
329
  ]
313
330
  return np.array(fmean).T
314
331
 
315
- def get_post_fcov(self, xs):
332
+ def get_post_fcov(self, xs, diag=True):
333
+ """
334
+ Calculate covariance of predictors (post distribution)
335
+
336
+ Parameters
337
+ ----------
338
+ xs: physbo.variable or np.ndarray
339
+ input parameters to calculate covariance
340
+ shape is (num_points, num_parameters)
341
+ diag: bool
342
+ If true, only variances (diagonal elements) are returned.
343
+
344
+ Returns
345
+ -------
346
+ fcov: numpy.ndarray
347
+ Covariance matrix of the post distribution.
348
+ Returned shape is (num_points, num_objectives) if diag=true, (num_points, num_points, num_objectives) if diag=false.
349
+ """
316
350
  if self.predictor_list == [None] * self.num_objectives:
317
351
  self._warn_no_predictor("get_post_fcov()")
318
352
  predictor_list = []
@@ -326,10 +360,14 @@ class policy(discrete.policy):
326
360
  predictor_list = self.predictor_list[:]
327
361
  X = self._make_variable_X(xs)
328
362
  fcov = [
329
- predictor.get_post_fcov(training, X)
363
+ predictor.get_post_fcov(training, X, diag)
330
364
  for predictor, training in zip(predictor_list, self.training_list)
331
365
  ]
332
- return np.array(fcov).T
366
+ arr = np.array(fcov)
367
+ if diag:
368
+ return arr.T
369
+ else:
370
+ return np.einsum("nij->ijn", arr)
333
371
 
334
372
  def get_score(
335
373
  self,
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: physbo
3
- Version: 2.0.2
3
+ Version: 2.1.0
4
4
  Summary: optimization tool for PHYSics based on Bayesian Optimization
5
5
  Home-page: https://github.com/issp-center-dev/PHYSBO
6
6
  Author: PHYSBO developers
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = physbo
3
- version = 2.0.2
3
+ version = 2.1.0
4
4
  description = optimization tool for PHYSics based on Bayesian Optimization
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes