Standardize transform should handle edge case where variable has zero variance
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start by locating the implementation and tests for patsy’s standardize and center transforms, then reproduce the issue with the provided patsy.dmatrix example. Done means standardize accepts a zero-variance variable without raising an error and produces the centered result, while existing non-constant behavior remains unchanged.
Written by the indexing model from the issue text.
Description
In edge cases where a variable has zero variance, standardize should do the same as center rather than producing an error.
Suppose I am fitting a linear model with a large number of random covariates. I'd like to standardize them and fit a regularized model (e.g. sklearn.linear_model.Ridge). If there's some probability that a given covariate has zero variance, I'd like my code to run (and give that covariate a coefficient of zero) rather than crash.
Toy example:
import patsy
data = {"x1": [1, 2, 3, 4], "x2":[5, 5, 5, 5]}
mat = patsy.dmatrix("standardize(x1) + center(x2)", data) # Works
mat = patsy.dmatrix("standardize(x1) + standardize(x2)", data) # Fails! Should handle this edge case
- Dominant language
- Python
- Stars
- 990
- Forks
- 106
- Avg merge
- 7d 34m
- Merged PRs (30d)
- 1
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pydata/patsy
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solana-foundation/pay-kit#341 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nasa/python_cmr#123 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
EleutherAI/lm-evaluation-harness#4243 ·
Maintainers usually reply within 1 day
-
area: dashboard bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Nitjsefnie-Harness-Commons/daedalus#1179 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
cusp-ai-oss/tojax#17 ·