Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > e578866d55cd81fdb23827cdf3cec911 > files > 698

python-scikits-learn-0.6-1mdv2010.2.i586.rpm



<!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>Contributing &mdash; scikits.learn v0.6.0 documentation</title>
    <link rel="stylesheet" href="../_static/nature.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.6.0',
        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="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="top" title="scikits.learn v0.6.0 documentation" href="../index.html" />
    <link rel="next" title="&lt;no title&gt;" href="../performance.html" />
    <link rel="prev" title="SVM: Weighted samples" href="../auto_examples/svm/plot_weighted_samples.html" /> 
  </head>
  <body>
    <div class="header-wrapper">
      <div class="header">
          <p class="logo"><a href="../index.html">
            <img src="../_static/scikit-learn-logo-small.png" alt="Logo"/>
          </a>
          </p><div class="navbar">
          <ul>
            <li><a href="../install.html">Download</a></li>
            <li><a href="../support.html">Support</a></li>
            <li><a href="../user_guide.html">User Guide</a></li>
            <li><a href="../auto_examples/index.html">Examples</a></li>
            <li><a href="#">Development</a></li>
       </ul>

<div class="search_form">

<div id="cse" style="width: 100%;"></div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
  google.load('search', '1', {language : 'en'});
  google.setOnLoadCallback(function() {
    var customSearchControl = new google.search.CustomSearchControl('016639176250731907682:tjtqbvtvij0');
    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    var options = new google.search.DrawOptions();
    options.setAutoComplete(true);
    customSearchControl.draw('cse', options);
  }, true);
</script>

</div>

          </div> <!-- end navbar --></div>
    </div>

    <div class="content-wrapper">

    <!-- <div id="blue_tile"></div> -->

        <div class="sphinxsidebar">
        <div class="rel">
          <a href="../auto_examples/svm/plot_weighted_samples.html" title="SVM: Weighted samples"
             accesskey="P">previous</a> |
          <a href="../performance.html" title="&lt;no title&gt;"
             accesskey="N">next</a> |
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a>
        </div>
        

        <h3>Contents</h3>
         <ul>
<li><a class="reference internal" href="#">Contributing</a><ul>
<li><a class="reference internal" href="#submitting-a-bug-report">Submitting a bug report</a></li>
<li><a class="reference internal" href="#retrieving-the-latest-code">Retrieving the latest code</a></li>
<li><a class="reference internal" href="#contributing-code">Contributing code</a><ul>
<li><a class="reference internal" href="#how-to-contribute">How to contribute</a></li>
<li><a class="reference internal" href="#easyfix-issues">EasyFix Issues</a></li>
<li><a class="reference internal" href="#roadmap">Roadmap</a></li>
<li><a class="reference internal" href="#documentation">Documentation</a></li>
<li><a class="reference internal" href="#developers-web-site">Developers web site</a></li>
</ul>
</li>
<li><a class="reference internal" href="#coding-guidelines">Coding guidelines</a></li>
<li><a class="reference internal" href="#apis-of-scikit-learn-objects">APIs of scikit learn objects</a><ul>
<li><a class="reference internal" href="#different-objects">Different objects</a></li>
<li><a class="reference internal" href="#estimators">Estimators</a><ul>
<li><a class="reference internal" href="#instantiation">Instantiation</a></li>
<li><a class="reference internal" href="#fitting">Fitting</a></li>
<li><a class="reference internal" href="#python-tuples">Python tuples</a></li>
<li><a class="reference internal" href="#optional-arguments">Optional Arguments</a></li>
</ul>
</li>
<li><a class="reference internal" href="#unresolved-api-issues">Unresolved API issues</a></li>
<li><a class="reference internal" href="#specific-models">Specific models</a></li>
</ul>
</li>
</ul>
</li>
</ul>


        

        </div>

      <div class="content">
            
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="contributing">
<h1>Contributing<a class="headerlink" href="#contributing" title="Permalink to this headline">¶</a></h1>
<p>This project is a community effort, and everyone is welcomed to
contribute.</p>
<div class="section" id="submitting-a-bug-report">
<h2>Submitting a bug report<a class="headerlink" href="#submitting-a-bug-report" title="Permalink to this headline">¶</a></h2>
<p>In case you experience difficulties using the package, do not hesitate
to submit a ticket to the
<a class="reference external" href="http://sourceforge.net/apps/trac/scikit-learn/report/1">Bug Tracker</a>.</p>
<p>You are also welcomed to post there feature requests and patches.</p>
</div>
<div class="section" id="retrieving-the-latest-code">
<span id="git-repo"></span><h2>Retrieving the latest code<a class="headerlink" href="#retrieving-the-latest-code" title="Permalink to this headline">¶</a></h2>
<p>You can check the latest sources with the command:</p>
<div class="highlight-python"><pre>git clone git://github.com/scikit-learn/scikit-learn.git</pre>
</div>
<p>or if you have write privileges:</p>
<div class="highlight-python"><pre>git clone git@github.com:scikit-learn/scikit-learn.git</pre>
</div>
<p>You can also check out the sources online in the web page
<a class="reference external" href="http://github.com/scikit-learn/scikit-learn">http://github.com/scikit-learn/scikit-learn</a></p>
<p>If you run the development version, it is cumbersome to re-install the
package each time you update the sources. It is thus preferred that
you add the scikit-directory to your PYTHONPATH and build the
extension in place:</p>
<div class="highlight-python"><pre>python setup.py build_ext --inplace</pre>
</div>
</div>
<div class="section" id="contributing-code">
<h2>Contributing code<a class="headerlink" href="#contributing-code" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-to-contribute">
<h3>How to contribute<a class="headerlink" href="#how-to-contribute" title="Permalink to this headline">¶</a></h3>
<p>The prefered way to contribute to <cite>scikit-learn</cite> is to fork the main
repository on
<a class="reference external" href="http://github.com/scikit-learn/scikit-learn/">github</a>:</p>
<blockquote>
<ol class="arabic">
<li><p class="first"><a class="reference external" href="https://github.com/signup/free">Create an account</a> on
github if you don&#8217;t have one already.</p>
</li>
<li><p class="first">Fork the <a class="reference external" href="http://github.com/scikit-learn/scikit-learn">scikit-learn repo</a>: click on the &#8216;Fork&#8217;
button, at the top, center of the page. This creates a copy of
the code on the github server where you can work.</p>
</li>
<li><p class="first">Clone this copy to your local disk (you need the <cite>git</cite> program to do
this):</p>
<div class="highlight-python"><pre>$ git clone git@github.com:YourLogin/scikit-learn.git</pre>
</div>
</li>
<li><p class="first">Work on this copy, on your computer, using git to do the version
control:</p>
<div class="highlight-python"><pre>$ git add modified_files
$ git commit
$ git push origin master</pre>
</div>
<p>and so on.</p>
</li>
</ol>
</blockquote>
<p>When you are ready, and you have pushed your changes on your github repo,
go the web page of the repo, and click on &#8216;Pull request&#8217; to send us a
pull request. Send us a mail with your pull request, and we can look at
your changes, and integrate them.</p>
<p><strong>Before asking for a pull or a review</strong>, be sure to read the
<a class="reference internal" href="#coding-guidelines">coding-guidelines</a> (below).</p>
<p>Also, make sure that your code is tested, and that all the tests for the
scikit pass.</p>
</div>
<div class="section" id="easyfix-issues">
<h3>EasyFix Issues<a class="headerlink" href="#easyfix-issues" title="Permalink to this headline">¶</a></h3>
<p>The best way to get your feet wet is to pick up an issue from the
<a class="reference external" href="https://sourceforge.net/apps/trac/scikit-learn/report">issue tracker</a> that are
labeled as EasyFix. This means that the knowledge needed to solve the
issue is low, but still you are helping the project and letting more
experienced developers concentrate on other issues.</p>
</div>
<div class="section" id="roadmap">
<h3>Roadmap<a class="headerlink" href="#roadmap" title="Permalink to this headline">¶</a></h3>
<p><a class="reference external" href="http://sourceforge.net/apps/trac/scikit-learn/roadmap">Here</a> you
will find a detailed roadmap, with a description on what&#8217;s planned to
be implemented in the following releases.</p>
</div>
<div class="section" id="documentation">
<h3>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h3>
<p>We are glad to accept any sort of documentation: function docstrings,
rst docs (like this one), tutorials, etc. Rst docs live in the source
code repository, under directory doc/.</p>
<p>You can edit them using any text editor and generate the html docs by
typing from the doc/ directory <tt class="docutils literal"><span class="pre">make</span> <span class="pre">html</span></tt> (or <tt class="docutils literal"><span class="pre">make</span> <span class="pre">html-noplot</span></tt>,
see README in that directory for more info). That should create a
directory _build/html/ with html files that are viewable in a web
browser.</p>
</div>
<div class="section" id="developers-web-site">
<h3>Developers web site<a class="headerlink" href="#developers-web-site" title="Permalink to this headline">¶</a></h3>
<p>More information can be found at the <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/wiki">developer&#8217;s wiki</a>.</p>
</div>
</div>
<div class="section" id="coding-guidelines">
<span id="id1"></span><h2>Coding guidelines<a class="headerlink" href="#coding-guidelines" title="Permalink to this headline">¶</a></h2>
<p>The following are some guidelines on how new code should be
written. Of course, there are special cases and there will be
exceptions to these rules. However, following these rules when
submitting new code makes the review easier so new code can be
integrated in less time.</p>
<p>Uniformly formated code makes it easier to share code ownership. The
scikit learn tries to follow closely the officiel Python guidelines
detailed in <a class="reference external" href="http://www.python.org/dev/peps/pep-0008/">PEP8</a> that
details how code should be formatted, and indented. Please read it and
follow it.</p>
<p>In addition, we add the following guidelines:</p>
<blockquote>
<ul class="simple">
<li>Use underscores to separate words in non class names: <cite>n_samples</cite>
rather than <cite>nsamples</cite>.</li>
<li>Avoid multiple statements on one line. Prefer a line return after
a control flow statement (<cite>if</cite>/<cite>for</cite>).</li>
<li>Use relative imports for references inside scikits.learn.</li>
<li><strong>Please don&#8217;t use `import *` in any case</strong>. It is considered harmful
by the <a class="reference external" href="http://docs.python.org/howto/doanddont.html#from-module-import">official Python recommandations</a>.
It makes the code harder to read as the origin of symbols is no
longer explicitely referenced, but most important, it prevents
using a static analysis tool like <a class="reference external" href="http://www.divmod.org/trac/wiki/DivmodPyflakes">pyflakes</a> to automatically
find bugs in the scikit.</li>
</ul>
</blockquote>
<p>A good example of code that we like can be found <a class="reference external" href="https://svn.enthought.com/enthought/browser/sandbox/docs/coding_standard.py">here</a>.</p>
</div>
<div class="section" id="apis-of-scikit-learn-objects">
<h2>APIs of scikit learn objects<a class="headerlink" href="#apis-of-scikit-learn-objects" title="Permalink to this headline">¶</a></h2>
<p>To have a uniform API, we try to have a common basic API for all the
objects. In addition, to avoid the proliferation of framework code, we
try to adopt simple conventions and limit to a minimum the number of
methods an object has to implement.</p>
<div class="section" id="different-objects">
<h3>Different objects<a class="headerlink" href="#different-objects" title="Permalink to this headline">¶</a></h3>
<p>The main objects of the scikit learn are (one class can implement
multiple interfaces):</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Estimator:</th><td class="field-body"><p class="first">The base object, implements:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">estimator</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</pre></div>
</div>
</td>
</tr>
<tr class="field"><th class="field-name">Predictor:</th><td class="field-body"><p class="first">For suppervised learning, or some unsupervised problems, implements:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">prediction</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</pre></div>
</div>
</td>
</tr>
<tr class="field"><th class="field-name">Transformer:</th><td class="field-body"><p class="first">For filtering or modifying the data, in a supervised or unsupervised
way, implements:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">new_data</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</pre></div>
</div>
<p>When fitting and transforming can be performed much more efficiently
together than separately, implements:</p>
<p>new_data = obj.fit_transform(data)</p>
</td>
</tr>
<tr class="field"><th class="field-name">Model:</th><td class="field-body"><p class="first">A model that can give a goodness of fit or a likelihood of unseen
data, implements (higher is better):</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="n">score</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">score</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="estimators">
<h3>Estimators<a class="headerlink" href="#estimators" title="Permalink to this headline">¶</a></h3>
<p>The API has one predominant object: the estimator. A estimator is an
object that fits a model based on some training data and is capable of
inferring some properties on new data. It can be for instance a
classifier or a regressor. All estimators implement the fit method:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">estimator</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
</div>
<div class="section" id="instantiation">
<h4>Instantiation<a class="headerlink" href="#instantiation" title="Permalink to this headline">¶</a></h4>
<p>This concerns the object creation. The object&#8217;s __init__ method might
accept as arguments constants that determine the estimator behavior
(like the C constant in SVMs).</p>
<p>It should not, however, take the actual training data as argument, as
this is left to the <tt class="docutils literal"><span class="pre">fit()</span></tt> method:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">clf2</span> <span class="o">=</span> <span class="n">SVC</span><span class="p">(</span><span class="n">C</span><span class="o">=</span><span class="mf">2.3</span><span class="p">)</span>
<span class="n">clf3</span> <span class="o">=</span> <span class="n">SVC</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]],</span> <span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span> <span class="c"># WRONG!</span>
</pre></div>
</div>
<p>The arguments that go in the <cite>__init__</cite> should all be keyword arguments
with a default value. In other words, a user should be able to instanciate
an estimator without passing to it any arguments.</p>
<p>The arguments in given at instanciation of an estimator should all
correspond to hyper parameters describing the model or the optimisation
problem that estimator tries to solve. They should however not be
parameters of the estimation routine: these are passed directly to the
<cite>fit</cite> method.</p>
<p>In addition, <strong>every keyword argument given to the `__init__` should
correspond to an attribute on the instance</strong>. The scikit relies on this
to find what are the relevent attributes to set on an estimator when
doing model selection.</p>
<p>All estimators should inherit from <cite>scikit.learn.base.BaseEstimator</cite></p>
</div>
<div class="section" id="fitting">
<h4>Fitting<a class="headerlink" href="#fitting" title="Permalink to this headline">¶</a></h4>
<p>The next thing you&#8217;ll probably want to do is to estimate some
parameters in the model. This is implemented in the .fit() method.</p>
<p>The fit method takes as argument the training data, which can be one
array in the case of unsupervised learning, or two arrays in the case
of supervised learning.</p>
<p>Note that the model is fitted using X and y but the object holds no
reference to X, y. There are however some exceptions to this, as in
the case of precomputed kernels where you need to store access these
data in the predict method.</p>
<blockquote>
<p>Parameters</p>
<blockquote>
<ul class="simple">
<li>X : array-like, with shape = [N, D], where N is the number of
samples and D is the number of features.</li>
<li>Y : array, with shape = [N], where N is the number of samples.</li>
<li>args, kwargs. Parameters can also be set in the fit method.</li>
</ul>
</blockquote>
</blockquote>
<p>X.shape[0] should be the same as Y.shape[0]. If this requisite is not
met, an exception should be raised.</p>
<p>Y might be dropped in the case of unsupervised learning.</p>
<p>The method should return the object (self).</p>
</div>
<div class="section" id="python-tuples">
<h4>Python tuples<a class="headerlink" href="#python-tuples" title="Permalink to this headline">¶</a></h4>
<p>In addition to numpy arrays, all methods should be able to accept
python tuples as arguments. In practice, this means you should call
numpy.asanyarray at the beginning at each public method that accepts
arrays.</p>
</div>
<div class="section" id="optional-arguments">
<h4>Optional Arguments<a class="headerlink" href="#optional-arguments" title="Permalink to this headline">¶</a></h4>
<p>In iterative algorithms, number of iterations should be specified by
an int called <tt class="docutils literal"><span class="pre">n_iter</span></tt>.</p>
</div>
</div>
<div class="section" id="unresolved-api-issues">
<h3>Unresolved API issues<a class="headerlink" href="#unresolved-api-issues" title="Permalink to this headline">¶</a></h3>
<p>Some things are must still be decided:</p>
<blockquote>
<ul class="simple">
<li>what should happen when predict is called before than fit() ?</li>
<li>which exception should be raised when arrays&#8217; shape do not match
in fit() ?</li>
</ul>
</blockquote>
</div>
<div class="section" id="specific-models">
<h3>Specific models<a class="headerlink" href="#specific-models" title="Permalink to this headline">¶</a></h3>
<p>In linear models, coefficients are stored in an array called <tt class="docutils literal"><span class="pre">coef_</span></tt>,
and independent term is stored in <tt class="docutils literal"><span class="pre">intercept_</span></tt>.</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
        <div class="clearer"></div>
      </div>
    </div>

    <div class="footer">
        <p style="text-align: center">This documentation is relative
        to scikits.learn version 0.6.0<p>
        &copy; 2010, scikits.learn developers (BSD Lincense).
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5. Design by <a href="http://webylimonada.com">Web y Limonada</a>.
    </div>
  </body>
</html>