ipfml.utils.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>ipfml.utils &mdash; IPFML v0.3.7 documentation</title>
  8. <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  9. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  10. <link rel="index" title="Index" href="../genindex.html" />
  11. <link rel="search" title="Search" href="../search.html" />
  12. <link rel="next" title="ipfml.exceptions" href="ipfml.exceptions.html" />
  13. <link rel="prev" title="ipfml.processing" href="ipfml.processing.html" />
  14. <script src="../_static/js/modernizr.min.js"></script>
  15. </head>
  16. <body class="wy-body-for-nav">
  17. <div class="wy-grid-for-nav">
  18. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  19. <div class="wy-side-scroll">
  20. <div class="wy-side-nav-search">
  21. <a href="../index.html" class="icon icon-home"> IPFML
  22. </a>
  23. <div class="version">
  24. 0.3.7
  25. </div>
  26. <div role="search">
  27. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  28. <input type="text" name="q" placeholder="Search docs" />
  29. <input type="hidden" name="check_keywords" value="yes" />
  30. <input type="hidden" name="area" value="default" />
  31. </form>
  32. </div>
  33. </div>
  34. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  35. <p class="caption"><span class="caption-text">Contents:</span></p>
  36. <ul class="current">
  37. <li class="toctree-l1"><a class="reference internal" href="../description.html">Description</a></li>
  38. <li class="toctree-l1 current"><a class="reference internal" href="../ipfml.html">Documentation</a><ul class="current">
  39. <li class="toctree-l2"><a class="reference internal" href="ipfml.metrics.html">ipfml.metrics</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="ipfml.processing.html">ipfml.processing</a></li>
  41. <li class="toctree-l2 current"><a class="current reference internal" href="#">ipfml.utils</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="ipfml.exceptions.html">ipfml.exceptions</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-filters">ipfml.filters</a></li>
  44. <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-iqa">ipfml.iqa</a></li>
  45. </ul>
  46. </li>
  47. <li class="toctree-l1"><a class="reference internal" href="../examples.html">Examples</a></li>
  48. <li class="toctree-l1"><a class="reference internal" href="../contributing.html">Contributing</a></li>
  49. </ul>
  50. </div>
  51. </div>
  52. </nav>
  53. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  54. <nav class="wy-nav-top" aria-label="top navigation">
  55. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  56. <a href="../index.html">IPFML</a>
  57. </nav>
  58. <div class="wy-nav-content">
  59. <div class="rst-content">
  60. <div role="navigation" aria-label="breadcrumbs navigation">
  61. <ul class="wy-breadcrumbs">
  62. <li><a href="../index.html">Docs</a> &raquo;</li>
  63. <li><a href="../ipfml.html">Documentation</a> &raquo;</li>
  64. <li>ipfml.utils</li>
  65. <li class="wy-breadcrumbs-aside">
  66. <a href="https://github.com/jbuisine/IPFML/blob/master/docs/source/ipfml/ipfml.utils.rst" class="fa fa-github"> Edit on GitHub</a>
  67. </li>
  68. </ul>
  69. <hr/>
  70. </div>
  71. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  72. <div itemprop="articleBody">
  73. <div class="section" id="module-ipfml.utils">
  74. <span id="ipfml-utils"></span><h1>ipfml.utils<a class="headerlink" href="#module-ipfml.utils" title="Permalink to this headline">¶</a></h1>
  75. <p>Utils functions of ipfml package (array normalization)</p>
  76. <p class="rubric">Functions</p>
  77. <table border="1" class="longtable docutils">
  78. <colgroup>
  79. <col width="10%" />
  80. <col width="90%" />
  81. </colgroup>
  82. <tbody valign="top">
  83. <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>
  84. <td>Returns the computed entropy from arr</td>
  85. </tr>
  86. <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,&nbsp;i)</td>
  87. <td>Returns the entropy contribution i column</td>
  88. </tr>
  89. <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,&nbsp;i)</td>
  90. <td>Returns the computed entropy from arr without contribution of i</td>
  91. </tr>
  92. <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,&nbsp;n)</td>
  93. <td>Returns indices of n highest values from list or 1D numpy array</td>
  94. </tr>
  95. <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,&nbsp;n)</td>
  96. <td>Returns indices of n highest values from list or 1D numpy array</td>
  97. </tr>
  98. <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,&nbsp;dx)</td>
  99. <td>Returns area under curves from provided data points using Simpsons rule</td>
  100. </tr>
  101. <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,&nbsp;dx)</td>
  102. <td>Returns area under curves from provided data points using Trapezium rule</td>
  103. </tr>
  104. <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>
  105. <td>Return array normalize from its min and max values</td>
  106. </tr>
  107. <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>
  108. <td>Normalize data of 1D array shape</td>
  109. </tr>
  110. <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,&nbsp;min,&nbsp;max)</td>
  111. <td>Normalize data of 1D array shape</td>
  112. </tr>
  113. </tbody>
  114. </table>
  115. <dl class="function">
  116. <dt id="ipfml.utils.get_entropy">
  117. <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>
  118. <dd><p>Returns the computed entropy from arr</p>
  119. <table class="docutils field-list" frame="void" rules="none">
  120. <col class="field-name" />
  121. <col class="field-body" />
  122. <tbody valign="top">
  123. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – numpy array</td>
  124. </tr>
  125. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">entropy score computed</td>
  126. </tr>
  127. </tbody>
  128. </table>
  129. <p>Example:</p>
  130. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  131. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  132. <span class="gp">&gt;&gt;&gt; </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>
  133. <span class="gp">&gt;&gt;&gt; </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>
  134. <span class="gp">&gt;&gt;&gt; </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
  135. <span class="go">0</span>
  136. </pre></div>
  137. </div>
  138. </dd></dl>
  139. <dl class="function">
  140. <dt id="ipfml.utils.get_entropy_contribution_of_i">
  141. <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>
  142. <dd><p>Returns the entropy contribution i column</p>
  143. <table class="docutils field-list" frame="void" rules="none">
  144. <col class="field-name" />
  145. <col class="field-body" />
  146. <tbody valign="top">
  147. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  148. <li><strong>arr</strong> – numpy array</li>
  149. <li><strong>i</strong> – column index</li>
  150. </ul>
  151. </td>
  152. </tr>
  153. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">entropy contribution score computed</p>
  154. </td>
  155. </tr>
  156. </tbody>
  157. </table>
  158. <p>Example:</p>
  159. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  160. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  161. <span class="gp">&gt;&gt;&gt; </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>
  162. <span class="gp">&gt;&gt;&gt; </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>
  163. <span class="gp">&gt;&gt;&gt; </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
  164. <span class="go">0</span>
  165. </pre></div>
  166. </div>
  167. </dd></dl>
  168. <dl class="function">
  169. <dt id="ipfml.utils.get_entropy_without_i">
  170. <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>
  171. <dd><p>Returns the computed entropy from arr without contribution of i</p>
  172. <table class="docutils field-list" frame="void" rules="none">
  173. <col class="field-name" />
  174. <col class="field-body" />
  175. <tbody valign="top">
  176. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  177. <li><strong>arr</strong> – numpy array</li>
  178. <li><strong>i</strong> – column index</li>
  179. </ul>
  180. </td>
  181. </tr>
  182. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">entropy score computed</p>
  183. </td>
  184. </tr>
  185. </tbody>
  186. </table>
  187. <p>Example:</p>
  188. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  189. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  190. <span class="gp">&gt;&gt;&gt; </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>
  191. <span class="gp">&gt;&gt;&gt; </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>
  192. <span class="gp">&gt;&gt;&gt; </span><span class="nb">int</span><span class="p">(</span><span class="n">entropy</span><span class="p">)</span>
  193. <span class="go">0</span>
  194. </pre></div>
  195. </div>
  196. </dd></dl>
  197. <dl class="function">
  198. <dt id="ipfml.utils.get_indices_of_highest_values">
  199. <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>
  200. <dd><p>Returns indices of n highest values from list or 1D numpy array</p>
  201. <table class="docutils field-list" frame="void" rules="none">
  202. <col class="field-name" />
  203. <col class="field-body" />
  204. <tbody valign="top">
  205. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  206. <li><strong>arr</strong> – List of numpy array</li>
  207. <li><strong>n</strong> – number of highest elements wanted</li>
  208. </ul>
  209. </td>
  210. </tr>
  211. <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>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <p>Example:</p>
  217. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  218. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  219. <span class="gp">&gt;&gt;&gt; </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>
  220. <span class="gp">&gt;&gt;&gt; </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>
  221. <span class="gp">&gt;&gt;&gt; </span><span class="n">indices</span>
  222. <span class="go">array([9, 8])</span>
  223. </pre></div>
  224. </div>
  225. </dd></dl>
  226. <dl class="function">
  227. <dt id="ipfml.utils.get_indices_of_lowest_values">
  228. <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>
  229. <dd><p>Returns indices of n highest values from list or 1D numpy array</p>
  230. <table class="docutils field-list" frame="void" rules="none">
  231. <col class="field-name" />
  232. <col class="field-body" />
  233. <tbody valign="top">
  234. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  235. <li><strong>arr</strong> – List of numpy array</li>
  236. <li><strong>n</strong> – number of highest elements wanted</li>
  237. </ul>
  238. </td>
  239. </tr>
  240. <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>
  241. </td>
  242. </tr>
  243. </tbody>
  244. </table>
  245. <p>Example:</p>
  246. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  247. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  248. <span class="gp">&gt;&gt;&gt; </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>
  249. <span class="gp">&gt;&gt;&gt; </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>
  250. <span class="gp">&gt;&gt;&gt; </span><span class="n">indices</span>
  251. <span class="go">array([0, 1])</span>
  252. </pre></div>
  253. </div>
  254. </dd></dl>
  255. <dl class="function">
  256. <dt id="ipfml.utils.integral_area_simps">
  257. <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>
  258. <dd><p>Returns area under curves from provided data points using Simpsons rule</p>
  259. <table class="docutils field-list" frame="void" rules="none">
  260. <col class="field-name" />
  261. <col class="field-body" />
  262. <tbody valign="top">
  263. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  264. <li><strong>y_values</strong> – y values of curve</li>
  265. <li><strong>dx</strong> – number of unit for x axis</li>
  266. </ul>
  267. </td>
  268. </tr>
  269. <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>
  270. </td>
  271. </tr>
  272. </tbody>
  273. </table>
  274. <p>Example:</p>
  275. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  276. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  277. <span class="gp">&gt;&gt;&gt; </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>
  278. <span class="gp">&gt;&gt;&gt; </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>
  279. <span class="gp">&gt;&gt;&gt; </span><span class="n">area</span>
  280. <span class="go">460.0</span>
  281. </pre></div>
  282. </div>
  283. </dd></dl>
  284. <dl class="function">
  285. <dt id="ipfml.utils.integral_area_trapz">
  286. <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>
  287. <dd><p>Returns area under curves from provided data points using Trapezium rule</p>
  288. <table class="docutils field-list" frame="void" rules="none">
  289. <col class="field-name" />
  290. <col class="field-body" />
  291. <tbody valign="top">
  292. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  293. <li><strong>y_values</strong> – y values of curve</li>
  294. <li><strong>dx</strong> – number of unit for x axis</li>
  295. </ul>
  296. </td>
  297. </tr>
  298. <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>
  299. </td>
  300. </tr>
  301. </tbody>
  302. </table>
  303. <p>Example:</p>
  304. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  305. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  306. <span class="gp">&gt;&gt;&gt; </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>
  307. <span class="gp">&gt;&gt;&gt; </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>
  308. <span class="gp">&gt;&gt;&gt; </span><span class="n">area</span>
  309. <span class="go">452.5</span>
  310. </pre></div>
  311. </div>
  312. </dd></dl>
  313. <dl class="function">
  314. <dt id="ipfml.utils.normalize_2D_arr">
  315. <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>
  316. <dd><p>Return array normalize from its min and max values</p>
  317. <table class="docutils field-list" frame="void" rules="none">
  318. <col class="field-name" />
  319. <col class="field-body" />
  320. <tbody valign="top">
  321. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – 2D Numpy array</td>
  322. </tr>
  323. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 2D Numpy array</td>
  324. </tr>
  325. </tbody>
  326. </table>
  327. <p>Example:</p>
  328. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
  329. <span class="gp">&gt;&gt;&gt; </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>
  330. <span class="gp">&gt;&gt;&gt; </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">&#39;./images/test_img.png&#39;</span><span class="p">)</span>
  331. <span class="gp">&gt;&gt;&gt; </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>
  332. <span class="gp">&gt;&gt;&gt; </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>
  333. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span><span class="o">.</span><span class="n">shape</span>
  334. <span class="go">(200, 200)</span>
  335. </pre></div>
  336. </div>
  337. </dd></dl>
  338. <dl class="function">
  339. <dt id="ipfml.utils.normalize_arr">
  340. <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>
  341. <dd><p>Normalize data of 1D array shape</p>
  342. <table class="docutils field-list" frame="void" rules="none">
  343. <col class="field-name" />
  344. <col class="field-body" />
  345. <tbody valign="top">
  346. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  347. </tr>
  348. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D array</td>
  349. </tr>
  350. </tbody>
  351. </table>
  352. <p>Example:</p>
  353. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  354. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  355. <span class="gp">&gt;&gt;&gt; </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>
  356. <span class="gp">&gt;&gt;&gt; </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>
  357. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
  358. <span class="go">0.1</span>
  359. </pre></div>
  360. </div>
  361. </dd></dl>
  362. <dl class="function">
  363. <dt id="ipfml.utils.normalize_arr_with_range">
  364. <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>
  365. <dd><p>Normalize data of 1D array shape</p>
  366. <table class="docutils field-list" frame="void" rules="none">
  367. <col class="field-name" />
  368. <col class="field-body" />
  369. <tbody valign="top">
  370. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  371. </tr>
  372. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D Numpy array</td>
  373. </tr>
  374. </tbody>
  375. </table>
  376. <p>Example:</p>
  377. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  378. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  379. <span class="gp">&gt;&gt;&gt; </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>
  380. <span class="gp">&gt;&gt;&gt; </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>
  381. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
  382. <span class="go">0.05</span>
  383. </pre></div>
  384. </div>
  385. </dd></dl>
  386. </div>
  387. </div>
  388. </div>
  389. <footer>
  390. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  391. <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>
  392. <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>
  393. </div>
  394. <hr/>
  395. <div role="contentinfo">
  396. <p>
  397. &copy; Copyright 2019, Jérôme BUISINE
  398. </p>
  399. </div>
  400. 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>.
  401. </footer>
  402. </div>
  403. </div>
  404. </section>
  405. </div>
  406. <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
  407. <script type="text/javascript" src="../_static/jquery.js"></script>
  408. <script type="text/javascript" src="../_static/underscore.js"></script>
  409. <script type="text/javascript" src="../_static/doctools.js"></script>
  410. <script type="text/javascript" src="../_static/language_data.js"></script>
  411. <script type="text/javascript" src="../_static/js/theme.js"></script>
  412. <script type="text/javascript">
  413. jQuery(function () {
  414. SphinxRtdTheme.Navigation.enable(true);
  415. });
  416. </script>
  417. </body>
  418. </html>