|
65 | 65 | ytrain = y[train] |
66 | 66 | model = fit(learner, (Xtrain, ytrain)) # `fit(learner, Xtrain, ytrain)` will also work |
67 | 67 | ŷ = predict(model, Tables.subset(X, test))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">4-element Vector{Float64}: |
68 | | - 1.6381440393743048 |
69 | | - 0.5502900718394842 |
70 | | - 1.3178110421645899 |
71 | | - 1.9421285960183923</code></pre><p>Extracting coefficients:</p><pre><code class="language-julia hljs">LearnAPI.coefficients(model)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">3-element Vector{Pair{Symbol, Float64}}: |
72 | | - :a => 1.3279266086695747 |
73 | | - :b => 0.5276843405826362 |
74 | | - :c => 2.2366558130159606</code></pre><p>Serialization/deserialization:</p><pre><code class="language-julia hljs">using Serialization |
| 68 | + 1.291829211864996 |
| 69 | + 1.2089566571179264 |
| 70 | + 1.391070087543948 |
| 71 | + 2.295784442832129</code></pre><p>Extracting coefficients:</p><pre><code class="language-julia hljs">LearnAPI.coefficients(model)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">3-element Vector{Pair{Symbol, Float64}}: |
| 72 | + :a => 1.2176072114088736 |
| 73 | + :b => 0.4843030038325326 |
| 74 | + :c => 1.7735724325211237</code></pre><p>Serialization/deserialization:</p><pre><code class="language-julia hljs">using Serialization |
75 | 75 | small_model = LearnAPI.strip(model) |
76 | 76 | filename = tempname() |
77 | 77 | serialize(filename, small_model)</code></pre><pre><code class="language-julia hljs">recovered_model = deserialize(filename) |
|
139 | 139 | model = fit(learner, MLCore.getobs(observations_for_fit, train)) |
140 | 140 | observations_for_predict = obs(model, X) |
141 | 141 | ẑ = predict(model, MLCore.getobs(observations_for_predict, test))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">4-element Vector{Float64}: |
142 | | - 1.6760957670433079 |
143 | | - 1.1175399187563722 |
144 | | - 1.6147703835667333 |
145 | | - 1.379541336643833</code></pre><pre><code class="language-julia hljs">@assert ẑ == ŷ</code></pre><p>For an application of <a href="../obs/#LearnAPI.obs"><code>obs</code></a> to efficient cross-validation, see <a href="../obs/#obs_workflows">here</a>.</p><hr/><p>¹ In LearnAPI.jl a <em>table</em> is any object <code>X</code> implementing the <a href="https://tables.juliadata.org/dev/">Tables.jl</a> interface, additionally satisfying <code>Tables.istable(X) == true</code> and implementing <code>DataAPI.nrow</code> (and whence <code>MLCore.numobs</code>). Tables that are also (unnamed) tuples are disallowed.</p><p>² An implementation can provide further accessor functions, if necessary, but like the native ones, they must be included in the <a href="../traits/#LearnAPI.functions"><code>LearnAPI.functions</code></a> declaration.</p><p>³ The last index must be the observation index.</p><p>⁴ The <code>data = (X, y)</code> pattern implemented here is not the only supported pattern. For, example, <code>data</code> might be <code>(T, formula)</code> where <code>T</code> is a table and <code>formula</code> is an R-style formula.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../reference/">Overview »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <span class="colophon-date" title="Tuesday 9 December 2025 19:53">Tuesday 9 December 2025</span>. Using Julia version 1.12.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
| 142 | + 2.485558288963432 |
| 143 | + 0.97575144613329 |
| 144 | + 1.4650130971357858 |
| 145 | + 2.1334094124616634</code></pre><pre><code class="language-julia hljs">@assert ẑ == ŷ</code></pre><p>For an application of <a href="../obs/#LearnAPI.obs"><code>obs</code></a> to efficient cross-validation, see <a href="../obs/#obs_workflows">here</a>.</p><hr/><p>¹ In LearnAPI.jl a <em>table</em> is any object <code>X</code> implementing the <a href="https://tables.juliadata.org/dev/">Tables.jl</a> interface, additionally satisfying <code>Tables.istable(X) == true</code> and implementing <code>DataAPI.nrow</code> (and whence <code>MLCore.numobs</code>). Tables that are also (unnamed) tuples are disallowed.</p><p>² An implementation can provide further accessor functions, if necessary, but like the native ones, they must be included in the <a href="../traits/#LearnAPI.functions"><code>LearnAPI.functions</code></a> declaration.</p><p>³ The last index must be the observation index.</p><p>⁴ The <code>data = (X, y)</code> pattern implemented here is not the only supported pattern. For, example, <code>data</code> might be <code>(T, formula)</code> where <code>T</code> is a table and <code>formula</code> is an R-style formula.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../reference/">Overview »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <span class="colophon-date" title="Saturday 20 December 2025 00:28">Saturday 20 December 2025</span>. Using Julia version 1.12.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
0 commit comments