Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Int argument for predict function #301

Open
paschermayr opened this issue Sep 10, 2021 · 2 comments
Open

Int argument for predict function #301

paschermayr opened this issue Sep 10, 2021 · 2 comments
Assignees

Comments

@paschermayr
Copy link

From: https://julialang.zulipchat.com/#narrow/stream/240884-soss.2Ejl

Could we have an additional argument in the predict function, where we specify the number of samples taken? We can do this already via

using Soss, Distributions
dat = randn(100)
μ₀ = 1.
σ₀ = 2.

m = @model n begin
    μ ~ Distributions.Normal()
    σ ~ Distributions.Exponential()
    data ~ Distributions.Normal(μ, σ) |> iid(n)
    return (; data)
end
post =  m((μ = μ₀, σ = σ₀, n = length(dat))) | (data = dat,)
vals = (μ = μ₀, σ = σ₀)

pred = predictive(m, keys(vals)...)
rand(pred(μ = μ₀, σ = σ₀, n = 1))

but not via the predict function itself:

Soss.predict(post, vals) #Will be A vector of length length(dat)
Soss.predict(post, vals, n = 1) #Method error
@cscherrer
Copy link
Owner

Hi @paschermayr , sorry for the delay on this. I'm tied up for a while, but I think we can get something like this working. One possibility is to have a standard way to convert a predict call into a rand call, in a way that extra arguments are handled by passing them along directly. In this way any updates to rand will come into predict as well "for free"

@paschermayr
Copy link
Author

Thank you, that sounds good!

@cscherrer cscherrer self-assigned this Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants