Skip to content

add weighted ppc #2273

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

Merged
merged 9 commits into from
Jun 27, 2017
Merged

add weighted ppc #2273

merged 9 commits into from
Jun 27, 2017

Conversation

aloctavodia
Copy link
Member

@aloctavodia aloctavodia commented Jun 5, 2017

Allows to use sample_ppc to get weighted samples, if more than one trace and a set of weights are passed.
The weights could come from the compare function, for example.

I will try to add a notebook with examples ASAP.

@@ -536,6 +544,100 @@ def sample_ppc(trace, samples=None, model=None, vars=None, size=None,
return {k: np.asarray(v) for k, v in ppc.items()}


def sample_ppc_w(traces, samples=None, models=None, size=None, weights=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO Your approach before was better - why adding a new function instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be potentially confusing for the user.

@aloctavodia
Copy link
Member Author

I think is better for the user to have a separated function to perform a weighted ppc (model averaging).

@junpenglao
Copy link
Member

junpenglao commented Jun 7, 2017

I see, a notebook demonstrating how to use this for model averaging is necessary then. It would be quite a cool feature.

@aloctavodia
Copy link
Member Author

I will try do add that notebook ASAP, thanks for the review!

raise ValueError(
'The number of traces and weights should be the same')
indices = randint(0, len(trace), samples)
if progressbar:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tqdm progress bars need to be closed if sampling is interrupted. Some try...finally would do it.

@aloctavodia
Copy link
Member Author

I add an example showing how to use the new function and fix the tqdm issue
I also rename the model comparison notebook and add it to the examples list, under the Howto category. I did it as part of this PR, because I reference that notebook in the new example.

@junpenglao
Copy link
Member

Nice! I think it's ready to merge once the test pass.

@aseyboldt
Copy link
Member

This looks nice! But I think we should merge only after the 3.1 release.

@junpenglao
Copy link
Member

Fine with me.
@twiecki what is the time line for 3.1 release?

@twiecki
Copy link
Member

twiecki commented Jun 8, 2017

@junpenglao After we fix the notebooks and examples we should be good to go.

@junpenglao
Copy link
Member

@twiecki the examples are fixed (#2254) except one which depends on #2277. Since #2277 is on the 3.2 road map I think #2254 is OK to merge now.
As for the notebook, I think they are more or less ready as well (I fixed GLM_*, and @ferrine fixed VI notebooks).

@twiecki twiecki added this to the 3.2 milestone Jun 9, 2017
@aloctavodia
Copy link
Member Author

I just fix a couple of conflicts, that I think were introduced by #2291

@aloctavodia
Copy link
Member Author

I just fix a couple of conflicts (probably in the less elegant way).

@fonnesbeck fonnesbeck merged commit fd1e5ba into pymc-devs:master Jun 27, 2017
@fonnesbeck
Copy link
Member

Thanks @aloctavodia

@aloctavodia aloctavodia deleted the sample_ppc_ma branch June 27, 2017 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants