Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add exponentiation of a covariance function with a scalar #3852

Merged
merged 3 commits into from
Apr 6, 2020

Conversation

tirthasheshpatel
Copy link
Contributor

This PR adds functionality to the pm.gp.cov module. Now, a covariance function can be exponentiated with a scalar.

Changes:

  • Add a Exponentiated class for kernels that are exponentiated with a scalar.
  • Add an interface __pow__ in covariance base class to support exponentiation for all the covariance functions
  • Add tests for exponentiated kernels.

@codecov
Copy link

codecov bot commented Mar 25, 2020

Codecov Report

Merging #3852 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3852      +/-   ##
==========================================
+ Coverage   90.45%   90.47%   +0.02%     
==========================================
  Files         133      135       +2     
  Lines       20564    21246     +682     
==========================================
+ Hits        18601    19223     +622     
- Misses       1963     2023      +60
Impacted Files Coverage Δ
pymc3/tests/test_gp.py 99.88% <100%> (ø) ⬆️
pymc3/gp/cov.py 98.21% <100%> (+0.1%) ⬆️
pymc3/step_methods/hmc/base_hmc.py 93.45% <0%> (-0.94%) ⬇️
pymc3/distributions/timeseries.py 70.89% <0%> (-0.76%) ⬇️
pymc3/distributions/continuous.py 79.69% <0%> (-0.76%) ⬇️
pymc3/tests/test_distributions_random.py 98.5% <0%> (-0.63%) ⬇️
pymc3/distributions/mixture.py 87.27% <0%> (-0.35%) ⬇️
pymc3/distributions/distribution.py 94.56% <0%> (-0.18%) ⬇️
pymc3/tests/test_shared.py 100% <0%> (ø) ⬆️
pymc3/tests/test_data_container.py 100% <0%> (ø) ⬆️
... and 13 more

@tirthasheshpatel
Copy link
Contributor Author

Why have the travis tests not started yet?

@twiecki twiecki requested a review from bwengals March 28, 2020 22:37
pymc3/gp/cov.py Outdated
@@ -34,6 +36,7 @@
"Coregion",
"ScaledCov",
"Kron",
"Exponentiated",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Exponentiated isn't necessarily user-facing because you added __pow__, it probably shouldn't be included in __all__.

pymc3/gp/cov.py Outdated
@@ -117,6 +136,19 @@ def __array_wrap__(self, result):
raise RuntimeError


class Exponentiated(Covariance):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this down to be near Add and Prod? (very small nitpick, since it's more like a Combination covariance than a base covariance)

Copy link
Contributor

@bwengals bwengals left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Maybe you could add a very brief example to the docs so this functionality can be discovered? https://docs.pymc.io/notebooks/GP-MeansAndCovs.html

Tests look perfect.

@tirthasheshpatel
Copy link
Contributor Author

Thanks for the review @bwengals. Noticed that there were no examples exclusively for combinations of kernels so I went ahead and added all of them. I hope they are good to go!

@bwengals
Copy link
Contributor

bwengals commented Apr 5, 2020

Nice, yeah I support merging now

@twiecki twiecki merged commit 70218bf into pymc-devs:master Apr 6, 2020
@twiecki
Copy link
Member

twiecki commented Apr 6, 2020

Thanks @tirthasheshpatel!

@tirthasheshpatel tirthasheshpatel deleted the gp/cov/exponentiation branch April 6, 2020 14:24
@tirthasheshpatel
Copy link
Contributor Author

Thanks @bwengals for reviewing this!
You're welcome @twiecki.

tirthasheshpatel added a commit to tirthasheshpatel/pymc3 that referenced this pull request Apr 6, 2020
pymc-devs#3852 adds the new feature to the V3.8 changelog while it should go in the V3.9 changelog.
twiecki pushed a commit that referenced this pull request Apr 6, 2020
* move change from V3.8 to V3.9

#3852 adds the new feature to the V3.8 changelog while it should go in the V3.9 changelog.

* fix small typo

* move the change a little down in the changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants