|
50 | 50 | y = rand("ABC", 1000) |> categorical |
51 | 51 | ŷ = rand("ABC", 1000) |> categorical |
52 | 52 | class_weights = Dict('A' => 1, 'B' =>2, 'C' => 10) |
53 | | -MulticlassFScore(beta=0.5, average=MacroAvg())(ŷ, y, class_weights)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">1.403740884019081</code></pre><pre><code class="language-julia hljs">MulticlassFScore(beta=0.5, average=NoAvg())(ŷ, y, class_weights)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">LittleDict{CategoricalArrays.CategoricalValue{Char, UInt32}, Float64, Tuple{CategoricalArrays.CategoricalValue{Char, UInt32}, CategoricalArrays.CategoricalValue{Char, UInt32}, CategoricalArrays.CategoricalValue{Char, UInt32}}, Tuple{Float64, Float64, Float64}} with 3 entries: |
54 | | - 'A' => 0.302752 |
55 | | - 'B' => 0.695027 |
56 | | - 'C' => 3.21344</code></pre><p>Unseen classes are tracked, when using <code>CategoricalArrays</code>, as here:</p><pre><code class="language-julia hljs"># find 'C'-free indices |
| 53 | +MulticlassFScore(beta=0.5, average=MacroAvg())(ŷ, y, class_weights)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">1.391308358413436</code></pre><pre><code class="language-julia hljs">MulticlassFScore(beta=0.5, average=NoAvg())(ŷ, y, class_weights)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">LittleDict{CategoricalArrays.CategoricalValue{Char, UInt32}, Float64, Tuple{CategoricalArrays.CategoricalValue{Char, UInt32}, CategoricalArrays.CategoricalValue{Char, UInt32}, CategoricalArrays.CategoricalValue{Char, UInt32}}, Tuple{Float64, Float64, Float64}} with 3 entries: |
| 54 | + 'A' => 0.362595 |
| 55 | + 'B' => 0.612121 |
| 56 | + 'C' => 3.19921</code></pre><p>Unseen classes are tracked, when using <code>CategoricalArrays</code>, as here:</p><pre><code class="language-julia hljs"># find 'C'-free indices |
57 | 57 | mask = y .!= 'C' .&& ŷ .!= 'C'; |
58 | 58 | # remove observations with 'C' class:: |
59 | 59 | y = y[mask] |
|
63 | 63 | ┌─────────┼────┬────┬────┤ |
64 | 64 | │Predicted│ A │ B │ C │ |
65 | 65 | ├─────────┼────┼────┼────┤ |
66 | | -│ A │ 99 │113 │ 0 │ |
| 66 | +│ A │133 │119 │ 0 │ |
67 | 67 | ├─────────┼────┼────┼────┤ |
68 | | -│ B │105 │116 │ 0 │ |
| 68 | +│ B │119 │101 │ 0 │ |
69 | 69 | ├─────────┼────┼────┼────┤ |
70 | 70 | │ C │ 0 │ 0 │ 0 │ |
71 | 71 | └─────────┴────┴────┴────┘ |
|
131 | 131 |
|
132 | 132 | y = rand(20) |
133 | 133 | ŷ = [Normal(rand(), 0.5) for i in 1:20] |
134 | | -ŷ[1]</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Distributions.Normal{Float64}(μ=0.6760416112174623, σ=0.5)</code></pre><pre><code class="language-julia hljs">log_loss(ŷ, y)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">0.5274106046708487</code></pre><pre><code class="language-julia hljs">weights = rand(20) |
135 | | -log_loss(ŷ, y, weights)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">0.23035335007266244</code></pre><pre><code class="language-julia hljs">weights = rand(20) |
| 134 | +ŷ[1]</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Distributions.Normal{Float64}(μ=0.5046317056465599, σ=0.5)</code></pre><pre><code class="language-julia hljs">log_loss(ŷ, y)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">0.5099991053893037</code></pre><pre><code class="language-julia hljs">weights = rand(20) |
| 135 | +log_loss(ŷ, y, weights)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">0.27170298589290603</code></pre><pre><code class="language-julia hljs">weights = rand(20) |
136 | 136 | measurements(log_loss, ŷ, y, weights)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">20-element Vector{Float64}: |
137 | | - 0.08598372983442924 |
138 | | - 0.1459889230627991 |
139 | | - 0.051802805417811806 |
140 | | - 0.2217504144582199 |
141 | | - 0.16589868333198188 |
142 | | - 0.21225942278730364 |
143 | | - 0.08857294080537546 |
144 | | - 0.2184684183453816 |
145 | | - 0.3456516041781843 |
146 | | - 0.06446747907142204 |
147 | | - 0.14507425242462074 |
148 | | - 0.17083022589052202 |
149 | | - 0.09509955486473907 |
150 | | - 0.17000915541325654 |
151 | | - 0.30797703937333987 |
152 | | - 1.309584977239192 |
153 | | - 0.3616317504620074 |
154 | | - 1.52607837927812 |
155 | | - 0.03684630137545178 |
156 | | - 0.26453853985068504</code></pre><p>An example with <code>Count</code> (integer) data:</p><pre><code class="language-julia hljs">y = rand(1:10, 20) |
| 137 | + 0.2128738071383313 |
| 138 | + 0.22957050441003543 |
| 139 | + 0.4722403962181681 |
| 140 | + 0.3756187486610114 |
| 141 | + 0.33047213993360436 |
| 142 | + 0.2830516388124885 |
| 143 | + 0.2972192805683936 |
| 144 | + 0.08462056829825945 |
| 145 | + 0.22584981898693662 |
| 146 | + 0.23202311294297379 |
| 147 | + 0.3000779772834867 |
| 148 | + 1.1628907364241037 |
| 149 | + 0.17309754135559513 |
| 150 | + 0.4935270619734014 |
| 151 | + 0.12237900102037948 |
| 152 | + 0.09231568057657659 |
| 153 | + 0.6111693143451427 |
| 154 | + 0.03129926850732532 |
| 155 | + 0.19075789284388409 |
| 156 | + 0.15812995264948143</code></pre><p>An example with <code>Count</code> (integer) data:</p><pre><code class="language-julia hljs">y = rand(1:10, 20) |
157 | 157 | ŷ = [Poisson(10*rand()) for i in 1:20] |
158 | | -ŷ[1]</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Distributions.Poisson{Float64}(λ=7.708073055499032)</code></pre><pre><code class="language-julia hljs">brier_loss(ŷ, y)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">0.04393798725333948</code></pre><h2 id="Custom-multi-target-measures"><a class="docs-heading-anchor" href="#Custom-multi-target-measures">Custom multi-target measures</a><a id="Custom-multi-target-measures-1"></a><a class="docs-heading-anchor-permalink" href="#Custom-multi-target-measures" title="Permalink"></a></h2><p>Here's an example of constructing a multi-target regression measure, for data with 3 observations of a 2-component target:</p><pre><code class="language-julia hljs">using StatisticalMeasures |
| 158 | +ŷ[1]</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Distributions.Poisson{Float64}(λ=3.3810443315127916)</code></pre><pre><code class="language-julia hljs">brier_loss(ŷ, y)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">0.007532735696796258</code></pre><h2 id="Custom-multi-target-measures"><a class="docs-heading-anchor" href="#Custom-multi-target-measures">Custom multi-target measures</a><a id="Custom-multi-target-measures-1"></a><a class="docs-heading-anchor-permalink" href="#Custom-multi-target-measures" title="Permalink"></a></h2><p>Here's an example of constructing a multi-target regression measure, for data with 3 observations of a 2-component target:</p><pre><code class="language-julia hljs">using StatisticalMeasures |
159 | 159 |
|
160 | 160 | # last index is observation index: |
161 | 161 | y = ["X" "O" "O"; "O" "X" "X"] |
|
202 | 202 | RootMeanSquaredProportionalError => (aliases = ("rmsp",), consumes_multipl… |
203 | 203 | MeanAbsoluteProportionalError => (aliases = ("mape",), consumes_multipl… |
204 | 204 | LogCoshLoss => (aliases = ("log_cosh", "log_cosh_loss…</code></pre><pre><code class="language-julia hljs">options[LPLoss]</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">(aliases = ("l1", "l2", "mae", "mav", "mean_absolute_error", "mean_absolute_value"), consumes_multiple_observations = true, can_report_unaggregated = true, kind_of_proxy = Point(), observation_scitype = Union{Missing, Infinite}, can_consume_tables = false, supports_weights = true, supports_class_weights = true, orientation = Loss(), external_aggregation_mode = Mean(), human_name = "``L^p`` loss")</code></pre><pre><code class="language-julia hljs">measures("Matthew")</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">LittleDict{Any, Any, Vector{Any}, Vector{Any}} with 1 entry: |
205 | | - MatthewsCorrelation => (aliases = ("matthews_correlation", "mcc"), consumes_m…</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Overview</a><a class="docs-footer-nextpage" href="../auto_generated_list_of_measures/">The Measures »</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.14.1 on <span class="colophon-date" title="Monday 22 September 2025 20:25">Monday 22 September 2025</span>. Using Julia version 1.11.7.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
| 205 | + MatthewsCorrelation => (aliases = ("matthews_correlation", "mcc"), consumes_m…</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Overview</a><a class="docs-footer-nextpage" href="../auto_generated_list_of_measures/">The Measures »</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.14.1 on <span class="colophon-date" title="Sunday 19 October 2025 07:49">Sunday 19 October 2025</span>. Using Julia version 1.12.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
0 commit comments