MLDataPattern.jl icon indicating copy to clipboard operation
MLDataPattern.jl copied to clipboard

Support of NamedTuples

Open xukai92 opened this issue 5 years ago • 2 comments
trafficstars

This should be supported.

dataset = (x=rand(10), y=rand(2, 10))
for batch in eachbatch(dataset; size=3)
    # do something with batch.x and batch.y
end

xukai92 avatar Jan 16 '20 17:01 xukai92

This is a significant part of https://github.com/JuliaML/MLDataUtils.jl/issues/46

Since a named tuple of vectos is a valid Tables.jl ColumnTable

So solving this would make big steps towards Tables.jl compat.

oxinabox avatar Jan 18 '20 20:01 oxinabox

As a short term workaround if you load MLDataUtils, DataFrames support will be loaded, and then you can do:

dataset = (x=rand(10), y=rand(2, 10))
df = DataFrame(dataset)
for batch in eachbatch(df; size=3)
    # do something with batch.x and batch.y
end

oxinabox avatar Jan 18 '20 20:01 oxinabox