Skip to content

Commit

Permalink
update OPM example
Browse files Browse the repository at this point in the history
  • Loading branch information
pglpm committed Nov 14, 2024
1 parent 1cb9e9b commit da9829c
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 37 deletions.
4 changes: 2 additions & 2 deletions _freeze/example_opm1/execute-results/html.json

Large diffs are not rendered by default.

Binary file modified _freeze/example_opm1/figure-html/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/example_opm1/figure-html/unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/example_opm1/figure-html/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/example_opm1/figure-html/unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/example_opm1/figure-html/unnamed-chunk-14-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/example_opm1/figure-html/unnamed-chunk-20-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/example_opm1/figure-html/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 30 additions & 31 deletions docs/example_opm1.html
Original file line number Diff line number Diff line change
Expand Up @@ -1002,23 +1002,23 @@ <h3 class="anchored" data-anchor-id="the-rf-function">The <code>rF()</code> func
<pre><code>, , sample = #1

sex
income Female Male
&lt;=50K 28.17199 43.5344
&gt;50K 6.83616 21.4575
income Female Male
&lt;=50K 27.6411 43.5611
&gt;50K 6.9703 21.8275

, , sample = #2

sex
income Female Male
&lt;=50K 28.18455 43.4979
&gt;50K 7.24585 21.0717
&lt;=50K 28.31471 43.1568
&gt;50K 7.21764 21.3108

, , sample = #3

sex
income Female Male
&lt;=50K 28.13035 43.6037
&gt;50K 7.00727 21.2587</code></pre>
&lt;=50K 28.44690 42.0664
&gt;50K 7.28531 22.2014</code></pre>
</div>
</div>
<p>These possible full-population frequency distributions can be used to assess how much the probabilities we find could change, if we collected a much, much larger amount of training data. Here is an example:</p>
Expand All @@ -1037,20 +1037,20 @@ <h3 class="anchored" data-anchor-id="the-rf-function">The <code>rF()</code> func
<div class="cell-output cell-output-stdout">
<pre><code> sex
occupation Female Male
Adm-clerical 0.29 0.32
Armed-Forces 0.16 0.17
Craft-repair 0.17 0.47
Exec-managerial 0.31 0.62
Farming-fishing 0.16 0.23
Handlers-cleaners 0.17 0.19
Machine-op-inspct 0.17 0.29
Other-service 0.20 0.22
Priv-house-serv 0.16 0.16
Prof-specialty 0.36 0.56
Protective-serv 0.16 0.28
Sales 0.22 0.49
Tech-support 0.21 0.30
Transport-moving 0.16 0.31</code></pre>
Adm-clerical 0.28 0.33
Armed-Forces 0.15 0.16
Craft-repair 0.17 0.48
Exec-managerial 0.29 0.59
Farming-fishing 0.17 0.23
Handlers-cleaners 0.16 0.20
Machine-op-inspct 0.17 0.28
Other-service 0.21 0.23
Priv-house-serv 0.17 0.16
Prof-specialty 0.35 0.59
Protective-serv 0.17 0.29
Sales 0.21 0.50
Tech-support 0.19 0.29
Transport-moving 0.17 0.30</code></pre>
</div>
</div>
<p>the agent believes (at around 68%) that the current probability wouldn’t change more than about ±0.5%.</p>
Expand Down Expand Up @@ -1099,15 +1099,14 @@ <h3 class="anchored" data-anchor-id="exploring-the-population-properties-mutual-
<span id="cb25-9"><a href="#cb25-9" aria-hidden="true" tabindex="-1"></a><span class="fu">names</span>(relevances) <span class="ot">&lt;-</span> predictors</span>
<span id="cb25-10"><a href="#cb25-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb25-11"><a href="#cb25-11" aria-hidden="true" tabindex="-1"></a><span class="do">## calculate, for each variate,</span></span>
<span id="cb25-12"><a href="#cb25-12" aria-hidden="true" tabindex="-1"></a><span class="do">## the joint probability distribution 'probs'</span></span>
<span id="cb25-13"><a href="#cb25-13" aria-hidden="true" tabindex="-1"></a><span class="do">## and then mutual information 'relevance' (in shannons)</span></span>
<span id="cb25-14"><a href="#cb25-14" aria-hidden="true" tabindex="-1"></a><span class="do">## between 'income' and that variate</span></span>
<span id="cb25-15"><a href="#cb25-15" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span>(var <span class="cf">in</span> predictors){</span>
<span id="cb25-16"><a href="#cb25-16" aria-hidden="true" tabindex="-1"></a> relevances[var] <span class="ot">&lt;-</span> <span class="fu">mutualinfo</span>(<span class="at">agent =</span> opmall, <span class="at">A =</span> <span class="st">'income'</span>, <span class="at">B =</span> var)</span>
<span id="cb25-17"><a href="#cb25-17" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb25-18"><a href="#cb25-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb25-19"><a href="#cb25-19" aria-hidden="true" tabindex="-1"></a><span class="do">## output the mutual informations in decreasing order</span></span>
<span id="cb25-20"><a href="#cb25-20" aria-hidden="true" tabindex="-1"></a><span class="fu">sort</span>(relevances, <span class="at">decreasing =</span> <span class="cn">TRUE</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span id="cb25-12"><a href="#cb25-12" aria-hidden="true" tabindex="-1"></a><span class="do">## and the mutual information 'relevance' (in shannons)</span></span>
<span id="cb25-13"><a href="#cb25-13" aria-hidden="true" tabindex="-1"></a><span class="do">## between 'income' and that variate</span></span>
<span id="cb25-14"><a href="#cb25-14" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span>(var <span class="cf">in</span> predictors){</span>
<span id="cb25-15"><a href="#cb25-15" aria-hidden="true" tabindex="-1"></a> relevances[var] <span class="ot">&lt;-</span> <span class="fu">mutualinfo</span>(<span class="at">agent =</span> opmall, <span class="at">A =</span> <span class="st">'income'</span>, <span class="at">B =</span> var)</span>
<span id="cb25-16"><a href="#cb25-16" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb25-17"><a href="#cb25-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb25-18"><a href="#cb25-18" aria-hidden="true" tabindex="-1"></a><span class="do">## output the mutual informations in decreasing order</span></span>
<span id="cb25-19"><a href="#cb25-19" aria-hidden="true" tabindex="-1"></a><span class="fu">sort</span>(relevances, <span class="at">decreasing =</span> <span class="cn">TRUE</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>marital_status relationship education occupation workclass
0.10074130 0.09046621 0.06332052 0.05506897 0.03002995
Expand Down Expand Up @@ -1177,7 +1176,7 @@ <h2 data-number="35.6" class="anchored" data-anchor-id="example-application-to-n
<span id="cb27-28"><a href="#cb27-28" aria-hidden="true" tabindex="-1"></a><span class="do">## Print total time required</span></span>
<span id="cb27-29"><a href="#cb27-29" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(<span class="fu">Sys.time</span>() <span class="sc">-</span> stopwatch)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Time difference of 4.23584 secs</code></pre>
<pre><code>Time difference of 4.21148 secs</code></pre>
</div>
<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="do">## Histogram and average accuracy (rounded to one decimal)</span></span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a><span class="fu">myhist</span>(testprobs, <span class="at">n =</span> <span class="fu">seq</span>(<span class="dv">0</span>,<span class="dv">1</span>,<span class="at">length.out =</span> <span class="dv">10</span>), <span class="at">plot =</span> <span class="cn">TRUE</span>,</span>
Expand Down
Binary file modified docs/example_opm1_files/figure-html/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example_opm1_files/figure-html/unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example_opm1_files/figure-html/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example_opm1_files/figure-html/unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example_opm1_files/figure-html/unnamed-chunk-14-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example_opm1_files/figure-html/unnamed-chunk-20-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example_opm1_files/figure-html/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit da9829c

Please sign in to comment.