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

RFC: Composite transform #108

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

RFC: Composite transform #108

wants to merge 5 commits into from

Conversation

mzgubic
Copy link
Contributor

@mzgubic mzgubic commented May 17, 2022

Closes #105

In the present form, it is limited to OneToOne() component transforms, which have the same keyword arguments when calling apply.

In order to generalise Composite transforms the keyword arguments should become a part of the constructor rather than being passed in the apply call.

Todo:

  • add this stuff to the docs

@codecov
Copy link

codecov bot commented May 17, 2022

Codecov Report

Merging #108 (d18b668) into main (4a636c8) will increase coverage by 0.63%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   98.88%   99.51%   +0.63%     
==========================================
  Files          15       16       +1     
  Lines         179      208      +29     
==========================================
+ Hits          177      207      +30     
+ Misses          2        1       -1     
Impacted Files Coverage Δ
src/FeatureTransforms.jl 100.00% <ø> (ø)
src/composite.jl 100.00% <100.00%> (ø)
src/traits.jl 100.00% <100.00%> (ø)
src/scaling.jl 100.00% <0.00%> (+4.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a636c8...d18b668. Read the comment docs.

src/composite.jl Outdated Show resolved Hide resolved
src/traits.jl Outdated Show resolved Hide resolved
Comment on lines +7 to +9
The transforms in `Composite([t1, t2, t3])` are applied in `t1`, `t2`, `t3` order, where
the output of `t1` is the input to `t2` etc. When using `∘` to create transforms, the order
is `t3 ∘ t2 ∘ t1`, as in function composition.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm...that might get confusing...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had it the other way around first but the issue then is that the c.transforms[1] is the last transform that is applied, which is even more confusing I think.

The only totally non-confusing way is to get rid of the syntactic sugar, which is what switches the order.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only totally non-confusing way is to get rid of the ∘ syntactic sugar, which is what switches the order.

I wouldn't be against this tbh, but it might be handy for building pipelines of transforms like

tc = Composite(t1, t2)
...
...
tc = t3  tc
...
tc = t4  tc

so I can see value in it being used that way

@@ -46,3 +46,13 @@ struct ManyToMany <: Cardinality end
Returns the [`Cardinality`](@ref) of the `transform`.
"""
function cardinality end

Base.:(∘)(::OneToOne, ::OneToOne) = OneToOne()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if is the right syntax here... it's used to compose functions whereas here we're sort of "reducing" over the cardinalities.
I guess it makes sense in the context of composing the equivalent transforms?

If we do go for it then becomes part of the Cardinality API and should be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative is to have an internal _compose function which would do this instead? I don't think users need to use this at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah making it internal would indicate it shouldn't be used publically

Comment on lines +14 to +15
@test_throws ArgumentError id ∘ LinearCombination([1, 2, 3])
@test_throws ArgumentError OneHotEncoding([1, 2]) ∘ id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively we could use test_skip until these are implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make sure there is an actual error, so possibly @test_broken is the right thing

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

Successfully merging this pull request may close these issues.

Composite Transforms
2 participants