easystats / easystats/datawizard
Simplify code for linear transformers
@mattansb is already working on this.
Since Dec 12, 2022.
- Dominant language
- R
- Stars
- 238
- Forks
- 18
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 4
Description
All of the following are linear transformers:
center()standardize()slide()reverse()rescale()normalize()
So hypothetically we should be able to simplify their code to a common underlying function. Idially, each function would compute the needed shift and scale values, and these will be passed to standardize(..., center = <shift>, scale = <scale>).
This will have 0 effect on usability, but will make maintenance of the code much easier.
| Function | Supports weights? | Shift | Scale |
|---|---|---|---|
center() |
✅ | mean(x) or median(x) |
1 |
standardize() |
✅ | mean(x) or median(x) |
sd(x) or mad(x) |
slide() |
❌ | min(x) - lowest |
1 |
reverse() |
❌ | -(max(x)+min(x)) |
-1 |
rescale() |
❌ | min(x)*<scale>-to[1] |
(to[2]-to[1])/(max(x)-min(x)) |
normalize() |
❌ | same as rescale(x,to=c(0,1)+c(-1,1)*include_bounds) where include_bounds is a number [0,1] or 0.5/length(x) |
In any place where a reference= arg is provided, replace x with reference above.
All functions would have to deal with missing values, non-finite values, and labels.
Contributor guide
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.
Assessment
This issue has not been assessed yet.