bayesianmodelingandcomputationinpython / bookcode_edition1 Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://www.bayesiancomputationbook.com
License: GNU General Public License v2.0
Home Page: https://www.bayesiancomputationbook.com
License: GNU General Public License v2.0
In your book page 76, Code 3.11 :
run_mcmc = tf.function(
tfp.experimental.mcmc.windowed_adaptive_nuts,
autograph=False, jit_compile=True)
mcmc_samples, sampler_stats = run_mcmc(
1000, jd_penguin_mass_all_species, n_chains=4, num_adaptation_steps=1000,
mass=body_mass_g)
inf_data_model_penguin_mass_all_species2 = az.from_dict(
posterior={
# TFP mcmc returns (num_samples, num_chains, ...), we swap
# the first and second axis below for each RV so the shape
# is what ArviZ expected.
k:np.swapaxes(v, 1, 0)
for k, v in mcmc_samples._asdict().items()},
sample_stats={
k:np.swapaxes(sampler_stats[k], 1, 0)
for k in ["target_log_prob", "diverging", "accept_ratio", "n_steps"]}
)
When I wrote this code and run on python I encounter this error:
I looked at the codes and I have not noticed any typos. Appreciate it if you help with this issue.
Thanks!
The sentence about the New York Times Election Needle seems to be missing something at the end.
Reference
p.284, "Animation" paragraph.
Do not close until
In chapter 5 (Splines) - 5.1 last paragraph: "Additionally, as the degree increases the fit becomes more (???) to the removal of points, or equivalently to the addition of future data, in other words as the degree increases the model becomes more prone to overfitting."
In place of the question marks (???) I believe the word "sensitive" is missing?
Reference
https://bayesiancomputationbook.com/markdown/chp_05.html
Do not close until
I believe the first sentence of the Observational Studies section is missing a "that" i.e. it should read:
"Farming your own ingredients can be expensive, so a cheaper alternative could be foraging for ingredients that are growing by themselves."
Instead of:
"Farming your own ingredients can be expensive, so a cheaper alternative could be foraging for ingredients are growing by themselves."
Ideally these would be ordered
See this PR
#16
The transition matrices in Section https://bayesiancomputationbook.com/markdown/chp_11.html#markov-chains
Listing 1.4 plots two charts—a traceplot and a histrogram. The code to generate the traceplot—ax1
in the code—is missing.
Reference
Listing 1.4
in 1.2 A DIY Sampler
_, axes = plt.subplots(1,2, sharey=True)
axes[1].hist(trace["θ"], color="0.5", orientation="horizontal", density=True)
Do not close until
Typo in writing skewness on page 344 of the book under Appendiceal Topics, linked below.
Reference
https://bayesiancomputationbook.com/markdown/chp_11.html#:~:text=it%20will%20make%20the%20skweness%20independent
Page 344 line 4
Do not close until
Model model_hierarchical_salad_sales_predictions
in listing 4.17 is
@tfd.JointDistributionCoroutine
def out_of_sample_prediction_model():
model = yield root(non_centered_model)
β = model.beta_offset * model.beta_sigma[..., None] + model.beta_mu[..., None]
β_group = yield tfd.Normal(
model.beta_mu, model.beta_sigma, name="group_beta_prediction")
group_level_prediction = yield tfd.Normal(
β_group * out_of_sample_customers,
model.sigma_prior,
name="group_level_prediction")
for l in [2, 4]:
yield tfd.Normal(
tf.gather(β, l, axis=-1) * out_of_sample_customers,
tf.gather(model.sigma, l, axis=-1),
name=f"location_{l}_prediction")
In the distribution for group_level_prediction
, model.sigma_prior
is used for the standard deviation. However, model.sigma_prior
is the distribution of the hyperprior, not the prior that goes into the model.
I don't understand this. Shouldn't the standard deviation in group_level_prediction
be a half-normal distribution whose scaling parameter in turn is influenced by the hyperprior, like this (see s = ...
as well as the line afterwards):
@tfd.JointDistributionCoroutine
def out_of_sample_prediction_model():
model = yield root(non_centered_model)
β = model.beta_offset * model.beta_sigma[..., None] + model.beta_mu[..., None]
β_group = yield tfd.Normal(
model.beta_mu, model.beta_sigma, name="group_beta_prediction")
s = yield tfd.HalfNormal(model.sigma_prior, name="s")
group_level_prediction = yield tfd.Normal(
β_group * out_of_sample_customers,
s,
name="group_level_prediction")
for l in [2, 4]:
yield tfd.Normal(
tf.gather(β, l, axis=-1) * out_of_sample_customers,
tf.gather(model.sigma, l, axis=-1),
name=f"location_{l}_prediction")
Location | Original | Possible correction / Problem |
---|---|---|
Chapter 1 | One is what could called […] | One is what could be called […] |
Chapter 2 | In this chapter we will discuss some of these tasks including, checking model assumptions, diagnosing inference results and model comparison. | comma after "tasks" instead after "including"? |
Chapter 2, description of Fig. 2.6 | In the first panel, the curve with the solid line is the KDE of the proportion of simulations of predicted values with mean values less or equal than the observed data. | Isn't just the KDE of the test statistics T(y*|y) (= mean) plotted here? |
Chapter 2 | […] model_0 specified a posterior distribution […] | "specifies", because the rest of the sentence also uses present tense |
Chapter 2 | The quantity defined by Equation (2.5) (or that quantity multiplied by some constant) is usually known as the deviance, and it is use in both Bayesians and non-Bayesians contexts. | "used" instead of "use" |
Chapter 3, description of Fig. 3.3 | The vertical lines are the empirical mean and standard deviation. | In the description "vertical lines" are mentioned, but not visible in the plots. |
Chapter 3 | Take a moment to compare the estimate of the mean with the summary mean shows for each species in Table 3.1. | "shows" should be "shown" |
Chapter 3, Sec. "Linear Regression" | We call this a linear regression because the parameters (not the covariates) enter the model in a linear fashion. | To my understanding, "coefficients", "covariates" and "parameters" were defined as synonyms three sentences before. So, this sentence does not make sense to me. |
Chapter 3, Sec. "Linear Regression" | From our posterior estimate we can state that if we saw an Adelie penguin with a 0 mm flipper length we would expect the mass of this impossible penguin to somewhere between -4213 and -546 grams. | 1. The numbers -4213 and -546 are different from the HDI numbers in Fig. 3.8 left (-4151 and -510) 2. "be" is missing after "to" |
Chapter 3, Sec. "Linear Regression" | For example, in our intercept per penguin model (Code Block mass_forest_plot), instead of mu = μ[species.codes] we can use pandas.get_dummies to parse the categorical information into a design matrix mu = pd.get_dummies(penguins["species"]) @ μ. where @ is a Python operator for performing matrix multiplication. | 1. Sounds like mu is the design matrix, not pd.get_dummies(penguins["species"]) 2. Comma instead of period after the last μ |
Chapter 3, Sec. "Linear Regression" | In this case we will opt for a centering transformation, which takes a set a value and centers its mean value at zero as shown in Code Block flipper_centering. | […] which takes a set of values […] |
Chapter 3, Sec. "Linear Regression" | In this case our estimate of has dropped a mean of 462 grams in our no covariate model defined in Code Block penguin_mass to a mean value 298 grams from the linear model defined in Code Block penguin_mass_multi that includes flipper length and sex as a covariates. | "of" missing in "a mean value 298 grams" |
Chapter 3, description of Fig. 3.15 | Fig. 46 By incorporating sex as a covariate in model_penguin_mass_categorical the estimated distribution of from this model is centered around 300 grams, which lower value than estimated by our fixed mean model and our single covariate model. This figure is generated from Code Block forest_multiple_models. | "[…], which lower value than estimated […]" should be "[…], which is lower than the value estimated […]" |
Chapter 3, Sec. "Multiple Linear Regression" | it is easy to condition on new predictors, which useful for counterfactual analyses. | "is" missing in front of "useful" |
Chapter 3, Sec. "GLM" | We are still dealing a linear model here […] | "with" missing in front of "a linear model" |
Chapter 3, Sec. "GLM" | In our classifying penguins example we find it reasonable to equally expect a Gentoo penguin […] | "Chinstrap" instead of "Gentoo" (see last model) |
Chapter 3, Sec. "GLM" | […] and Fig. 3.22.A separation […] | Missing space before "A separation " |
Chapter 3, Sec. "GLM" | […] if we were to pick a random penguin from Adelie or Chinstrap penguinsthe probability that […] | Missing space in "penguinsthe" |
Chapter 3, Sec. "Picking Priors in Regression" | Given these choices we can write our model in Code Block uninformative_prior_sex_ratio) […] | unnecessary ")" |
Chapter 3, Sec. "Picking Priors in Regression" | This is not a fully uninformative priors […] | plural/singular |
Chapter 3, Notebook , Code for Figure 3.24 | # Take 10 sample from posterior num_samples = 50 | Comment says 10 samples from posterior, but drawn are 50 samples from prior |
Chapter 3, Notebook , Code for Figure 3.24 | # Take 10 sample from posterior num_samples = 50 | Comment says 10 samples from posterior, but drawn are 50 samples from posterior |
Chapter 3, Sec. "Picking Priors in Regression" | Plotting our posterior samples the concentration of coefficients is smaller and the plotted posterior lines fall into bounds that more reasonable when considering possible ratios. | "are" missing after "bounds that" |
Chapter 3, E7 | Note that there are divergence with the original parameterization. | divergence should be plural |
An unrelated question: You write solutions are available on request. Can you send the solutions to me, please? Would really be helpful as a self-learner.
Hi there, I'm encountering an issue in Chapter 06 at Code Block 6.14, when it comes to the section of the code where we're using generate_gam_ar_latent()
:
mcmc_samples, sampler_stats = run_mcmc(
1000, gam_with_latent_ar, n_chains=4, num_adaptation_steps=1000,
seed=tf.constant([36245, 734565], dtype=tf.int32),
observed=co2_by_month_training_data.T
)
When it comes to running MCMC function on this model I get the following error:
------------------------------------------------------------------
ValueError Traceback (most recent call last)
<timed exec> in <module>
~\anaconda3\envs\pm3env\lib\site-packages\tensorflow\python\util\traceback_utils.py in error_handler(*args, **kwargs)
151 except Exception as e:
152 filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153 raise e.with_traceback(filtered_tb) from None
154 finally:
155 del filtered_tb
~\anaconda3\envs\pm3env\lib\site-packages\tensorflow_probability\python\experimental\mcmc\windowed_sampling.py in windowed_adaptive_nuts(n_draws, joint_dist, n_chains, num_adaptation_steps, current_state, init_step_size, dual_averaging_kwargs, max_tree_depth, max_energy_diff, unrolled_leapfrog_steps, parallel_iterations, trace_fn, return_final_kernel_results, discard_tuning, chain_axis_names, seed, **pins)
709 'unrolled_leapfrog_steps': unrolled_leapfrog_steps,
710 'parallel_iterations': parallel_iterations}
--> 711 return _windowed_adaptive_impl(
712 n_draws=n_draws,
713 joint_dist=joint_dist,
~\anaconda3\envs\pm3env\lib\site-packages\tensorflow_probability\python\experimental\mcmc\windowed_sampling.py in _windowed_adaptive_impl(n_draws, joint_dist, kind, n_chains, proposal_kernel_kwargs, num_adaptation_steps, current_state, dual_averaging_kwargs, trace_fn, return_final_kernel_results, discard_tuning, seed, chain_axis_names, **pins)
883 samplers.sanitize_seed(seed), n=2)
884 (target_log_prob_fn, initial_transformed_position, bijector,
--> 885 step_broadcast, batch_shape, shard_axis_names) = _setup_mcmc(
886 joint_dist,
887 n_chains=n_chains,
~\anaconda3\envs\pm3env\lib\site-packages\tensorflow_probability\python\experimental\mcmc\windowed_sampling.py in _setup_mcmc(model, n_chains, init_position, seed, **pins)
241 tf.nest.flatten(batch_shape))
242
--> 243 lp_static_shape = tensorshape_util.concatenate(n_chains, batch_shape)
244
245 if not tensorshape_util.is_fully_defined(batch_shape):
~\anaconda3\envs\pm3env\lib\site-packages\tensorflow_probability\python\internal\tensorshape_util.py in concatenate(x, other)
131 dimensions in `x` and `other`.
132 """
--> 133 return _cast_tensorshape(tf.TensorShape(x).concatenate(other), type(x))
134
135
~\anaconda3\envs\pm3env\lib\site-packages\tensorflow_probability\python\internal\tensorshape_util.py in _cast_tensorshape(x, x_type)
72 # as the shape, which we don't want.
73 return np.array(as_list(x), dtype=np.int32)
---> 74 return x_type(as_list(x))
75
76
~\anaconda3\envs\pm3env\lib\site-packages\tensorflow_probability\python\internal\tensorshape_util.py in as_list(x)
62 ValueError: If `x` has unknown rank.
63 """
---> 64 return tf.TensorShape(x).as_list()
65
66
ValueError: as_list() is not defined on an unknown TensorShape.
Is there something that I need to fix in the generate_gam_ar_latent()
function itself?
def generate_gam_ar_latent(training=True):
@tfd.JointDistributionCoroutine
def gam_with_latent_ar():
seasonality, trend, noise_sigma = yield from gam_trend_seasonality()
# Latent AR(1)
ar_sigma = yield root(tfd.HalfNormal(.1, name='ar_sigma'))
rho = yield root(tfd.Uniform(-1., 1., name='rho'))
def ar_func(y):
loc = tf.concat([tf.zeros_like(y[..., :1]), y[..., :-1]],
axis=-1) * rho[..., None]
return tfd.Independent(
tfd.Normal(loc=loc, scale=ar_sigma[..., None]),
reinterpreted_batch_ndims=1
)
temporal_error = yield tfd.Autoregressive(
distribution_fn=ar_func,
sample0=tf.zeros_like(trend),
num_steps=trend.shape[-1],
name='temporal_error'
)
# Linear prediction
y_hat = seasonality + trend + temporal_error
if training:
y_hat = y_hat[..., :co2_by_month_training_data.shape[0]]
# Likelihood
observed = yield tfd.Independent(
tfd.Normal(y_hat, noise_sigma[..., None]),
reinterpreted_batch_ndims=1,
name='observed'
)
return gam_with_latent_ar
I upgraded to TensorFlow Probability 0.15.0 and now my Kernel just dies; is there any possible known solution to this? Many thanks for this incredible book!
Confusing use of trace
instead of idata
in Fig. 1.5 plot (img/chp01/Bayesian_quartet_distributions.png)
az.plot_dist(trace["θ"], plot_kwargs={"color":"0.5"},
fill_kwargs={'alpha':1}, ax=axes[2])
works, but it is confusing because the variable "trace" was used on Code 1.3, and Fig 1.5 is meant to as result of Code 1.6, right?
I think it should be:
az.plot_dist(idata["posterior"]["θ"], plot_kwargs={"color":"0.5"},
fill_kwargs={'alpha':1}, ax=axes[2])
Reference
Fig. 1.5 plot code
Do not close until
Hi there, I'm finding troubles to install the provided environment. Particularly, I'm getting the following error related to mkl
:
Installing pip dependencies: \ Ran pip subprocess with arguments:
['/Users/roberto/miniconda3/envs/bmcp/bin/python', '-m', 'pip', 'install', '-U', '-r', '/Users/roberto/Desktop/BookCode_Edition1/condaenv.o04625o0.requirements.txt']
Pip subprocess output:
Collecting arviz==0.11.2
Using cached arviz-0.11.2-py3-none-any.whl (1.6 MB)
Collecting ipython==7.26.0
Using cached ipython-7.26.0-py3-none-any.whl (786 kB)
Collecting jupyter==1.0.0
Using cached jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
Collecting jupyterlab==3.2.1
Using cached jupyterlab-3.2.1-py3-none-any.whl (8.6 MB)
Collecting matplotlib==3.4.3
Using cached matplotlib-3.4.3.tar.gz (37.9 MB)
Pip subprocess error:
ERROR: Could not find a version that satisfies the requirement mkl==2021.3.0 (from versions: none)
ERROR: No matching distribution found for mkl==2021.3.0
failed
Below are my conda settings. I'm also using an Apple M1 laptop.
> conda info
active environment : base
active env location : /Users/roberto/miniconda3
shell level : 1
user config file : /Users/roberto/.condarc
populated config files : /Users/roberto/.condarc
conda version : 4.11.0
conda-build version : not installed
python version : 3.8.12.final.0
virtual packages : __osx=12.1=0
__unix=0=0
__archspec=1=arm64
base environment : /Users/roberto/miniconda3 (writable)
conda av data dir : /Users/roberto/miniconda3/etc/conda
conda av metadata url : None
channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/osx-arm64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-arm64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/roberto/miniconda3/pkgs
/Users/roberto/.conda/pkgs
envs directories : /Users/roberto/miniconda3/envs
/Users/roberto/.conda/envs
platform : osx-arm64
user-agent : conda/4.11.0 requests/2.26.0 CPython/3.8.12 Darwin/21.2.0 OSX/12.1
UID:GID : 501:20
netrc file : None
offline mode : False
I tried to conda install mkl-service
but I always get this error:
> conda install -c anaconda mkl-service
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- mkl-service
Current channels:
- https://conda.anaconda.org/anaconda/osx-arm64
- https://conda.anaconda.org/anaconda/noarch
- https://conda.anaconda.org/conda-forge/osx-arm64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/osx-arm64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-arm64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Any guidance on how to sort this out?
Manuscript code requires bambi package, please add to the environment.yml file.
bambi library mentioned on page xix, Code 0.2
section, but not included in the environment.yml
file so running the code on page xix yields a runtime error.
Reference
page xix
The function name on 2E7 should be az.plot_loo_pit(ecdf=True)
instead of az.plot_loo(ecdf=True)
Reference
Do not close until
- we introduce these concepts and methods, many, which will be further explored
+ we introduce these concepts and methods, many of which will be further explored
Reference
https://bayesiancomputationbook.com/markdown/chp_01.html
Do not close until
Location | Original | Possible correction / Problem |
---|---|---|
Section 4.1 | We can note express mathematically by extending Equation […] | We can express this mathematically by extending Equation […] |
Section 4.1 | model_linear faithfully gives us a linear growth rate as shown Fig. 4.2 […] | "model_linear" is named "model_baby_linear" in Listing 4.2 |
4E7 | […] baby_model_linear and baby_model_sqrt […] | both models are named differently in listings 4.2 and 4.3: "model_baby_linear" and "model_baby_sqrt" |
Section 4.1 | The model tends to overestimate the length of babies close to 0 months of age, and over estimate length at 10 months of age, and then once again underestimate at 25 months of age. | Figure 4.2 looks different than this sentence says: overestimation @0 months underestimation @10 months overestimation @25 months |
Section 4.3 | But if this town in a cold climate with an average daily temperature of -5 degrees Celsius […] | But if this is a town in a cold climate with an average daily temperature of -5 degrees Celsius […] |
Section 4.3, description of Figure 4.5 | On the right we show the non-interaction estimate […] On the left we show our model from Code Block tips_no_interaction […] | On the left we show the non-interaction estimate […] On the right we show our model from Code Block tips_interaction […] |
Section 4.4 | Outliers, as the name suggests, are observations that lie outside of the range “reasonable expectation”. | Outliers, as the name suggests, are observations that lie outside the range of “reasonable expectation”. |
Section 4.4, Table 4.1 | […] noting in particular σ which at a mean value of 574 seems high […] | In Table 4.1, the mean is 2951.1, not 574 |
Section 4.5 | Often we have dataset that […] | Often we have datasets that […] |
Section 4.5 | The GraphViz representation is also shown in Fig. 4.12. | The GraphViz representation is also shown in Fig. 4.16. |
Section 4.5 | Description of Figures 4.20/21 | In the online version there is "code" text below the figures, like [fig:Salad_Sales_Basic_Regression_Scatter_Sigma_Pooled_Slope_Unpooled]{#fig:Salad_Sales_Basic_Regression_Scatter_Sigma_Pooled_Slope_Unpooled label=”fig:Salad_Sales_Basic_Regression_Scatter_Sigma_Pooled_Slope_Unpooled”} |
Section 4.5 | Note how the estimated of σ in the multilevel model is within the bounds of the estimates from the pooled model. | Note how the estimation of σ in the multilevel model is within the bounds of the estimates from the pooled model. |
Section 4.6 | In our data treatment thus far we have had two options for groups, pooled where there is no distinction between groups, and unpooled where there a complete distinction between groups. | In our data treatment thus far we have had two options for groups, pooled where there is no distinction between groups, and unpooled where there is a complete distinction between groups. |
Section 4.6 | The partial refers to the idea that groups that do not share one fixed parameter, but share a which describes the distribution of for the parameters of the prior itself. | The partial refers to the idea that groups that do not share one fixed parameter, but share a hyperprior/hyperparameter (???) which describes the distribution of for the parameters of the prior itself. |
Section 4.6 | But in this case we assume that only the variance is related, which justifying the use of partial pooling and that the slopes are completely independent. | But in this case we assume that only the variance is related, which justifies the use of partial pooling and that the slopes are completely independent. |
Section 4.6, description of Figure 4.24 | Note how the hyperprior tends to represent fall within the range of the three group priors. | Note how the hyperprior tends to |
Section 4.6 | We can also see the effect of a hierarchical model if we compare the summary tables of the unpooled model and hierarchical models in Table 4.3. | We can also see the effect of a hierarchical model if we compare the summaries of the unpooled model and hierarchical model in Tables 4.3 and 4.4. |
Section 4.6 | Moreover, the estimates of the pizza and salad categories in the hierarchical category, while regressed towards the mean slightly, remain largely the same as the unpooled estimates. | Moreover, the estimates of the pizza and sandwich categories in the hierarchical model, while regressed towards the mean slightly, remain largely the same as the unpooled estimates. |
Section 4.6 | It would be helpful to explain what "regressed towards the mean" means. | |
Section 4.6 | Given that our observed data and the model which does not share information between groups this consistent with our expectations. | Given |
Section 4.6, info box | Note that since beta_mj has a Gaussian distributed prior, we can actually choose two hyperprior […] | Note that since beta_mj has a Gaussian distributed prior, we can actually choose two hyperpriors […] |
Section 4.6, info box | A natural question you might ask is can we go even further and adding hyperhyperprior to the parameters that are parameterized the hyperprior? | A natural question you might ask is can we go even further and add a hyperhyperprior to the parameters that |
Section 4.6, info box | Intuitively, they are a way for the model to “borrow” information from sub-group or sub-cluster of data to inform the estimation of other sub-group/cluster with less observation. The group with more observations will inform the posterior of the hyperparameter, which then in turn regulates the parameters for the group with less observations. | Intuitively, they are a way for the model to “borrow” information from sub-groups or sub-clusters of data to inform the estimation of other sub-groups/clusters with less observation. The group with more observations will inform the posterior of the hyperparameters, which then in turn regulate [or regulates, if the concept of information sharing is meant?] the parameters for the group with less observations. |
Section 4.6, info box | In this lens, putting hyperprior on parameters that are not group specific is quite meaningless. | In this sense, putting a hyperprior on parameters that are not group specific is quite meaningless. |
Section 4.6.1 | At sampling at the top of the funnel where Y is around a value 6 to 8, a sampler can take wide steps of lets say 1 unit, and likely remain within a dense r.egion of the posterior | When sampling at the top of the funnel where Y is around a value 6 to 8, a sampler can take wide steps of lets say 1 unit, and likely remain within a dense r.egion of the posterior |
Section 4.6.1 | This drastic difference in the posterior geometry shape is one reason poor posterior estimation, can occur for sampling based estimates. | This drastic difference in the posterior geometry shape is one reason poor posterior estimation [no comma here] can occur for sampling based estimates. |
Section 4.6.1 | In hierarchical models the geometry is largely defined by the correlation of hyperpriors to other parameters, which can result in funnel geometry that are difficult to sample. | In hierarchical models the geometry is largely defined by the correlation of hyperpriors to other parameters, which can result in funnel geometries that are difficult to sample. |
Section 4.6.1 | In other words as the value beta_sh approaches zero, there the region in which to sample parameter collapses and the sampler is not able to effectively characterize this space of the posterior. | In other words as the value beta_sh approaches zero, there |
Section 4.6.1, description of Figure 4.27 | As the hyperprior approaches zero the posterior space for slope collapses results in the divergences seen in blue. | As the hyperprior approaches zero the posterior space for the slope collapses and results in the divergences seen in blue. |
Section 4.6.1 | Is there something wrong with the subscript of beta_m? | |
Section 4.6.2 | This using the fitted parameter estimates to make an out of sample prediction for the distribution of customers for 50 customers, at two locations and for the company as a whole simultaneously. | This uses the fitted parameter estimates to make an out of sample prediction for the distribution of customers for 50 customers, at two locations and for the company as a whole simultaneously. |
Section 4.6.2 | In this case, imagine we are opening another salad restaurant in a new location we can already make some predictions of how the salad sales might looks like […] | In this case, imagine we are opening another salad restaurant in a new location we can already make some predictions of how the salad sales might look like […] |
Section 4.6.2 | […] the distributions with and without the point/group/etc being close to each other. | […] the distributions with and without the point/group/etc. being close to each other. |
Section 4.6.3 | Moreover, since the effect of partial pooling is the combination of how informative the hyperprior is, the number of groups you have, and the number of observations in each group. | Moreover, |
The repo does not appear to contain the datasets for three Exercises in Chapter 04:
gravity_measurements.csv
These datasets are not in the data/ directory nor in the exercises/data/ directory. I've searched elsewhere in the repo and cannot find them anywhere. Please add these to repo, as they look like very interesting exercises to try out. Thank you.
Reference
Pages 142-143 in the physical book and/or https://bayesiancomputationbook.com/markdown/chp_04.html#exercises
Do not close until
A box in the flow diagram (Figure 9.1) says “Model compasion” instead of “model comparison”
In exercise 2E6, there is a referral to an ArViz data file in the GitHub file that should be read for the solution. Can't find the ArViz files in the repo.
Reference
Do not close until
Hey, thanks once again for the great book - I was just revisiting the section on the Tensorflow Probability implementation of SARIMAX in Chapter 6, I have a couple quick questions:
Is it possible to use / include a demo of how you'd make out of sample forecast predictions using the SARIMAX models? (Probably requires more effort, but similar to the forecast examples given using the STS models at the end?)
While it's stated that we can't combine the seasonal_order
with the design_matrix
- is it possible to model external regressors (e.g. holidays, covariates etc) in addition to using the fourier_seasonality()
basis function, and just add a couple extra columns to the design matrix, or is something more clever / sophisticated required?
Many thanks again!
Probably needs some other stuff too, but these three for sure
The toggle navigation button doesn't work on every page. You don;t notice it that much on a desktop but it makes the pages unviewable on mobile because the navigation pane overlays the main text page. In chapter one the Preface and the Bayesian Inference pages have non working toggle navigation buttons, but the button on the Foreward page works.
The code needs to be cleaned, and maybe it can made a little bit more efficient.
Hey! I love the book! Thanks for working on it :)
In Section 9.11 Experimental Example: Comparing Between Two Groups I think there are missing units. I quote:
*... For example, the first bidirectional specimen failed at 3774 lbf (1532 kg) at a cross section area of .504 inches (12.8mm) by .057 inches (1.27), yielding an ultimate strength of 131.393 ksi (kilopound per square inch). *
However it seems it should be:
*...For example, the first bidirectional specimen failed at 3774 lbf (1532 kg) at a cross section area of .504 inches (12.8mm) by .057 inches (1.27mm), yielding an ultimate strength of 131.393 ksi (kilopound per square inch). *
Note the change in (1.27mm)
Reference
Section 9.11 Experimental Example: Comparing Between Two Groups. In the book is page 286.
Do not close until
Hi there,
I find the explanation of Laplace being a maximum entropy prior is confusing (page 23). Could you please explain what you mean by "an absolute value mean"? I thought the constrain here should be there is an existing absolute deviation to the mean (or more generally, the location). Thanks a lot.
In Section 2.4.1 Effective Sample Size
there is a parentheses missing (page 42 physical book). I quote:
Plotting the ESS for specifics quantiles az.plot_ess(., kind="quantiles"
or for small intervals
I think it should be
Plotting the ESS for specifics quantiles az.plot_ess(., kind="quantiles")
or for small intervals
Note the closed parentheses in the az.plot_ess
method.
Reference
Section 2.4.1 Effective Sample Size
and page 42 physical book.
Do not close until
Broken sentence on 376 and Typo on 380
Reference
Do not close until
navigation does not close on chapters 3, 5, & 10.
navigation does not close on chapters 3, 5, & 10.
Reference
https://bayesiancomputationbook.com/markdown/chp_03.html
https://bayesiancomputationbook.com/markdown/chp_05.html
https://bayesiancomputationbook.com/markdown/chp_10.html
Do not close until
input_df
parameter for the gen_hierarchical_salad_sales
function on code block 4.13 not referenced inside the function.
Expected:
def gen_hierarchical_salad_sales(input_df, beta_prior_fn, dtype=tf.float32):
customers = tf.constant(input_df["customers"].values, dtype=dtype)
location_category = input_df["location"].values
sales = tf.constant(input_df["sales"].values, dtype=dtype)
Reference
Page 133
https://bayesiancomputationbook.com/markdown/chp_04.html#model-hierarchical-salad-sales
Do not close until
Figure 36 has the following description:
Fig. 36 Forest plot of the mean of mass of each species group in model_penguin_mass_all_species. Each line represents one chain in the sampler, the dot is a point estimate, in this case the mean, the thin line is the interquartile range from 25% to 75% of the posterior and the thick line is the 94% Highest Density Interval.
However, from the plot, it does not make sense since the thin line is larger than the thick line which would mean that the 50% interquartile range contains 94% of the data. I think the thin and thick descriptors should be reverted.
Reference
https://bayesiancomputationbook.com/markdown/chp_03.html#comparing-two-or-more-groups
Do not close until
Not sure this is an error or not, but I could not load the datasets from problem 2E6 with the suggested comamnd:
#Does not work ( from source code, looks like load_arviz_data is not designed to load custom datasets from anywhere in disk):
pois_idata=az.load_arviz_data("./pois_idata.nc")
#However the following command doest work:
pois_idata = az.from_netcdf("./pois_idata.nc")
Reference
pg 62 problem 2E6
Do not close until
See #79
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.