123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551 |
- <!DOCTYPE html>
- <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
- <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
- <head>
- <meta charset="utf-8">
-
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-
- <title>ipfml.utils — IPFML v0.3.7 documentation</title>
-
-
-
-
-
-
-
-
-
-
- <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
- <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
- <link rel="index" title="Index" href="../genindex.html" />
- <link rel="search" title="Search" href="../search.html" />
- <link rel="next" title="ipfml.exceptions" href="ipfml.exceptions.html" />
- <link rel="prev" title="ipfml.processing" href="ipfml.processing.html" />
-
- <script src="../_static/js/modernizr.min.js"></script>
- </head>
- <body class="wy-body-for-nav">
-
- <div class="wy-grid-for-nav">
-
- <nav data-toggle="wy-nav-shift" class="wy-nav-side">
- <div class="wy-side-scroll">
- <div class="wy-side-nav-search">
-
-
- <a href="../index.html" class="icon icon-home"> IPFML
-
-
- </a>
-
-
-
- <div class="version">
- 0.3.7
- </div>
-
-
-
- <div role="search">
- <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
- <input type="text" name="q" placeholder="Search docs" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
-
- </div>
- <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
-
-
-
-
-
-
- <p class="caption"><span class="caption-text">Contents:</span></p>
- <ul class="current">
- <li class="toctree-l1"><a class="reference internal" href="../description.html">Description</a></li>
- <li class="toctree-l1 current"><a class="reference internal" href="../ipfml.html">Documentation</a><ul class="current">
- <li class="toctree-l2"><a class="reference internal" href="ipfml.metrics.html">ipfml.metrics</a></li>
- <li class="toctree-l2"><a class="reference internal" href="ipfml.processing.html">ipfml.processing</a></li>
- <li class="toctree-l2 current"><a class="current reference internal" href="#">ipfml.utils</a></li>
- <li class="toctree-l2"><a class="reference internal" href="ipfml.exceptions.html">ipfml.exceptions</a></li>
- <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-filters">ipfml.filters</a></li>
- <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-iqa">ipfml.iqa</a></li>
- </ul>
- </li>
- <li class="toctree-l1"><a class="reference internal" href="../examples.html">Examples</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../contributing.html">Contributing</a></li>
- </ul>
-
-
- </div>
- </div>
- </nav>
- <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
-
- <nav class="wy-nav-top" aria-label="top navigation">
-
- <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
- <a href="../index.html">IPFML</a>
-
- </nav>
- <div class="wy-nav-content">
-
- <div class="rst-content">
-
-
- <div role="navigation" aria-label="breadcrumbs navigation">
- <ul class="wy-breadcrumbs">
-
- <li><a href="../index.html">Docs</a> »</li>
-
- <li><a href="../ipfml.html">Documentation</a> »</li>
-
- <li>ipfml.utils</li>
-
-
- <li class="wy-breadcrumbs-aside">
-
-
-
- <a href="https://github.com/jbuisine/IPFML/blob/master/docs/source/ipfml/ipfml.utils.rst" class="fa fa-github"> Edit on GitHub</a>
-
-
-
- </li>
-
- </ul>
-
- <hr/>
- </div>
- <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
- <div itemprop="articleBody">
-
- <div class="section" id="module-ipfml.utils">
- <span id="ipfml-utils"></span><h1>ipfml.utils<a class="headerlink" href="#module-ipfml.utils" title="Permalink to this headline">¶</a></h1>
- <p>Utils functions of ipfml package (array normalization)</p>
- <p class="rubric">Functions</p>
- <table border="1" class="longtable docutils">
- <colgroup>
- <col width="10%" />
- <col width="90%" />
- </colgroup>
- <tbody valign="top">
- <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_entropy" title="ipfml.utils.get_entropy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_entropy</span></code></a>(arr)</td>
- <td>Returns the computed entropy from arr</td>
- </tr>
- <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.get_entropy_contribution_of_i" title="ipfml.utils.get_entropy_contribution_of_i"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_entropy_contribution_of_i</span></code></a>(arr, i)</td>
- <td>Returns the entropy contribution i column</td>
- </tr>
- <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_entropy_without_i" title="ipfml.utils.get_entropy_without_i"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_entropy_without_i</span></code></a>(arr, i)</td>
- <td>Returns the computed entropy from arr without contribution of i</td>
- </tr>
- <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_highest_values" title="ipfml.utils.get_indices_of_highest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_highest_values</span></code></a>(arr, n)</td>
- <td>Returns indices of n highest values from list or 1D numpy array</td>
- </tr>
- <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_lowest_values" title="ipfml.utils.get_indices_of_lowest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_lowest_values</span></code></a>(arr, n)</td>
- <td>Returns indices of n highest values from list or 1D numpy array</td>
- </tr>
- <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.integral_area_simps" title="ipfml.utils.integral_area_simps"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_simps</span></code></a>(y_values, dx)</td>
- <td>Returns area under curves from provided data points using Simpsons rule</td>
- </tr>
- <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.integral_area_trapz" title="ipfml.utils.integral_area_trapz"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_trapz</span></code></a>(y_values, dx)</td>
- <td>Returns area under curves from provided data points using Trapezium rule</td>
- </tr>
- <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.normalize_2D_arr" title="ipfml.utils.normalize_2D_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_2D_arr</span></code></a>(arr)</td>
- <td>Return array normalize from its min and max values</td>
- </tr>
- <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.normalize_arr" title="ipfml.utils.normalize_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr</span></code></a>(arr)</td>
- <td>Normalize data of 1D array shape</td>
- </tr>
- <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.normalize_arr_with_range" title="ipfml.utils.normalize_arr_with_range"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr_with_range</span></code></a>(arr, min, max)</td>
- <td>Normalize data of 1D array shape</td>
- </tr>
- </tbody>
- </table>
- <dl class="function">
- <dt id="ipfml.utils.get_entropy">
- <code class="descclassname">ipfml.utils.</code><code class="descname">get_entropy</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_entropy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_entropy" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns the computed entropy from arr</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – numpy array</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">entropy score computed</td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">entropy</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_entropy</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
- <span class="go">0</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.get_entropy_contribution_of_i">
- <code class="descclassname">ipfml.utils.</code><code class="descname">get_entropy_contribution_of_i</code><span class="sig-paren">(</span><em>arr</em>, <em>i</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_entropy_contribution_of_i"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_entropy_contribution_of_i" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns the entropy contribution i column</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>arr</strong> – numpy array</li>
- <li><strong>i</strong> – column index</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">entropy contribution score computed</p>
- </td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">entropy</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_entropy_contribution_of_i</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
- <span class="go">0</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.get_entropy_without_i">
- <code class="descclassname">ipfml.utils.</code><code class="descname">get_entropy_without_i</code><span class="sig-paren">(</span><em>arr</em>, <em>i</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_entropy_without_i"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_entropy_without_i" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns the computed entropy from arr without contribution of i</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>arr</strong> – numpy array</li>
- <li><strong>i</strong> – column index</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">entropy score computed</p>
- </td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">entropy</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_entropy_without_i</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
- <span class="go">0</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.get_indices_of_highest_values">
- <code class="descclassname">ipfml.utils.</code><code class="descname">get_indices_of_highest_values</code><span class="sig-paren">(</span><em>arr</em>, <em>n</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_indices_of_highest_values"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_indices_of_highest_values" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns indices of n highest values from list or 1D numpy array</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>arr</strong> – List of numpy array</li>
- <li><strong>n</strong> – number of highest elements wanted</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><cite>n</cite> indices of highest values</p>
- </td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">indices</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_indices_of_highest_values</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">indices</span>
- <span class="go">array([9, 8])</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.get_indices_of_lowest_values">
- <code class="descclassname">ipfml.utils.</code><code class="descname">get_indices_of_lowest_values</code><span class="sig-paren">(</span><em>arr</em>, <em>n</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_indices_of_lowest_values"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_indices_of_lowest_values" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns indices of n highest values from list or 1D numpy array</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>arr</strong> – List of numpy array</li>
- <li><strong>n</strong> – number of highest elements wanted</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><cite>n</cite> indices of highest values</p>
- </td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">indices</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_indices_of_lowest_values</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">indices</span>
- <span class="go">array([0, 1])</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.integral_area_simps">
- <code class="descclassname">ipfml.utils.</code><code class="descname">integral_area_simps</code><span class="sig-paren">(</span><em>y_values</em>, <em>dx</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#integral_area_simps"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.integral_area_simps" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns area under curves from provided data points using Simpsons rule</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>y_values</strong> – y values of curve</li>
- <li><strong>dx</strong> – number of unit for x axis</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Area under curves obtained from these points</p>
- </td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">y_values</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">5</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
- <span class="gp">>>> </span><span class="n">area</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">integral_area_simps</span><span class="p">(</span><span class="n">y_values</span><span class="p">,</span> <span class="n">dx</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">area</span>
- <span class="go">460.0</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.integral_area_trapz">
- <code class="descclassname">ipfml.utils.</code><code class="descname">integral_area_trapz</code><span class="sig-paren">(</span><em>y_values</em>, <em>dx</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#integral_area_trapz"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.integral_area_trapz" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns area under curves from provided data points using Trapezium rule</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>y_values</strong> – y values of curve</li>
- <li><strong>dx</strong> – number of unit for x axis</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Area under curves obtained from these points</p>
- </td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">y_values</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">5</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
- <span class="gp">>>> </span><span class="n">area</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">integral_area_trapz</span><span class="p">(</span><span class="n">y_values</span><span class="p">,</span> <span class="n">dx</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">area</span>
- <span class="go">452.5</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.normalize_2D_arr">
- <code class="descclassname">ipfml.utils.</code><code class="descname">normalize_2D_arr</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#normalize_2D_arr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.normalize_2D_arr" title="Permalink to this definition">¶</a></dt>
- <dd><p>Return array normalize from its min and max values</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – 2D Numpy array</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 2D Numpy array</td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
- <span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span><span class="p">,</span> <span class="n">processing</span>
- <span class="gp">>>> </span><span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">'./images/test_img.png'</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">img_mscn</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">rgb_to_mscn</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">img_normalized</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">normalize_2D_arr</span><span class="p">(</span><span class="n">img_mscn</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">img_normalized</span><span class="o">.</span><span class="n">shape</span>
- <span class="go">(200, 200)</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.normalize_arr">
- <code class="descclassname">ipfml.utils.</code><code class="descname">normalize_arr</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#normalize_arr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.normalize_arr" title="Permalink to this definition">¶</a></dt>
- <dd><p>Normalize data of 1D array shape</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D array</td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">arr_normalized</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">normalize_arr</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
- <span class="go">0.1</span>
- </pre></div>
- </div>
- </dd></dl>
- <dl class="function">
- <dt id="ipfml.utils.normalize_arr_with_range">
- <code class="descclassname">ipfml.utils.</code><code class="descname">normalize_arr_with_range</code><span class="sig-paren">(</span><em>arr</em>, <em>min</em>, <em>max</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#normalize_arr_with_range"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.normalize_arr_with_range" title="Permalink to this definition">¶</a></dt>
- <dd><p>Normalize data of 1D array shape</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D Numpy array</td>
- </tr>
- </tbody>
- </table>
- <p>Example:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
- <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
- <span class="gp">>>> </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">arr_normalized</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">normalize_arr_with_range</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
- <span class="go">0.05</span>
- </pre></div>
- </div>
- </dd></dl>
- </div>
- </div>
-
- </div>
- <footer>
-
- <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
-
- <a href="ipfml.exceptions.html" class="btn btn-neutral float-right" title="ipfml.exceptions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
-
-
- <a href="ipfml.processing.html" class="btn btn-neutral" title="ipfml.processing" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
-
- </div>
-
- <hr/>
- <div role="contentinfo">
- <p>
- © Copyright 2019, Jérôme BUISINE
- </p>
- </div>
- Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
- </footer>
- </div>
- </div>
- </section>
- </div>
-
-
-
-
- <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></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>
- <script type="text/javascript" src="../_static/language_data.js"></script>
-
-
- <script type="text/javascript" src="../_static/js/theme.js"></script>
- <script type="text/javascript">
- jQuery(function () {
- SphinxRtdTheme.Navigation.enable(true);
- });
- </script>
- </body>
- </html>
|