-
Notifications
You must be signed in to change notification settings - Fork 54
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
materializer
for matrix tables
#281
Comments
You mean something like I must be missing something, as julia> X = [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> Tables.materializer(X)
columntable (generic function with 5 methods)
julia> Tables.materializer(X)(X)
ERROR: ArgumentError: a 'Matrix{Int64}' is not a table; see `?Tables.table` for ways to treat an AbstractVecOrMat as a table
Stacktrace:
[1] columns(m::Matrix{Int64})
@ Tables ~/.julia/packages/Tables/M26tI/src/matrix.jl:5
[2] columntable(itr::Matrix{Int64})
@ Tables ~/.julia/packages/Tables/M26tI/src/namedtuples.jl:171
[3] top-level scope
@ REPL[10]:1 |
No. Currently, we have: using Tables
matrix_table = Tables.table(rand(2,3))
some_table = [(x=1, y=2), (x=3, y=4)]
julia> Tables.materializer(matrix_table)(some_table)
(x = [1, 3], y = [2, 4]) I'm getting a column table for the last call because that's the fallback behaviour for |
OK, makes sense. So that would mean |
Syntactically, that would work for my use-case. However, I'm not sure that would be ideal as an implementation. I was hoping that |
Yeah we could define a separate function with a fallback method calling |
Perfect. |
This is not currently overloaded, ie, falls back to columntable.
In MLJ (and elsewhere) core models operate on matrices. An MLJ interface for a model accepts a table
X
, converts it to a matrix (using Tables.matrix) and reports any output as a table usingmaterializer(X)(Xout)
. This is currently leading to unnecessary copying and computation in the last step.Is there an overloading of
materializer
for matrix tables that Tables.jl would be willing to implement to address this use case?The text was updated successfully, but these errors were encountered: