Repository navigation
Skip missing values when center() and standardize() memorize their statistics - #271
Open
raashish1601 wants to merge 1 commit into
Open
raashish1601 wants to merge 1 commit into
raashish1601 wants to merge 1 commit into
Conversation
Contributor
|
patsy is in effectively long-term maintenance mode with mostly only seeing absolutely required fixes to stop it from failing to operate as it has been on new versions of python. I wouldn't say this is a hard no, but just to set expectations that we mostly don't take features or bug fixes |
Author
|
Understood, thanks for setting expectations. I'll leave it open in case it's useful, and I'm happy to close it if you'd rather keep patsy as is. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #208, and the missing-value case of #166.
center()andstandardize()memorize their mean (and variance) over every row, including missing ones. A singleNaNin the column makes the meanNaN, so the transformed column isNaNin every row, and the NA action then drops all rows:With this change the statistics skip missing values column by column, as R's
scale()does (colMeans(x, na.rm = TRUE)), and the transform leavesNaNwhere the input was missing. The NA action then drops only the rows that actually have missing values:Inputs without missing values give the same results as before. Only float/complex inputs are checked for
NaN; other dtypes keep the previous path.Tests: added
test_Center_missing_valuesandtest_Standardize_missing_valuestopatsy/test_state.py, with two columns that haveNaNin different rows, memorized in one chunk and in two chunks. They fail on main and pass with this change. The full test suite passes locally andruff formatis clean.