PyMC3 on Databricks: progress bar

Thank you @DanhPhan

Any code that defines a model and calls pm.sample() would do, for instance the one from this gist

import numpy as np
import matplotlib.pyplot as plt

np.random.seed(42)

true_m = 0.5
true_b = -1.3
true_σ = 0.3

x = np.sort(np.random.uniform(0, 5, 50))
y_true = true_b + true_m * x
y = y_true + true_σ * np.random.randn(len(x))


import pymc3 as pm

with pm.Model() as model:
    # Define the priors on each parameter.
    m = pm.Uniform("m", lower=-5, upper=5)
    b = pm.Uniform("b", lower=-5, upper=5)
    σ = pm.Uniform("σ", lower=0, upper=10)

    # Define the likelihood.
    pm.Normal("obs", mu=m * x + b, sd=σ, observed=y)

    # This is how you will sample the model.
    trace = pm.sample(draws=1000, tune=1000, chains=8, cores=24)

Thank you!

1 Like