JuliaML / MLUtils.jl

Utilities and abstractions for Machine Learning tasks
MIT License
109 stars 22 forks source link

define `numobs` and `getobs` fallbacks for Tables.jl's tables? #41

Closed CarloLucibello closed 2 years ago

CarloLucibello commented 2 years ago

We could implement a generic fallback like:

function numobs(x) 
  if Tables.istable(x)
    length(Tables.rows(x))
  else
    error("numobs not defined")
  end
end

function getobs(x, i) 
  if Tables.istable(x)
    Tables.rows(x)[i]
  else
    error("numobs not defined")
  end
end
darsnack commented 2 years ago

The TableDataset that will be ported from FastAI to MLDatasets supports this along with faster paths for specific implementations of the Tables.jl interface.