The motivational problem I have is I’m trying to make a data pipeline to calculate features from observations.
I’m gonna jump into an example, let’s say I’m working with real estate data. Observations look like this:
struct Data
street::String
squarefoot::Int64
floors::Int64
...
end
Then I can define feature methods that are all of the following “type”:
feature_function :: Data -> SomeType
such as
street(d::Data) = d.street
logsqft(d::Data) = log(d.squarefoot)
I can construct models and pair them with appropriate feature methods. Then I just need to build some generic code to go over the data with the supplied feature methods and return for the model to use. I can do this but I was wondering if it’s possible to make the code type stable. For example, as I understand the following method is not type stable.
extract(fs::Vector{Function}, d::Data) = Tuple(f(d) for f in fs)
Since the type of extract([street, logsqft], d)
is not the same as extract([logsqft, street], d)
. I was trying to figure out if I could do this with type selectors and traits but I couldn’t think of a way.
Is there a Julian way to go about this? I think I can live with this type instability but I wanted to check if there’s a solution here that I missed.