{class="subtitle"} Reference for implementing the data container interface. See data containers for an introduction.
To implement the data container interface for a custom type T
, you must implement two functions:
LearnBase.getobs(data::T, i::Int)
loads thei
-th observationLearnBase.nobs(data::T, i::Int)::Int
gives the number of observations in a data container
You can optionally also implement:
LearnBase.getobs!(buf, data::T, i::Int)
: loads thei
-th observation into the preallocated bufferbuf
.
See the MLDataPattern.jl documentation for a comprehensive discussion of and reference for data containers.
!!! note "Extending functions"
To define a method for the above functions, you need to import the functions explicitly. You can do this without installing `LearnBase` by running:
```julia
import DataLoaders.LearnBase: getobs, nobs, getobs!
````