@@ -72,13 +72,17 @@ class ModelBuilder(pm.Model):
72
72
... }
73
73
... )
74
74
>>> model.fit(X, y)
75
- Inference...
75
+ <BLANKLINE>
76
+ <BLANKLINE>
77
+ Inference data...
76
78
>>> X_new = rng.normal(loc=0, scale=1, size=(20,2))
77
79
>>> model.predict(X_new)
78
- Inference...
79
- >>> model.score(X, y) # doctest: +NUMBER
80
- r2 0.3
81
- r2_std 0.0
80
+ <BLANKLINE>
81
+ Inference data...
82
+ >>> model.score(X, y)
83
+ <BLANKLINE>
84
+ r2 0.390344
85
+ r2_std 0.081135
82
86
dtype: float64
83
87
"""
84
88
@@ -112,10 +116,7 @@ def fit(self, X, y, coords: Optional[Dict[str, Any]] = None) -> None:
112
116
113
117
# Ensure random_seed is used in sample_prior_predictive() and
114
118
# sample_posterior_predictive() if provided in sample_kwargs.
115
- if "random_seed" in self .sample_kwargs :
116
- random_seed = self .sample_kwargs ["random_seed" ]
117
- else :
118
- random_seed = None
119
+ random_seed = self .sample_kwargs .get ("random_seed" , None )
119
120
120
121
self .build_model (X , y , coords )
121
122
with self :
@@ -137,10 +138,17 @@ def predict(self, X):
137
138
138
139
"""
139
140
141
+ # Ensure random_seed is used in sample_prior_predictive() and
142
+ # sample_posterior_predictive() if provided in sample_kwargs.
143
+ random_seed = self .sample_kwargs .get ("random_seed" , None )
144
+
140
145
self ._data_setter (X )
141
146
with self : # sample with new input data
142
147
post_pred = pm .sample_posterior_predictive (
143
- self .idata , var_names = ["y_hat" , "mu" ], progressbar = False
148
+ self .idata ,
149
+ var_names = ["y_hat" , "mu" ],
150
+ progressbar = False ,
151
+ random_seed = random_seed ,
144
152
)
145
153
return post_pred
146
154
@@ -193,7 +201,9 @@ class WeightedSumFitter(ModelBuilder):
193
201
>>> y = np.asarray(sc['actual']).reshape((sc.shape[0], 1))
194
202
>>> wsf = WeightedSumFitter(sample_kwargs={"progressbar": False})
195
203
>>> wsf.fit(X,y)
196
- Inference ...
204
+ <BLANKLINE>
205
+ <BLANKLINE>
206
+ Inference data...
197
207
""" # noqa: W605
198
208
199
209
def build_model (self , X , y , coords ):
@@ -249,7 +259,9 @@ class LinearRegression(ModelBuilder):
249
259
... 'obs_indx': np.arange(rd.shape[0])
250
260
... },
251
261
... )
252
- Inference...
262
+ <BLANKLINE>
263
+ <BLANKLINE>
264
+ Inference data...
253
265
""" # noqa: W605
254
266
255
267
def build_model (self , X , y , coords ):
@@ -301,6 +313,8 @@ class InstrumentalVariableRegression(ModelBuilder):
301
313
... "eta": 2,
302
314
... "lkj_sd": 2,
303
315
... })
316
+ <BLANKLINE>
317
+ <BLANKLINE>
304
318
Inference data...
305
319
"""
306
320
0 commit comments