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

Add standard deviation to PIG plots in regression case #182

Open
joostneuj opened this issue Aug 30, 2023 · 0 comments · May be fixed by #183
Open

Add standard deviation to PIG plots in regression case #182

joostneuj opened this issue Aug 30, 2023 · 0 comments · May be fixed by #183
Assignees
Labels
enhancement New feature or request

Comments

@joostneuj
Copy link

Add standard deviation to PIG plots in regression case

Task: Adding standard deviation in each bin to PIG plots.

Task Description

With minor modifications to the code, it would be possible to include standard deviations to PIG plots. In the case of regression, it could be useful to visually inspect what the variance is within one bin. I would suggest to not plot it by default, but make it available to the users who want (using a specific argument)? Output could then look like this:

std_dev_example

In the function compute_pig_table, the aggregation should be extended to also calculate the standard deviation as follows:
res = (basetable.groupby(predictor_column_name)
.agg(
avg_target = (target_column_name, "mean"),
pop_size = (target_column_name, "size"),
std_dev_target = (target_column_name, "std"),
)
.reset_index()
.rename(
columns={predictor_column_name: "label"}
)
)

And in the function plot_incidence, you can use ax.errorbar (with yerr being half the previously calculated standard deviation) instead of ax.plot.

@joostneuj joostneuj added the enhancement New feature or request label Aug 30, 2023
@patrickleonardy patrickleonardy self-assigned this Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants