-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Passing pd.Series
to gp.Marginal().marginal_likelihood
gives cryptic error
#5053
Comments
pd.Series
to gp.Latent().marginal_likelihood
gives cryptic errorpd.Series
to gp.Marginal().marginal_likelihood
gives cryptic error
I would like to take a stab at it.
If we want the interface and usage experience to be similar to scikit, I would suggest going with Automatically converting it since scikit works quite nicely with pandas as an interface and also just to keep I was thinking of a basic check like if isinstance(y, pd.Series):
self.y = y.to_numpy() pandas reference https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.to_numpy.html#pandas.Series.to_numpy P.S. in the description you are still referring to Latent, I assume you mean Marginal given the heading change also Latent not having the y parameter.
|
Hi @heaven00 |
curious to know why would this check be required on kwargs too? because I wasn't thinking about checking kwargs at all, since they are just passed down directly to other objects like the Also, when you mention other classes how big is the scope of the list of classes? if its a lot we can add an exception within the def make_setter(name):
def setter(self, val):
if isinstance(val, pd.Series):
val = val.to_numpy()
setattr(self, name, val) code: https://github.com/pymc-devs/pymc/blob/main/pymc/gp/util.py#L126 I did a quick check and the |
I mean the parameters from the method signatures in general, so also Be sure to check out #5055. In order to avoid git conflicts it might be best to do a PR into that branch, or to keep the PR as focused as possible. |
I just confirmed that this problem no longer persists on Probably due to #5920. with pm.Model() as pmodel:
x = np.arange(10)
y = np.sin(x)
gp = pm.gp.Marginal(
cov_func=pm.gp.cov.ExpQuad(1, ls=pm.HalfNormal("ls"))
)
gp.marginal_likelihood(
"L",
X=x[:, None],
y=pd.Series(y),
noise=1
) |
Description of your problem
The
y
argument toLatent.marginal_likelihood
is just forwarded intoself.y
.Later in the workflow, when attempting to make conditional observations this leads to a traceback that does not immediately make it obvious what the problem was.
Converting the
y
to a numpy array orpm.Data
container solves the problem.Traceback from my debugging
Possible solutions
y
is a numpy array or tensorVersions and main components
main
The text was updated successfully, but these errors were encountered: