easystats / easystats/datawizard

Simplify code for linear transformers

Open
#332 1 comment 0 reactions 1 assignee View on GitHub

@mattansb is already working on this.

Since Dec 12, 2022.

Consistency :green_apple: :apple: Upkeep :broom:
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.