A C++ library for Bayesian modeling, mainly through Markov chain Monte Carlo, but with a few other methods supported. BOOM = "Bayesian Object Oriented Modeling". It is also the sound your computer makes when it crashes.
GNU Lesser General Public License v2.1
35
stars
14
forks
source link
Python: TypeError in lm_spike when initializing sampler #68
When attempting to instantiate lm_spike, a TypeError occurs.
System info:
OS: Ubuntu 18.04.6 LTS
Python: 3.8.8
BayesBoom-0.1.9
pybind11-2.10.1
numpy-1.19.2
pandas-1.1.5
Minimal example:
import numpy as np
import pandas as pd
from BayesBoom.spikeslab import dot, lm_spike
data = pd.DataFrame(np.random.random(3000).reshape(1000,3), columns=['y', 'X1', 'X2'])
model = lm_spike(f'y ~ {dot(data)}', niter=100, data=data)
Expectation:
An lm_spike model is instantiated (though not useful for this dummy data).
Actual result:
(...)/site-packages/BayesBoom/spikeslab/spikeslab.py in __init__(self, formula, niter, data, prior, ping, seed, **kwargs)
161 prior = RegressionSpikeSlabPrior(x=X, y=y, **kwargs)
162
--> 163 sampler = boom.BregVsSampler(
164 self._model,
165 prior.slab(self._model.Sigsq_prm),
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. _boom.BregVsSampler(model: _boom.RegressionModel, slab: _boom.MvnGivenScalarSigma, residual_precision_prior: _boom.GammaModelBase, spike: _boom.VariableSelectionPrior, seeding_rng: _boom.RNG = <_boom.RNG object at 0x7f63d5604670>)
Invoked with: <_boom.RegressionModel object at 0x7f639e0bf4b0>, <_boom.MvnGivenScalarSigma object at 0x7f639e0aa930>, <_boom.ChisqModel object at 0x7f639e0b95b0>, <_boom.VariableSelectionPrior object at 0x7f639efb2770>
Aside from looking for an obvious error on my part (step 1), I have also tried simple modifications of lm_spike to isolate the issue. Notably:
Passing residual_precision_prior=None to BregVsSampler
Succeeds in instantiating sampler, but leads to an error later. (Expected.)
Constructing a GammaModel instance and passing that as residual_precision_prior
Causes a TypeError very similar to the one from the minimal example (replacing the reference to ChisqModel with one to GammaModel.
The first of these confirms that the issue is specifically caused by the provided GammaModelBase (ChisqModel) instance, while the second demonstrates that it is not a unique issue affecting the chi-squared model but one which also applies to other implementations of GammaModelBase.
When attempting to instantiate
lm_spike
, a TypeError occurs.System info:
Minimal example:
Expectation:
lm_spike
model is instantiated (though not useful for this dummy data).Actual result:
Aside from looking for an obvious error on my part (step 1), I have also tried simple modifications of
lm_spike
to isolate the issue. Notably:residual_precision_prior=None
toBregVsSampler
GammaModel
instance and passing that asresidual_precision_prior
ChisqModel
with one toGammaModel
.The first of these confirms that the issue is specifically caused by the provided
GammaModelBase
(ChisqModel
) instance, while the second demonstrates that it is not a unique issue affecting the chi-squared model but one which also applies to other implementations ofGammaModelBase
.