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

Define cardinality traits #79

Merged
merged 4 commits into from
Apr 16, 2021
Merged

Define cardinality traits #79

merged 4 commits into from
Apr 16, 2021

Conversation

glennmoy
Copy link
Member

First step towards #75 is to define the various traits and add them to the existing transforms

@@ -1,7 +1,7 @@
name = "FeatureTransforms"
uuid = "8fd68953-04b8-4117-ac19-158bf6de9782"
authors = ["Invenia Technical Computing Corporation"]
version = "0.3.2"
version = "0.3.3-DEV"
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to follow up with TestUtils before tagging a release

@codecov
Copy link

codecov bot commented Apr 16, 2021

Codecov Report

Merging #79 (d74ecbc) into main (aa43348) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
+ Coverage   99.10%   99.18%   +0.07%     
==========================================
  Files          10       11       +1     
  Lines         112      122      +10     
==========================================
+ Hits          111      121      +10     
  Misses          1        1              
Impacted Files Coverage Δ
src/FeatureTransforms.jl 100.00% <ø> (ø)
src/linear_combination.jl 100.00% <100.00%> (ø)
src/one_hot_encoding.jl 100.00% <100.00%> (ø)
src/periodic.jl 100.00% <100.00%> (ø)
src/power.jl 100.00% <100.00%> (ø)
src/scaling.jl 100.00% <100.00%> (ø)
src/temporal.jl 100.00% <100.00%> (ø)
src/traits.jl 100.00% <100.00%> (ø)

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 aa43348...d74ecbc. Read the comment docs.

Copy link
Contributor

@bencottier bencottier left a comment

Choose a reason for hiding this comment

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

Looks good to me


Returns the [`Cardinality`](@ref) of the `transform`.
"""
function cardinality end
Copy link
Contributor

Choose a reason for hiding this comment

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

I initially thought defining cardinality on instances rather than types seemed redundant in a way. And that cardinality for each subtype of AbstractScaling seemed redundant. But I realised it's how traits are supposed to work right?

Copy link
Member Author

@glennmoy glennmoy Apr 16, 2021

Choose a reason for hiding this comment

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

I'm not sure I understand.
I could/should have defined the cardinality on AbstractScaling, which would have covered MeanStdScaling and IdentityScaling. In case another type of scaling comes along that's ManyToOne it would have to be special-cased in that instance. Is that what you're getting at?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that's partly what I was thinking. For some reason thought defining cardinality on AbstractScaling wouldn't work because it was an abstract type, so I didn't comment on that directly.

The other point I was making is, why should every instance of a given Transform subtype have this trait, when the trait is the same between all instances? Conceptually, cardinality belongs more with the type than the instances.

I backed off on that because I figured traits, as a design pattern, apply to instances. But I'm not even sure about that - is it a valid point?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh right, well they can apply to both.

You'll see I've changed the code so that cardinality now applies to AbstractScaling.
In that case it made more sense to attach it to the type because all concrete subtypes will have the same behaviour.

But I attached it directly to the concrete types of all other transforms because they don't have abstract supertype (besides Transform) to define it for. And if I defined it for Transform outright then users won't know they have to define it themselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep that looks fine. Still not sure if I got this across though:

why should every instance of a given Transform subtype have this trait, when the trait is the same between all instances? Conceptually, cardinality belongs more with the type than the instances.

This means e.g.

julia> cardinality(T) where T <: Power = OneToOne()

julia> cardinality(Power) 
OneToOne

vs.

julia> cardinality(::Power) = OneToOne()

julia> cardinality(Power(2))
OneToOne

@glennmoy glennmoy enabled auto-merge April 16, 2021 11:11
@glennmoy glennmoy merged commit f66d6a4 into main Apr 16, 2021
@glennmoy glennmoy deleted the gm/addtraits branch April 16, 2021 11:17
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.

2 participants