-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fix failing doctest #428
Comments
Calling |
|
Every time we call So yes, every time we call Does it makes more sense for calculating goodness of fit to be based on the expectation, |
I've tried changing the def score(self, X, y) -> pd.Series:
mu = self.predict(X)
mu = az.extract(mu, group="posterior_predictive", var_names="mu").T.values
return r2_score(y.flatten(), mu) If I run this import causalpy as cp
import numpy as np
import pymc as pm
from causalpy.pymc_models import PyMCModel
class MyToyModel(PyMCModel):
def build_model(self, X, y, coords):
with self:
X_ = pm.Data(name="X", value=X)
y_ = pm.Data(name="y", value=y)
beta = pm.Normal("beta", mu=0, sigma=1, shape=X_.shape[1])
sigma = pm.HalfNormal("sigma", sigma=1)
mu = pm.Deterministic("mu", pm.math.dot(X_, beta))
pm.Normal("y_hat", mu=mu, sigma=sigma, observed=y_)
rng = np.random.default_rng(seed=42)
X = rng.normal(loc=0, scale=1, size=(20, 2))
y = rng.normal(loc=0, scale=1, size=(20,))
model = MyToyModel(
sample_kwargs={
"chains": 2,
"draws": 2000,
"progressbar": False,
"random_seed": rng,
}
)
model.fit(X, y)
model.score(X, y) and repeatedly call However if I run the whole block multiple times then I get different outputs for |
It works when you provide an integer seed in the |
With
pymc 5.18.2
, andpytensor 2.26.3
the doctest forPyMCModel
is failingCausalPy/causalpy/pymc_models.py
Lines 29 to 68 in 142694f
The text was updated successfully, but these errors were encountered: