getobs
function
defined in module
MLUtils
getobs(data, [idx])
Return the observations corresponding to the observation index
idx
. Note that
idx
can be any type as long as
data
has defined
getobs
for that type. If
idx
is not provided, then materialize all observations in
data
.
If
data
does not have
getobs
defined, then in the case of
Tables.table(data) == true
returns the row(s) in position
idx
, otherwise returns
data[idx]
.
Authors of custom data containers should implement
Base.getindex
for their type instead of
getobs
.
getobs
should only be implemented for types where there is a difference between
getobs
and
Base.getindex
(such as multi-dimensional arrays).
The returned observation(s) should be in the form intended to be passed as-is to some learning algorithm. There is no strict interface requirement on how this "actual data" must look like. Every author behind some custom data container can make this decision themselves. The output should be consistent when
idx
is a scalar vs vector.
getobs
supports by default nested combinations of array, tuple, named tuples, and dictionaries.
# named tuples
x = (a = [1, 2, 3], b = rand(6, 3))
getobs(x, 2) == (a = 2, b = x.b[:, 2])
getobs(x, [1, 3]) == (a = [1, 3], b = x.b[:, [1, 3]])
# dictionaries
x = Dict(:a => [1, 2, 3], :b => rand(6, 3))
getobs(x, 2) == Dict(:a => 2, :b => x[:b][:, 2])
getobs(x, [1, 3]) == Dict(:a => [1, 3], :b => x[:b][:, [1, 3]])
There are
16
methods for MLUtils.getobs
:
The following pages link back here:
Blocks and encodings, Custom learning tasks, Data containers, Discovery, Feature registries in FastAI.jl, How to visualize data, Image segmentation, Introduction, Keypoint regression, New visualization tools for FastAI.jl, Performant data pipelines, Presizing vision datasets for performance, Saving and loading models for inference, Siamese image similarity, Tabular Classification, Text Classification, TimeSeries Classification, Variational autoencoders, tsregression
FastAI.jl , datasets/Datasets.jl , datasets/recipe.jl , tasks/taskdata.jl , training/utils.jl , FastTabular.jl , recipes.jl , FastVision.jl , blocks/image.jl , encodings/imagepreprocessing.jl , MLUtils.jl , batchview.jl , eachobs.jl , observation.jl , obstransform.jl , obsview.jl , parallel.jl , randobs.jl , utils.jl