PyMC3 do not converge

I'm trying to run a simple logistic regression on PyMC3. Here the code:

with pm.Model() as logistic_model:
    alpha=pm.Normal('alpha', mu=0, sd=100)
    beta1=pm.Normal('beta', mu=0, sd=100)
    beta2=pm.Normal('beta2', mu=0, sd=100)

    argtemp=alpha + beta1*data['age'].values +beta2*data['educ'].values
    prob=pm.invlogit(argtemp)
    Y_obs = pm.Bernoulli('Y_obs', p=prob, observed=data['income_more_50K'].values)
    map_estimate = pm.find_MAP()
    sampler=pm.Metropolis()

    trace= pm.sample(40000, step=sampler, start=map_estimate)

The sampler run, but at the end it gives this error:

The gelman-rubin statistic is larger than 1.4 for some parameters. The sampler did not converge.
The estimated number of effective samples is smaller than 200 for some parameters.

Can someone help me in understanding what is wrong, and why the sampler do not converge?

Thank you!

Topic probabilistic-programming mcmc python machine-learning

Category Data Science


It turns out that the problem was the MAP estimation. Commenting out that line makes the code works.

Details in this thread in the PyMC Discourse forum.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.