Skip to content

Do not compute model log_likelihood by default at the end of sampling #6266

Closed
@ricardoV94

Description

@ricardoV94

This evaluation can be quite expensive and require too much memory. I think it's safe to say most users don't make use of this information (nor most of our tests where we choose to return inferencedata), making it pretty wasteful.

It's also trivial to provide an API to obtain it after the fact:

with model:
  idata = pm.compute_log_likelihood(idata, extend_inferencedata=True)

My suggestion is to add that API, and make the automatic computation at the end of sampling opt-in rather than opt-out as it is now, if a user already knows they will want it.

with model:
  idata = pm.sample(idata_kwargs={"log_likelihood": True})  # Otherwise it's not computed by default

I would even consider deprecating that idata_kwargs option to keep pm.sample a bit more simple, but no strong opinion there

CC @OriolAbril

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions