9
9
10
10
from scipy .stats .distributions import pareto
11
11
12
+ import pymc3 as pm
12
13
from .backends import tracetab as ttab
13
14
14
15
__all__ = ['autocorr' , 'autocov' , 'dic' , 'bpic' , 'waic' , 'loo' , 'hpd' , 'quantiles' ,
@@ -114,7 +115,7 @@ def waic(trace, model=None, n_eff=False):
114
115
model : PyMC Model
115
116
Optional model. Default None, taken from context.
116
117
n_eff: bool
117
- if True the effective number parameters will be returned.
118
+ if True the effective number parameters will be returned.
118
119
Default False
119
120
120
121
Returns
@@ -131,8 +132,8 @@ def waic(trace, model=None, n_eff=False):
131
132
132
133
vars_lpd = np .var (log_py , axis = 0 )
133
134
if np .any (vars_lpd > 0.4 ):
134
- warnings .warn ("""For one or more samples the posterior variance of the
135
- log predictive densities exceeds 0.4. This could be indication of
135
+ warnings .warn ("""For one or more samples the posterior variance of the
136
+ log predictive densities exceeds 0.4. This could be indication of
136
137
WAIC starting to fail see http://arxiv.org/abs/1507.04544 for details
137
138
""" )
138
139
p_waic = np .sum (vars_lpd )
@@ -155,7 +156,7 @@ def loo(trace, model=None, n_eff=False):
155
156
model : PyMC Model
156
157
Optional model. Default None, taken from context.
157
158
n_eff: bool
158
- if True the effective number parameters will be computed and returned.
159
+ if True the effective number parameters will be computed and returned.
159
160
Default False
160
161
161
162
Returns
@@ -189,7 +190,7 @@ def loo(trace, model=None, n_eff=False):
189
190
if np .any (pareto_fit [0 ] > 0.5 ):
190
191
warnings .warn ("""Estimated shape parameter of Pareto distribution
191
192
is for one or more samples is greater than 0.5. This may indicate
192
- that the variance of the Pareto smoothed importance sampling estimate
193
+ that the variance of the Pareto smoothed importance sampling estimate
193
194
is very large.""" )
194
195
195
196
# Calculate expected values of the order statistics of the fitted Pareto
@@ -404,7 +405,7 @@ def quantiles(x, qlist=(2.5, 25, 50, 75, 97.5), transform=lambda x: x):
404
405
return dict (zip (qlist , quants ))
405
406
406
407
except IndexError :
407
- print ("Too few elements for quantile calculation" )
408
+ _log . warning ("Too few elements for quantile calculation" )
408
409
409
410
410
411
def df_summary (trace , varnames = None , stat_funcs = None , extend = False , include_transformed = False ,
@@ -438,7 +439,7 @@ def df_summary(trace, varnames=None, stat_funcs=None, extend=False, include_tran
438
439
addition to, rather than in place of, the default statistics.
439
440
This is only meaningful when `stat_funcs` is not None.
440
441
include_transformed : bool
441
- Flag for reporting automatically transformed variables in addition to
442
+ Flag for reporting automatically transformed variables in addition to
442
443
original variables (defaults to False).
443
444
alpha : float
444
445
The alpha level for generating posterior intervals. Defaults
@@ -545,7 +546,7 @@ def summary(trace, varnames=None, alpha=0.05, start=0, batches=100, roundto=3,
545
546
The number of digits to round posterior statistics.
546
547
547
548
include_transformed : bool
548
- Flag for summarizing automatically transformed variables in addition to
549
+ Flag for summarizing automatically transformed variables in addition to
549
550
original variables (defaults to False).
550
551
551
552
tofile : None or string
0 commit comments