-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
type Cardinality | ||
|
||
A trait describing the cardinality of a [`Transform`]. Available cardinalities are: | ||
[`OneToOne`](@ref), [`ManyToOne`](@ref), [`OneToMany`](@ref), and [`ManyToMany`](@ref). | ||
""" | ||
abstract type Cardinality end | ||
|
||
""" | ||
OneToOne <: Cardinality | ||
|
||
Transforms that map each input to exactly one output: `x → y`. | ||
Examples: [`Power`](@ref), [`Periodic`](@ref). | ||
""" | ||
struct OneToOne <: Cardinality end | ||
|
||
""" | ||
ManyToOne <: Cardinality | ||
|
||
Transforms that map many inputs to one output: `(x_1, x_2, ..., x_n) → y`. | ||
These are typically reduction operations. | ||
Examples: [`LinearCombination`](@ref). | ||
""" | ||
struct ManyToOne <: Cardinality end | ||
|
||
""" | ||
OneToMany <: Cardinality | ||
|
||
Transforms that map one input to many outputs: `x → (y_1, y_2, ..., y_n)`. | ||
Examples: [`OneHotEncoding`](@ref). | ||
""" | ||
struct OneToMany <: Cardinality end | ||
|
||
""" | ||
ManyToMany <: Cardinality | ||
|
||
Transforms that map many inputs to many outputs: `(x_1, x_2, ..., x_m) → (y_1, y_2, ..., y_n)`. | ||
Examples: Principle Component Analysis (not implemented). | ||
""" | ||
struct ManyToMany <: Cardinality end | ||
|
||
|
||
""" | ||
cardinality(transform) -> Cardinality | ||
|
||
Returns the [`Cardinality`](@ref) of the `transform`. | ||
""" | ||
function cardinality end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially thought defining There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 The other point I was making is, why should every instance of a given 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
This means e.g.
vs.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@testset "traits.jl" begin | ||
for t in (OneToOne(), OneToMany(), ManyToOne(), ManyToMany()) | ||
@test t isa FeatureTransforms.Cardinality | ||
end | ||
end |
There was a problem hiding this comment.
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