-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
HSGP improvements #7335
HSGP improvements #7335
Conversation
The failing test on Windows isn't related to these changes 🤷♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Just some minor suggestions :)
Maybe I missed but I missed, but is there a test where we verify the mean sustraction works as expected in the out-of-sample case?
pymc/gp/hsgp_approx.py
Outdated
c = max(a1 * (lengthscale_range[1] / S), 1.2) | ||
m = int(a2 * c / (lengthscale_range[0] / S)) | ||
|
||
return m, c, S |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion: what about returning a namedtuple so that we do not depend on the special order of the parameters? something like
HSGPParam = namedtuple('HSGPParam ', ['m', 'c', 'S'])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally think this is over-engineering, because introducing a new HSGPParam
type serves no purpose other than to compensate for a perceived defect with the Python language. I think it was clearer before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinion here. I just mess up indices so often that I prefer going safe with names instead 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah but I would just expect people to unpack like, m, c, S = ...
.
Which makes me think it might make sense (in this or a later PR) to slightly refactor this so that there's a different function,
S = calc_X_radius(X) # or calc_halfwidth or something
that could be used later where _X_mean
was replaced. Then this function only needs to return m
and c
and not also S
, since that's handled now.
Thanks @juanitorduz ! I just pushed all the changes.
Good point. Added it |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7335 +/- ##
==========================================
- Coverage 92.49% 92.37% -0.13%
==========================================
Files 102 102
Lines 17173 17208 +35
==========================================
+ Hits 15885 15896 +11
- Misses 1288 1312 +24
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just left a comment just to make sure its intentional and not a typo ;)
Looks like there's one failing test mentioning assert np.allclose(
gp._X_mean, original_mean
> ), "gp._X_mean should not change after updating data for out-of-sample predictions."
E AttributeError: 'HSGP' object has no attribute '_X_mean' |
Closes #7240
Working on this in concert with @bwengals for this example
L
X
values under the hood, instead of requiring it from usersprior_linearized
withm
andc
instead of onlym
andL
parametrization
is not documentedcoords
to HSGP for thebeta
coefficients._m_star
more accessible / user friendly (make a property with no leading underscore so existing code doesn't break), document it, and fix example inprior_linearized
docstring.tl=np
. It's subtly wrong when calculating the eigen stuff and its not used anywhere.approx_params
function tohsgp_approx
fileType of change
📚 Documentation preview 📚: https://pymc--7335.org.readthedocs.build/en/7335/