Skip to content

Commit

Permalink
v4 refactor for GP module (#5055)
Browse files Browse the repository at this point in the history
* np.int -> int, fix np DepricationWarning

* remove shape arg from non-kron implementations, TODO for is_observed in Marginal, mark for deprecation

* np.int -> int in gp/util.py

* force all mean_func, cov_func args to GP constructors to be required kwargs (often default zero mean_func is used)

* fix predictt functions, rename to _predict_at.  because theano -> aesara

* fix TP tests, force mean_func, cov_func to be req kwarg

* fix TP reparameterization to sample studentt instead of chi2/norm

* change naming shape->size where appropriate

* add deprecation warning for is_observed

* add jitter arg for covs headed for cholesky decomps, previously fixed at 1e-6.  add deprecation warning for is_observed arg

* clean up trivial aesara.function usage to .eval() instead

* fix gp.util.replace_with_values to handle case with no symbolic values, .eval() works

* jitter=0 for conditonals/predicts, fix replace_with_values calls

* fix more tests

- use model.logp instead of variable.logp
- set req kwargs cov_func and mean_func
- fix weirdly small scale on some input X, y
- move predict calls into model block
- the two kron models outstanding

* black stuff

* small fixes to get kronlatent and kronmarginal to pass

* remove leftover prints

* dep warning -> future warning

* roll back mkl and mkl-service version

* fix precommit

* remove old DeprecationWarning

* improve tests

cleanup gp.util.replace_with_values and add docstrings

* fix pre-commit issue

* fix precommit on cov.py

* fix comment

* dont force blas version in windows dev enviornment (roll back changes)

* update release notes

* add removed ... line from release notes

* add link to PR

* remove is_observed usage from TestMarginalVsLatent

* remove is_observed usage from TestMarginalVsMarginalSparse

* Update RELEASE-NOTES.md

Co-authored-by: Thomas Wiecki <thomas.wiecki@gmail.com>
  • Loading branch information
bwengals and twiecki committed Nov 21, 2021
1 parent d74537c commit 64c1464
Show file tree
Hide file tree
Showing 6 changed files with 498 additions and 329 deletions.
9 changes: 8 additions & 1 deletion RELEASE-NOTES.md
Expand Up @@ -45,9 +45,16 @@ All of the above apply to:
- Changes to the BART implementation:
- A BART variable can be combined with other random variables. The `inv_link` argument has been removed (see [4914](https://github.com/pymc-devs/pymc3/pull/4914)).
- Moved BART to its own module (see [5058](https://github.com/pymc-devs/pymc3/pull/5058)).
- Changes to the Gaussian Process (GP) submodule (see [5055](https://github.com/pymc-devs/pymc/pull/5055)):
- For all implementations, `gp.Latent`, `gp.Marginal` etc., `cov_func` and `mean_func` are required kwargs.
- In Windows test conda environment the `mkl` version is fixed to verison 2020.4, and `mkl-service` is fixed to `2.3.0`. This was required for `gp.MarginalKron` to function properly.
- `gp.MvStudentT` uses rotated samples from `StudentT` directly now, instead of sampling from `pm.Chi2` and then from `pm.Normal`.
- The "jitter" parameter, or the diagonal noise term added to Gram matrices such that the Cholesky is numerically stable, is now exposed to the user instead of hard-coded. See the function `gp.util.stabilize`.
- The `is_observed` arguement for `gp.Marginal*` implementations has been deprecated.
- In the gp.utils file, the `kmeans_inducing_points` function now passes through `kmeans_kwargs` to scipy's k-means function.
- The function `replace_with_values` function has been added to `gp.utils`.
- ...


### Expected breaks
+ New API was already available in `v3`.
+ Old API had deprecation warnings since at least `3.11.0` (2021-01).
Expand Down
3 changes: 2 additions & 1 deletion conda-envs/windows-environment-test-py38.yml
Expand Up @@ -12,7 +12,8 @@ dependencies:
- fastprogress>=0.2.0
- h5py>=2.7
- libpython
- mkl-service
- mkl==2020.4
- mkl-service==2.3.0
- m2w64-toolchain
- numpy>=1.15.0
- pandas
Expand Down
6 changes: 4 additions & 2 deletions pymc/gp/cov.py
Expand Up @@ -64,7 +64,7 @@ def __init__(self, input_dim, active_dims=None):
if active_dims is None:
self.active_dims = np.arange(input_dim)
else:
self.active_dims = np.asarray(active_dims, np.int)
self.active_dims = np.asarray(active_dims, int)

def __call__(self, X, Xs=None, diag=False):
r"""
Expand Down Expand Up @@ -152,7 +152,9 @@ def __array_wrap__(self, result):
elif isinstance(result[0][0], Prod):
return result[0][0].factor_list[0] * A
else:
raise RuntimeError
raise TypeError(
f"Unknown Covariance combination type {result[0][0]}. Known types are `Add` or `Prod`."
)


class Combination(Covariance):
Expand Down

0 comments on commit 64c1464

Please sign in to comment.