Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No-arg MeanStdScaling constructor #59

Closed
rofinn opened this issue Mar 21, 2021 · 3 comments · Fixed by #107
Closed

No-arg MeanStdScaling constructor #59

rofinn opened this issue Mar 21, 2021 · 3 comments · Fixed by #107

Comments

@rofinn
Copy link
Member

rofinn commented Mar 21, 2021

In many cases, we're gonna call apply with the same array data that was used to construct the MeanstdScaling transform, so why not provide a no-arg constructor and computing the mean and std on the fly in the apply call? I guess that would make the fields Union{Real, Nothing}.

@glennmoy
Copy link
Member

@bencottier might also remember, but I think one reason we favoured immutable struct was to prevent the user from recycling the same scaling and potentially getting confused.

But I guess we could allow mutability iff the fields are nothing.

@bencottier
Copy link
Contributor

@bencottier might also remember, but I think one reason we favoured immutable struct was to prevent the user from recycling the same scaling and potentially getting confused.

The other reason was saving code. We'd need to overload apply. This reason feels weaker than at the time of the original PR. In general I now feel more ok with overloading apply to add convenience. Also I think there'd be less overloading necessary after apply became the default (#25 ).

@AlexRobson
Copy link
Member

AlexRobson commented Dec 6, 2021

A no-arg MeanStdScaling transform makes sense. We were just looking at swapping around transforms but at present, this means that we would need to handle the cases differently. e.g. comparing MeanStdScaling and LogTransform (recently added, but it applies to most (all?) other transforms that are not <:AbstractScaling)

function pipeline(x,...)
   ...
   transform = MeanStdScaling(x)
   ...
end
function pipeline(x,...)
   ...
   transform = LogTransform(x) # Would error
   ...
end

As @mzgubic points out, this requires separating out the constructor and the fitting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants