Note that there are some explanatory texts on larger screens.

plurals
  1. POOnline Bayesian Learning in PyMC(Updating Posterior Beliefs Repeatedly)
    text
    copied!<p>The following model is part of the tutorial of PyMC, named disaster_model.py and can be imported in the main code to be used as a model:</p> <pre><code>""" A model for the disasters data with a changepoint changepoint ~ U(0, 110) early_mean ~ Exp(1.) late_mean ~ Exp(1.) disasters[t] ~ Po(early_mean if t &lt;= switchpoint, late_mean otherwise) """ from pymc import * from numpy import array, empty from numpy.random import randint __all__ = ['disasters_array', 'switchpoint', 'early_mean', 'late_mean', 'rate', 'disasters'] disasters_array = array([ 4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, 3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5, 2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0, 1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2, 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]) # Define data and stochastics switchpoint = DiscreteUniform('switchpoint', lower=0, upper=110, doc='Switchpoint[year]') early_mean = Exponential('early_mean', beta=1.) late_mean = Exponential('late_mean', beta=1.) @deterministic(plot=False) def rate(s=switchpoint, e=early_mean, l=late_mean): ''' Concatenate Poisson means ''' out = empty(len(disasters_array)) out[:s] = e out[s:] = l return out disasters = Poisson('disasters', mu=rate, value=disasters_array, observed=True) </code></pre> <p>Now one can do a sampling from distributions using MCMC Metropolis Hasting algorithm to get posterior distribution of parameters. </p> <pre><code>from pymc.examples import disaster_model from pymc import MCMC M = MCMC(disaster_model) M.sample(iter=10000, burn=1000, thin=10) </code></pre> <p>Now my problem is that suppose after this sampling I achieve new data. How can I update my posterior distributions afterwards? Basically how can implement online learning using PyMC?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload