Add na_action handling to poststratify#260
Add na_action handling to poststratify#260neuralsorcerer wants to merge 7 commits intofacebookresearch:mainfrom
na_action handling to poststratify#260Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds na_action parameter to the poststratify function to provide explicit control over missing value handling during post-stratification weighting. The implementation follows the same pattern as the rake method.
Changes:
- Added
na_actionparameter with "add_indicator" (default) and "drop" options - Implemented NA handling after transformations, consistent with rake
- Added tests for both na_action behaviors and parameter validation
- Updated CHANGELOG with user-facing documentation
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| balance/weighting_methods/poststratify.py | Added na_action parameter with validation and implementation for both "drop" and "add_indicator" modes; removed TODO comment about adding na_action |
| tests/test_poststratify.py | Added test_poststratify_na_action() covering basic functionality and validation test for invalid na_action values |
| CHANGELOG.md | Documented new na_action parameter in New Features section |
talgalili
left a comment
There was a problem hiding this comment.
Please fix failing tests :)
talgalili
left a comment
There was a problem hiding this comment.
ok, I'm sorry, I take it back.
Adding bool as an option seems cumbersome.
Could you please just revert back to na_action as string - with the options you had implemented?
(sorry for the back and forth)
no problem. will do it :) |
|
@neuralsorcerer could you please fix the copilot's comments? |
|
@talgalili has imported this pull request. If you are a Meta employee, you can view this in D90583549. |
|
@talgalili merged this pull request in 06e72cf. |
Added
na_actionhandling topoststratifyso missing values can be dropped or treated as their own category during weighting. Also, added tests coveringna_actionbehaviors and validation in poststratify.