Hi, since Turing 0.35 generated_quantities() is deprecated. So how do I now get my model’s predictions? Before 0.35 I did something like this
function predict(mdl, mles)
## mdl is an instantiated Turing model
params = string.(names(mles.values)...)
preds = generated_quantities(mdl, mles.values, params)
return preds
end
I could write a function like expectation(params, data) that I use inside the model to get the expectation and then after fit to get the predictions, but that is rather cumbersome I feel. Is there an easier solution?
I see the problem now. There is a method that accepts a NamedTuple as an input for the parameters. One hack would be to convert your mode estimation result into a NamedTuple. As a long term solution, maybe a method could be created to work specifically with mode estimators.
Your predict function doesn’t work if you replace generated_quantities with returned? It looks like it’s the same. returned uses fix on the model and then calls it so this would be another way to write it.
function predict(mdl, mles)
## mdl is an instantiated Turing model
vs = Tuple(mles.values)
ks = Tuple(names(mles.values)[1])
preds = returned(mdl, NamedTuple{ks}(vs))
return preds
end