(12, 5)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaML/MLUtils.jl/blob/v0.4.8/src/utils.jl#L380-L394">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="MLCore.getobs" href="#MLCore.getobs"><code>MLCore.getobs</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">getobs(data, [idx])</code></pre><p>Return the observations corresponding to the observation index <code>idx</code>.</p><p>The index <code>idx</code> is an integer with values in the range <code>1:numobs(data)</code>. Types can optionally support <code>idx</code> being an array of integers.</p><p>If <code>data</code> does not have <code>getobs</code> defined, then in the case of <code>Tables.table(data) == true</code> returns the row(s) in position <code>idx</code>, otherwise returns <code>data[idx]</code>.</p><p>Authors of custom data containers should implement <code>Base.getindex</code> for their type instead of <code>getobs</code>. <code>getobs</code> should only be implemented for types where there is a difference between <code>getobs</code> and <code>Base.getindex</code> (such as multi-dimensional arrays).</p><p>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 <code>idx</code> is a scalar vs vector.</p><p><code>getobs</code> supports by default nested combinations of array, tuple, named tuples, and dictionaries. </p><p>The return from <code>getobs</code> should always be a materialized object, not a view, altough it can be a reference to the original data. </p><p>If the argument <code>idx</code> is not provided, <code>getobs(data)</code> should return a materialized version of the data.</p><p>See also <a href="#MLCore.getobs!"><code>getobs!</code></a> and <a href="#MLCore.numobs"><code>numobs</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl hljs">julia> x = (a = [1, 2, 3], b = rand(6, 3));
0 commit comments