Skip to content

Support trimming in rake and poststratify#147

Closed
neuralsorcerer wants to merge 2 commits intofacebookresearch:mainfrom
neuralsorcerer:trim
Closed

Support trimming in rake and poststratify#147
neuralsorcerer wants to merge 2 commits intofacebookresearch:mainfrom
neuralsorcerer:trim

Conversation

@neuralsorcerer
Copy link
Copy Markdown
Collaborator

  • Added the reusable trim_and_normalize_weights helper to combine weight trimming with optional rescaling to a specified total while preserving series metadata.
  • Updated both rake() and poststratify() to surface the trimming parameters, route them through the new helper, and keep legacy weight totals in edge cases such as unmatched post-stratification cells.
  • Added tests to cover trimming behaviour.

Why?

@meta-cla meta-cla bot added the cla signed label Nov 14, 2025
@talgalili
Copy link
Copy Markdown
Contributor

talgalili commented Nov 14, 2025

Thanks for the PR @neuralsorcerer !

TODO: My one qualm is that I don't think it's worth having both trim_weights AND trim_and_normalize_weights.
I think it makes more sense to add target_sum_weights to trim_weights (with None as default, and use other values for the various cases). Could you please make that change and update the PR?

NOTE: for visibility, I need two people to accept your PR for it to land - so it might be that it would land only between 0-2 days after I accept - since my friends/colleagues may only give a green light next week - just for you to have visibility on why things might take time (I'll do my best to review ASAP, but the actual land depends on +1 other person to be available).

@neuralsorcerer
Copy link
Copy Markdown
Collaborator Author

TODO: My one qualm is that I don't think it's worth having both trim_weights AND trim_and_normalize_weights. I think it makes more sense to add target_sum_weights to trim_weights (with None as default, and use other values for the various cases). Could you please make that change and update the PR?

Updated.

NOTE: for visibility, I need two people to accept your PR for it to land - so it might be that it would land only between 0-2 days after I accept - since my friends/colleagues may only give a green light next week - just for you to have visibility on why things might take time (I'll do my best to review ASAP, but the actual land depends on +1 other person to be available).

No worries. Thanks for the update.

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Nov 14, 2025

@talgalili has imported this pull request. If you are a Meta employee, you can view this in D87063176.

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Nov 14, 2025

@talgalili merged this pull request in ca963b7.

@neuralsorcerer neuralsorcerer deleted the trim branch November 15, 2025 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] rake doesn't support trimming - but also doesn't indicate it to the user

3 participants