Skip to content

Commit

Permalink
build based on 07c815e
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Nov 23, 2024
1 parent b984c35 commit 686d1d3
Show file tree
Hide file tree
Showing 34 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-22T19:20:23","documenter_version":"1.8.0"}}
{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-23T03:23:54","documenter_version":"1.8.0"}}
4 changes: 2 additions & 2 deletions dev/accessor_functions/index.html

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions dev/anatomy_of_an_implementation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@
ytrain = y[train]
model = fit(learner, (Xtrain, ytrain)) # `fit(learner, Xtrain, ytrain)` will also work
ŷ = predict(model, Tables.subset(X, test))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">4-element Vector{Float64}:
1.358327084415597
2.0721462505804116
2.740111455058097
1.6298424113867953</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}}:
:a =&gt; 1.504741134142752
:b =&gt; -0.2769584147891986
:c =&gt; 2.346402561554166</code></pre><p>Serialization/deserialization:</p><pre><code class="language-julia hljs">using Serialization
1.0996536366169987
1.381804862761543
1.2181834770601387
1.1713459291897015</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}}:
:a =&gt; 1.7735675763376675
:b =&gt; -0.1347181083742321
:c =&gt; 1.7236884328781064</code></pre><p>Serialization/deserialization:</p><pre><code class="language-julia hljs">using Serialization
small_model = LearnAPI.strip(model)
filename = tempname()
serialize(filename, small_model)</code></pre><pre><code class="language-julia hljs">recovered_model = deserialize(filename)
@assert LearnAPI.learner(recovered_model) == learner
@assert predict(recovered_model, X) == predict(model, X)</code></pre><h2 id="Providing-a-separate-data-front-end"><a class="docs-heading-anchor" href="#Providing-a-separate-data-front-end">Providing a separate data front end</a><a id="Providing-a-separate-data-front-end-1"></a><a class="docs-heading-anchor-permalink" href="#Providing-a-separate-data-front-end" title="Permalink"></a></h2><p>An implementation may optionally implement <a href="../obs/#LearnAPI.obs"><code>obs</code></a>, to expose to the user (or some meta-algorithm like cross-validation) the representation of input data internal to <code>fit</code> or <code>predict</code>, such as the matrix version <code>A</code> of <code>X</code> in the ridge example. That is, we may factor out of <code>fit</code> (and also <code>predict</code>) the data pre-processing step, <code>obs</code>, to expose its outcomes. These outcomes become alternative user inputs to <code>fit</code>. To see the use of <code>obs</code> in action, see <a href="#advanced_demo">below</a>.</p><p>Here we specifically wrap all the pre-processed data into single object, for which we introduce a new type:</p><pre><code class="language-julia hljs">struct RidgeFitObs{T,M&lt;:AbstractMatrix{T}}
@assert predict(recovered_model, X) == predict(model, X)</code></pre><h2 id="Providing-a-separate-data-front-end"><a class="docs-heading-anchor" href="#Providing-a-separate-data-front-end">Providing a separate data front end</a><a id="Providing-a-separate-data-front-end-1"></a><a class="docs-heading-anchor-permalink" href="#Providing-a-separate-data-front-end" title="Permalink"></a></h2><p>An implementation may optionally implement <a href="../obs/#LearnAPI.obs"><code>obs</code></a>, to expose to the user (or some meta-algorithm like cross-validation) the representation of input data internal to <code>fit</code> or <code>predict</code>, such as the matrix version <code>A</code> of <code>X</code> in the ridge example. That is, we may factor out of <code>fit</code> (and also <code>predict</code>) the data pre-processing step, <code>obs</code>, to expose its outcomes. These outcomes become alternative user inputs to <code>fit</code>/<code>predict</code>. To see the use of <code>obs</code> in action, see <a href="#advanced_demo">below</a>.</p><p>Here we specifically wrap all the pre-processed data into single object, for which we introduce a new type:</p><pre><code class="language-julia hljs">struct RidgeFitObs{T,M&lt;:AbstractMatrix{T}}
A::M # `p` x `n` matrix
names::Vector{Symbol} # features
y::Vector{T} # target
Expand Down Expand Up @@ -127,7 +127,7 @@
model = fit(learner, MLUtils.getobs(observations_for_fit, train))
observations_for_predict = obs(model, X)
ẑ = predict(model, MLUtils.getobs(observations_for_predict, test))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">4-element Vector{Float64}:
1.4918385169030537
1.5673015490243523
2.102392904908139
1.7192917704382902</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>MLUtils.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 a single table containing both features and target variable. In this case, it will be necessary to overload <a href="../target_weights_features/#LearnAPI.features"><code>LearnAPI.features</code></a> in addition to <a href="../target_weights_features/#LearnAPI.target"><code>LearnAPI.target</code></a>; the name of the target column would need to be a hyperparameter.</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.8.0 on <span class="colophon-date" title="Friday 22 November 2024 19:20">Friday 22 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2.97437091630596
1.5788797384731128
1.1061881145341006
2.1645578421531226</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>MLUtils.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.8.0 on <span class="colophon-date" title="Saturday 23 November 2024 03:23">Saturday 23 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 686d1d3

Please sign in to comment.