Skip to content

Allow posterior sampling #13

@JohnGoertz

Description

@JohnGoertz

Right now Gumbi only allows (pymc) marginalized posterior predictions, i.e. only mean and variance rather than individual samples. We should also implement an interface for drawing individual posterior samples via .conditional.

Gumbi exposes the Pymc API, so for now the user can access the underlying pymc objects to do this:

gp = gmb.GP(...)

gp.fit(...)

gp.prepare_grid()

# add the GP conditional to the model, given the new X values
with model:
    f_pred = gp.conditional("f_pred", gp.grid_points)

# To use the MAP values, you can just replace the trace with a length-1 list with `mp`
with model:
    pred_samples = pm.sample_posterior_predictive([gp.MAP], vars=[f_pred], samples=2000)

But this approach obviously introduces complexity that Gumbi was intended to remove. In particular:

  • The two-step process of declaring f_pred and then drawing samples should be reduced to a single command, maybe gp.draw(samples=2000, point='MAP')
  • f_pred should be declared as a pm.Data object so that its value can be updated repeatedly, similar to the suggestion here. This should probably be done pre-emptively during intial model building.
  • The output pred_samples should be reshaped and stored as a Parray similar to how predict behaves. This will be slightly complicated by the fact that pred_samples will have an additional dimension compared to gp.grid_points corresponding to different samples.
    • ParrayPlotter should potentially be updated to accomodate this, otherwise the user might need to create a new ParrayPlotter instance for each sample.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions