/usr/share/doc/python-pebl/html/evaluator.html is in python-pebl-doc 1.0.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>evaluator – Network evaluators — Pebl v1.0.1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '1.0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Pebl v1.0.1 documentation" href="index.html" />
<link rel="up" title="API Reference" href="apiref.html" />
<link rel="next" title="learner.exhaustive – Exhaustive learners" href="learner/exhaustive.html" />
<link rel="prev" title="discretizer – Discretization algorithms" href="discretizer.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="learner/exhaustive.html" title="learner.exhaustive – Exhaustive learners"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="discretizer.html" title="discretizer – Discretization algorithms"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Pebl v1.0.1 documentation</a> »</li>
<li><a href="apiref.html" accesskey="U">API Reference</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-pebl.evaluator">
<span id="evaluator-network-evaluators"></span><h1><tt class="xref py py-mod docutils literal"><span class="pre">evaluator</span></tt> – Network evaluators<a class="headerlink" href="#module-pebl.evaluator" title="Permalink to this headline">¶</a></h1>
<p>Greedy learning algorithms work by scoring small, local changes to existing
networks. To do this efficiently, one must maintain state to eliminate
redundant computation or unnecessary cache retrievals – that is, we should
only rescore nodes that have changed. Maintaining this state can make
implementing efficient versions of learning algorithms more difficult than a
naive implementation.</p>
<p>The classes in this module provide helpers that encapsulate all the
state-management complexities required for efficient scoring. As long as
callers make changes to networks in a transactional manner (using the provided
methods), networks will be scored efficiently without redendant computation.</p>
<p>The main evaluator is the SmartNetworkEvaluator class. It’s interface is described below.</p>
<p>Note: Most user’s shouldn’t need to use this module directly. All included
learners encapsulate this functionality. This is really only for writing custom
learners.</p>
<div class="section" id="localscorecache">
<h2>LocalscoreCache<a class="headerlink" href="#localscorecache" title="Permalink to this headline">¶</a></h2>
<p>Although most users will never use the localscore cache directly, using pebl
with large datasets will require setting the maximum size of the cache to avoid
memory issues. There is only one relevant configuration parameter.</p>
<dl class="confparam">
<dt id="confparam-localscore_cache.maxsize">
<tt class="descname">localscore_cache.maxsize</tt><a class="headerlink" href="#confparam-localscore_cache.maxsize" title="Permalink to this definition">¶</a></dt>
<dd><p>Max number of localscores to cache. Default=-1 means unlimited size.
default=-1</p>
</dd></dl>
</div>
<div class="section" id="smartnetworkevaluator">
<h2>SmartNetworkEvaluator<a class="headerlink" href="#smartnetworkevaluator" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pebl.evaluator.SmartNetworkEvaluator">
<em class="property">class </em><tt class="descclassname">pebl.evaluator.</tt><tt class="descname">SmartNetworkEvaluator</tt><big>(</big><em>data_</em>, <em>network_</em>, <em>prior_=None</em>, <em>localscore_cache=None</em><big>)</big><a class="headerlink" href="#pebl.evaluator.SmartNetworkEvaluator" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a ‘smart’ network evaluator.</p>
<p>This network evaluator eliminates redundant computation by keeping
track of changes to network and only rescoring the changes. This
requires that all changes to the network are done through this
evaluator’s methods.</p>
<dl class="docutils">
<dt>The network can be altered by the following methods:</dt>
<dd><ul class="first last simple">
<li>alter_network</li>
<li>score_network</li>
<li>randomize_network</li>
<li>clear_network</li>
</ul>
</dd>
</dl>
<p>The last change applied can be ‘undone’ with restore_network</p>
<dl class="method">
<dt id="pebl.evaluator.SmartNetworkEvaluator.alter_network">
<tt class="descname">alter_network</tt><big>(</big><em>add=</em><span class="optional">[</span><span class="optional">]</span>, <em>remove=</em><span class="optional">[</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#pebl.evaluator.SmartNetworkEvaluator.alter_network" title="Permalink to this definition">¶</a></dt>
<dd><p>Alter the network while retaining the ability to <em>quickly</em> undo the changes.</p>
</dd></dl>
<dl class="method">
<dt id="pebl.evaluator.SmartNetworkEvaluator.clear_network">
<tt class="descname">clear_network</tt><big>(</big><big>)</big><a class="headerlink" href="#pebl.evaluator.SmartNetworkEvaluator.clear_network" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear all edges from the network.</p>
</dd></dl>
<dl class="method">
<dt id="pebl.evaluator.SmartNetworkEvaluator.randomize_network">
<tt class="descname">randomize_network</tt><big>(</big><big>)</big><a class="headerlink" href="#pebl.evaluator.SmartNetworkEvaluator.randomize_network" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomize the network edges.</p>
</dd></dl>
<dl class="method">
<dt id="pebl.evaluator.SmartNetworkEvaluator.restore_network">
<tt class="descname">restore_network</tt><big>(</big><big>)</big><a class="headerlink" href="#pebl.evaluator.SmartNetworkEvaluator.restore_network" title="Permalink to this definition">¶</a></dt>
<dd><p>Undo the last change to the network (and score).</p>
<dl class="docutils">
<dt>Undo the last change performed by any of these methods:</dt>
<dd><ul class="first last simple">
<li>score_network</li>
<li>alter_network</li>
<li>randomize_network</li>
<li>clear_network</li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pebl.evaluator.SmartNetworkEvaluator.score_network">
<tt class="descname">score_network</tt><big>(</big><em>net=None</em><big>)</big><a class="headerlink" href="#pebl.evaluator.SmartNetworkEvaluator.score_network" title="Permalink to this definition">¶</a></dt>
<dd><p>Score a network.</p>
<p>If net is provided, scores that. Otherwise, score network previously
set.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="network-evaluators-for-use-with-missing-values">
<h2>Network Evaluators for use with Missing Values<a class="headerlink" href="#network-evaluators-for-use-with-missing-values" title="Permalink to this headline">¶</a></h2>
<p>Scoring networks with missing values requires use of sampling algorithms to
sample over the space of possible completions for the missing values. Pebl
provides a few algorithms for this.</p>
<div class="section" id="configuration-parameters">
<h3>Configuration Parameters<a class="headerlink" href="#configuration-parameters" title="Permalink to this headline">¶</a></h3>
<dl class="confparam">
<dt id="confparam-evaluator.missingdata_evaluator">
<tt class="descname">evaluator.missingdata_evaluator</tt><a class="headerlink" href="#confparam-evaluator.missingdata_evaluator" title="Permalink to this definition">¶</a></dt>
<dd><dl class="docutils">
<dt>Evaluator to use for handling missing data. Choices include:</dt>
<dd><ul class="first">
<li><p class="first">gibbs: Gibb’s sampling</p>
</li>
<li><p class="first">maxentropy_gibbs: Gibbs’s sampling over all completions of the
missing values that result in maximum entropy discretization for the
variables.</p>
</li>
<li><dl class="first docutils">
<dt>exact: exact enumeration of all possible missing values (only</dt>
<dd><p class="first last">useable when there are few missing values)</p>
</dd>
</dl>
</li>
</ul>
<p class="last">default=gibbs</p>
</dd>
</dl>
</dd></dl>
<dl class="confparam">
<dt id="confparam-gibbs.burnin">
<tt class="descname">gibbs.burnin</tt><a class="headerlink" href="#confparam-gibbs.burnin" title="Permalink to this definition">¶</a></dt>
<dd><p>Burn-in period for the gibbs sampler (specified as a multiple of the number of missing values)
default=10</p>
</dd></dl>
<dl class="confparam">
<dt id="confparam-gibbs.stopping_criteria">
<tt class="descname">gibbs.stopping_criteria</tt><a class="headerlink" href="#confparam-gibbs.stopping_criteria" title="Permalink to this definition">¶</a></dt>
<dd><p>Stopping criteria for the gibbs sampler.</p>
<p>Should be a valid python expression that evaluates to true when gibbs
should stop. It can use the following variables:</p>
<blockquote>
<div><ul class="simple">
<li>iters: number of iterations</li>
<li>n: number of missing values</li>
</ul>
</div></blockquote>
<p>Examples:</p>
<blockquote>
<div><ul class="simple">
<li>iters > n**2 (for n-squared iterations)</li>
<li>iters > 100 (for 100 iterations)</li>
</ul>
</div></blockquote>
<p>default=iters > n**2</p>
</dd></dl>
</div>
<div class="section" id="missingdatanetworkevaluator">
<h3>MissingDataNetworkEvaluator<a class="headerlink" href="#missingdatanetworkevaluator" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="pebl.evaluator.MissingDataNetworkEvaluator">
<em class="property">class </em><tt class="descclassname">pebl.evaluator.</tt><tt class="descname">MissingDataNetworkEvaluator</tt><big>(</big><em>data_</em>, <em>network_</em>, <em>prior_=None</em>, <em>localscore_cache=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#pebl.evaluator.MissingDataNetworkEvaluator" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a network evaluator for use with missing values.</p>
<p>This evaluator uses a Gibb’s sampler for sampling over the space of
possible completions for the missing values.</p>
<p>For more information about Gibb’s sampling, consult:</p>
<blockquote>
<div><ol class="arabic simple">
<li><a class="reference external" href="http://en.wikipedia.org/wiki/Gibbs_sampling">http://en.wikipedia.org/wiki/Gibbs_sampling</a></li>
<li>D. Heckerman. A Tutorial on Learning with Bayesian Networks.
Microsoft Technical Report MSR-TR-95-06, 1995. p.21-22.</li>
</ol>
</div></blockquote>
<p>Any config param for ‘gibbs’ can be passed in via options.
Use just the option part of the parameter name.</p>
<dl class="method">
<dt id="pebl.evaluator.MissingDataNetworkEvaluator.score_network">
<tt class="descname">score_network</tt><big>(</big><em>net=None</em>, <em>gibbs_state=None</em><big>)</big><a class="headerlink" href="#pebl.evaluator.MissingDataNetworkEvaluator.score_network" title="Permalink to this definition">¶</a></dt>
<dd><p>Score a network.</p>
<p>If net is provided, scores that. Otherwise, score network previously
set.</p>
<p>The default stopping criteria is to run for n**2 iterations.</p>
<p>gibbs_state is the state of a previous run of the Gibb’s sampler. With
this, one can do the following:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">myeval</span> <span class="o">=</span> <span class="n">evaluator</span><span class="o">.</span><span class="n">MissingDataNetworkEvaluator</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="n">myeval</span><span class="o">.</span><span class="n">score_network</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="n">gibbs_state</span> <span class="o">=</span> <span class="n">myeval</span><span class="o">.</span><span class="n">gibbs_state</span>
<span class="n">cPickle</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">gibbs_state</span><span class="p">,</span> <span class="s">'gibbs_state.txt'</span><span class="p">)</span>
<span class="c"># look at results, do other analysis, etc</span>
<span class="c"># If we decide that we need further Gibb's sampler iterations, we</span>
<span class="c"># don't need to restart</span>
<span class="n">gibbs_state</span> <span class="o">=</span> <span class="n">cPickle</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="s">'gibbs_state.txt'</span><span class="p">))</span>
<span class="n">myeval</span> <span class="o">=</span> <span class="n">evaluator</span><span class="o">.</span><span class="n">MissingDataNetworkEvaluator</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="c"># continue with the previous run of the Gibb's sampler</span>
<span class="n">myeval</span><span class="o">.</span><span class="n">score_network</span><span class="p">(</span>
<span class="n">gibbs_state</span><span class="o">=</span><span class="n">gibbs_state</span><span class="p">,</span>
<span class="n">stopping_criteria</span><span class="o">=</span><span class="k">lambda</span> <span class="n">i</span><span class="p">,</span><span class="n">N</span><span class="p">:</span> <span class="n">i</span><span class="o">></span><span class="mi">200</span><span class="o">*</span><span class="n">N</span><span class="o">**</span><span class="mi">2</span>
<span class="p">)</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pebl.evaluator.MissingDataMaximumEntropyNetworkEvaluator">
<em class="property">class </em><tt class="descclassname">pebl.evaluator.</tt><tt class="descname">MissingDataMaximumEntropyNetworkEvaluator</tt><big>(</big><em>data_</em>, <em>network_</em>, <em>prior_=None</em>, <em>localscore_cache=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#pebl.evaluator.MissingDataMaximumEntropyNetworkEvaluator" title="Permalink to this definition">¶</a></dt>
<dd><p>MissingDataNetworkEvaluator that uses a different space of completions.</p>
<p>This evaluator only samples from missing value completions that result in a
maximum entropy discretization for the variables with missing values. This
is useful when the rest of the variables are maximum-entropy discretized
because then all variables have the same entropy.</p>
<p>Create a network evaluator for use with missing values.</p>
<p>This evaluator uses a Gibb’s sampler for sampling over the space of
possible completions for the missing values.</p>
<p>For more information about Gibb’s sampling, consult:</p>
<blockquote>
<div><ol class="arabic simple">
<li><a class="reference external" href="http://en.wikipedia.org/wiki/Gibbs_sampling">http://en.wikipedia.org/wiki/Gibbs_sampling</a></li>
<li>D. Heckerman. A Tutorial on Learning with Bayesian Networks.
Microsoft Technical Report MSR-TR-95-06, 1995. p.21-22.</li>
</ol>
</div></blockquote>
<p>Any config param for ‘gibbs’ can be passed in via options.
Use just the option part of the parameter name.</p>
</dd></dl>
<dl class="class">
<dt id="pebl.evaluator.MissingDataExactNetworkEvaluator">
<em class="property">class </em><tt class="descclassname">pebl.evaluator.</tt><tt class="descname">MissingDataExactNetworkEvaluator</tt><big>(</big><em>data_</em>, <em>network_</em>, <em>prior_=None</em>, <em>localscore_cache=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#pebl.evaluator.MissingDataExactNetworkEvaluator" title="Permalink to this definition">¶</a></dt>
<dd><p>MissingDataNEtworkEvaluator that does an exact enumeration.</p>
<p>This network evaluator enumerates over all possible completions of the
missing values. Since this is a combinatorial space, this class is only
feasible with datasets with few missing values.</p>
<p>Create a network evaluator for use with missing values.</p>
<p>This evaluator uses a Gibb’s sampler for sampling over the space of
possible completions for the missing values.</p>
<p>For more information about Gibb’s sampling, consult:</p>
<blockquote>
<div><ol class="arabic simple">
<li><a class="reference external" href="http://en.wikipedia.org/wiki/Gibbs_sampling">http://en.wikipedia.org/wiki/Gibbs_sampling</a></li>
<li>D. Heckerman. A Tutorial on Learning with Bayesian Networks.
Microsoft Technical Report MSR-TR-95-06, 1995. p.21-22.</li>
</ol>
</div></blockquote>
<p>Any config param for ‘gibbs’ can be passed in via options.
Use just the option part of the parameter name.</p>
</dd></dl>
</div>
</div>
<div class="section" id="factory-functions">
<h2>Factory Functions<a class="headerlink" href="#factory-functions" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="pebl.evaluator.fromconfig">
<tt class="descclassname">pebl.evaluator.</tt><tt class="descname">fromconfig</tt><big>(</big><em>data_=None</em>, <em>network_=None</em>, <em>prior_=None</em><big>)</big><a class="headerlink" href="#pebl.evaluator.fromconfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an evaluator based on configuration parameters.</p>
<p>This function will return the correct evaluator based on the relevant
configuration parameters.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">evaluator</span></tt> – Network evaluators</a><ul>
<li><a class="reference internal" href="#localscorecache">LocalscoreCache</a></li>
<li><a class="reference internal" href="#smartnetworkevaluator">SmartNetworkEvaluator</a></li>
<li><a class="reference internal" href="#network-evaluators-for-use-with-missing-values">Network Evaluators for use with Missing Values</a><ul>
<li><a class="reference internal" href="#configuration-parameters">Configuration Parameters</a></li>
<li><a class="reference internal" href="#missingdatanetworkevaluator">MissingDataNetworkEvaluator</a></li>
</ul>
</li>
<li><a class="reference internal" href="#factory-functions">Factory Functions</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="discretizer.html"
title="previous chapter"><tt class="docutils literal docutils literal docutils literal"><span class="pre">discretizer</span></tt> – Discretization algorithms</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="learner/exhaustive.html"
title="next chapter"><tt class="docutils literal"><span class="pre">learner.exhaustive</span></tt> – Exhaustive learners</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/evaluator.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="learner/exhaustive.html" title="learner.exhaustive – Exhaustive learners"
>next</a> |</li>
<li class="right" >
<a href="discretizer.html" title="discretizer – Discretization algorithms"
>previous</a> |</li>
<li><a href="index.html">Pebl v1.0.1 documentation</a> »</li>
<li><a href="apiref.html" >API Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2008, Abhik Shah.
Last updated on Apr 29, 2011.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
</div>
</body>
</html>
|