mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 06:02:01 +02:00
con WHONET, filter ab class
This commit is contained in:
@ -40,7 +40,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9020</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9021</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<h1>Benchmarks</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">02 March 2019</h4>
|
||||
<h4 class="date">05 March 2019</h4>
|
||||
|
||||
|
||||
<div class="hidden name"><code>benchmarks.Rmd</code></div>
|
||||
@ -217,14 +217,14 @@
|
||||
<a class="sourceLine" id="cb2-8" title="8"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
|
||||
<a class="sourceLine" id="cb2-9" title="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb2-10" title="10"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#> as.mo("sau") 16.60 16.70 16.90 16.70 16.80 18.20 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 31.80 32.00 44.30 32.10 72.40 73.60 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 16.70 16.70 16.80 16.70 16.80 17.30 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("STAAUR") 16.70 16.80 35.20 18.60 58.00 73.00 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 24.60 24.60 33.50 24.70 24.90 68.70 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("S. aureus") 24.50 24.70 25.30 24.90 26.00 26.40 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 7.35 7.45 7.53 7.51 7.56 7.97 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#> as.mo("sau") 16.80 17.20 25.80 18.10 32.10 52.8 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 32.20 33.10 43.30 34.00 42.40 82.3 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 16.70 16.80 25.40 17.20 19.80 60.4 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("STAAUR") 16.70 16.80 22.40 17.90 20.20 61.7 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 24.90 25.10 42.00 26.20 67.50 88.8 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("S. aureus") 24.50 25.00 43.70 25.30 67.90 78.2 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 7.47 7.48 9.63 7.53 7.69 28.3 10</span></a></code></pre></div>
|
||||
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.</p>
|
||||
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Thermus islandicus</em> (<code>B_THERMS_ISL</code>), a bug probably never found before in humans:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1">T.islandicus <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"theisl"</span>),</a>
|
||||
@ -235,13 +235,13 @@
|
||||
<a class="sourceLine" id="cb3-6" title="6"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
|
||||
<a class="sourceLine" id="cb3-7" title="7"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(T.islandicus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb3-8" title="8"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb3-9" title="9"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#> as.mo("theisl") 265.0 268.0 294.0 307.0 312 321 10</span></a>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("THEISL") 264.0 264.0 312.0 307.0 316 464 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("T. islandicus") 142.0 142.0 159.0 143.0 187 216 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("T. islandicus") 142.0 143.0 173.0 185.0 187 190 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("Thermus islandicus") 68.1 68.4 81.9 68.6 111 115 10</span></a></code></pre></div>
|
||||
<p>That takes 8 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
|
||||
<a class="sourceLine" id="cb3-9" title="9"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#> as.mo("theisl") 275.0 304.0 310 309.0 316 337 10</span></a>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("THEISL") 263.0 304.0 311 306.0 312 391 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("T. islandicus") 142.0 143.0 168 148.0 188 220 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("T. islandicus") 142.0 142.0 169 143.0 185 312 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("Thermus islandicus") 68.1 68.6 101 89.8 122 179 10</span></a></code></pre></div>
|
||||
<p>That takes 7 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
|
||||
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Thermus islandicus</em> (which is very uncommon):</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/par">par</a></span>(<span class="dt">mar =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">5</span>, <span class="dv">16</span>, <span class="dv">4</span>, <span class="dv">2</span>)) <span class="co"># set more space for left margin text (16)</span></a>
|
||||
<a class="sourceLine" id="cb4-2" title="2"></a>
|
||||
@ -286,9 +286,9 @@
|
||||
<a class="sourceLine" id="cb5-23" title="23"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
|
||||
<a class="sourceLine" id="cb5-24" title="24"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb5-25" title="25"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb5-26" title="26"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#> mo_fullname(x) 732 772 823 819 858 1020 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (819 ms). You only lose time on your unique input values.</p>
|
||||
<a class="sourceLine" id="cb5-26" title="26"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#> mo_fullname(x) 687 738 767 770 774 887 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.77 seconds (770 ms). You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -300,10 +300,10 @@
|
||||
<a class="sourceLine" id="cb6-4" title="4"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
|
||||
<a class="sourceLine" id="cb6-5" title="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb6-6" title="6"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb6-7" title="7"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#> A 11.100 11.400 16.700 11.700 14.400 43.200 10</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> B 22.300 22.400 22.800 22.700 22.900 24.100 10</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> C 0.324 0.439 0.532 0.577 0.582 0.677 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb6-7" title="7"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#> A 11.100 11.300 15.600 11.400 11.600 53.4 10</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> B 22.200 22.500 22.800 22.800 23.000 23.7 10</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> C 0.322 0.326 0.518 0.563 0.578 0.8 10</span></a></code></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0006 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">run_it <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</a>
|
||||
<a class="sourceLine" id="cb7-2" title="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</a>
|
||||
@ -317,14 +317,14 @@
|
||||
<a class="sourceLine" id="cb7-10" title="10"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb7-11" title="11"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb7-12" title="12"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#> A 0.322 0.338 0.397 0.384 0.415 0.569 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.316 0.370 0.442 0.442 0.508 0.601 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.335 0.385 0.502 0.504 0.566 0.724 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.283 0.324 0.362 0.366 0.389 0.437 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.252 0.274 0.317 0.323 0.355 0.383 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.255 0.275 0.325 0.332 0.348 0.411 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.259 0.272 0.307 0.299 0.318 0.412 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.271 0.319 0.338 0.334 0.362 0.418 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#> A 0.330 0.345 0.421 0.441 0.461 0.525 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.355 0.378 0.453 0.435 0.464 0.754 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.315 0.374 0.506 0.516 0.633 0.700 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.273 0.329 0.353 0.365 0.385 0.391 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.279 0.322 0.330 0.335 0.343 0.366 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.247 0.263 0.315 0.319 0.355 0.429 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.276 0.320 0.342 0.328 0.371 0.447 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.251 0.258 0.315 0.329 0.360 0.368 10</span></a></code></pre></div>
|
||||
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> too, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
|
||||
</div>
|
||||
<div id="results-in-other-languages" class="section level3">
|
||||
@ -351,13 +351,13 @@
|
||||
<a class="sourceLine" id="cb8-18" title="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</a>
|
||||
<a class="sourceLine" id="cb8-19" title="19"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb8-20" title="20"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#> en 14.92 15.11 15.44 15.31 15.83 16.30 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 27.88 27.89 32.32 28.03 28.37 69.82 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 27.39 28.01 40.70 28.48 69.20 70.26 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 27.69 27.93 38.06 28.12 29.21 84.95 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 27.73 27.95 28.16 28.00 28.15 29.40 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 27.13 27.65 32.76 28.41 29.50 69.48 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 27.08 27.34 27.89 27.99 28.05 29.40 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#> en 14.98 15.35 19.58 15.51 15.58 56.78 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 27.26 27.69 28.05 27.85 28.01 29.44 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 27.07 27.73 31.89 27.87 28.00 69.50 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 26.98 27.43 31.98 27.84 28.09 69.30 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 27.26 27.57 28.38 27.82 28.92 32.14 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 27.21 27.72 36.16 27.83 28.19 70.08 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 27.21 27.78 36.17 27.96 28.54 69.43 10</span></a></code></pre></div>
|
||||
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user