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

Update docstring and args #823

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bambi/interpret/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,11 @@ def predictions(

if pps:
idata = model.predict(
idata, data=cap_data, sample_new_groups=sample_new_groups, inplace=False, kind="pps"
idata,
data=cap_data,
sample_new_groups=sample_new_groups,
inplace=False,
kind="response",
)
y_hat = response_transform(idata["posterior_predictive"][response.name])
y_hat_mean = y_hat.mean(("chain", "draw"))
Expand Down
18 changes: 9 additions & 9 deletions bambi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,20 +812,20 @@ def predict(
idata : InferenceData
The ``InferenceData`` instance returned by ``.fit()``.
kind : str
Indicates the type of prediction required. Can be ``"mean"`` or ``"pps"``. The
first returns draws from the posterior distribution of the mean, while the latter
returns the draws from the posterior predictive distribution (i.e. the posterior
probability distribution for a new observation) in addition to the mean posterior
distribution. Defaults to ``"mean"``.
Indicates the type of prediction required. Can be ``"response_params"`` or
``"response"``. The first returns draws from the posterior distribution of
the mean, while the latter returns the draws from the posterior predictive
GStechschulte marked this conversation as resolved.
Show resolved Hide resolved
distribution (i.e. the posterior probability distribution for a new observation)
in addition to the mean posterior distribution. Defaults to ``"response_params"``.
GStechschulte marked this conversation as resolved.
Show resolved Hide resolved
data : pandas.DataFrame or None
An optional data frame with values for the predictors that are used to obtain
out-of-sample predictions. If omitted, the original dataset is used.
inplace : bool
If ``True`` it will modify ``idata`` in-place. Otherwise, it will return a copy of
``idata`` with the predictions added. If ``kind="mean"``, a new variable ending in
``"_mean"`` is added to the ``posterior`` group. If ``kind="pps"``, it appends a
``posterior_predictive`` group to ``idata``. If any of these already exist, it will be
overwritten.
``idata`` with the predictions added. If ``kind="response_params"``, a new variable
with the name of the parent parameter, e.g. ``"mu"`` or ``"p"``is added to the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here it can be multiple parameters (e.g. both mu and sigma)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I updated it to include 2 minimal examples (Gaussian and Bernoulli) so the user can reason what parameters to expect in the posterior group.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks!

``posterior`` group. If ``kind="response"``, it appends a ``posterior_predictive`` group
to ``idata``. If any of these already exist, it will be overwritten.
include_group_specific : bool
Determines if predictions incorporate group-specific effects. If ``False``, predictions
are made with common effects only (i.e. group specific are set to zero). Defaults to
Expand Down
Loading