Skip to content

Commit

Permalink
feat(*): add JSON import/export methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayaksaxena committed Oct 20, 2018
1 parent c52bdaf commit bdad34b
Show file tree
Hide file tree
Showing 8 changed files with 561 additions and 28 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Use [npm](https://www.npmjs.com/package/wink-perceptron) to install:
npm install wink-perceptron --save

### Getting Started
Here is an example of predicting type of iris plant from the Iris Data Set.
Here is an example of predicting type of iris plant from the [Iris Data Set](https://archive.ics.uci.edu/ml/datasets/iris).

```javascript
// Load training data from Iris Data Set obtained from
// Load training data — the Iris Data Set obtained from
// UCI Machine Learning Repository; it has been converted
// into JSON format.
// You may need to update the path in the "require" statement
Expand Down Expand Up @@ -58,7 +58,7 @@ Check out the [perceptron API documentation](http://winkjs.org/wink-perceptron/)
If you spot a bug and the same has not yet been reported, raise a new [issue](https://github.com/winkjs/wink-perceptron/issues) or consider fixing it and sending a pull request.

### About wink
[Wink](http://winkjs.org/) is a growing family of high quality [packages](http://winkjs.org/packages.html) for Statistical Analysis, Natural Language Processing and Machine Learning in NodeJS.
[Wink](http://winkjs.org/) is a growing family of high quality [packages](http://winkjs.org/packages.html) for **Statistical Analysis**, **Natural Language Processing** and **Machine Learning** in NodeJS. The code is throughly documented for easy comprehension and has a test coverage of ~100% for reliability.

### Copyright & License

Expand Down
296 changes: 289 additions & 7 deletions docs/Perceptron.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<nav>

<h2><a href="index.html">Home</a></h2><h2><a href="http://winkjs.org" target="_blank" >Wink JS</a></h2><h2><a href="https://github.com/winkjs/wink-perceptron" target="_blank" >Github</a></h2><h3>Classes</h3><ul><li><a href="Perceptron.html">Perceptron</a><ul class='methods'><li data-type='method'><a href="Perceptron.html#defineConfig">defineConfig</a></li><li data-type='method'><a href="Perceptron.html#learn">learn</a></li><li data-type='method'><a href="Perceptron.html#predict">predict</a></li><li data-type='method'><a href="Perceptron.html#reset">reset</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#perceptron">perceptron</a></li></ul>
<h2><a href="index.html">Home</a></h2><h2><a href="http://winkjs.org" target="_blank" >Wink JS</a></h2><h2><a href="https://github.com/winkjs/wink-perceptron" target="_blank" >Github</a></h2><h3>Classes</h3><ul><li><a href="Perceptron.html">Perceptron</a><ul class='methods'><li data-type='method'><a href="Perceptron.html#defineConfig">defineConfig</a></li><li data-type='method'><a href="Perceptron.html#exportJSON">exportJSON</a></li><li data-type='method'><a href="Perceptron.html#importJSON">importJSON</a></li><li data-type='method'><a href="Perceptron.html#learn">learn</a></li><li data-type='method'><a href="Perceptron.html#predict">predict</a></li><li data-type='method'><a href="Perceptron.html#reset">reset</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#perceptron">perceptron</a></li></ul>
</nav>

<div id="main">
Expand Down Expand Up @@ -87,7 +87,7 @@ <h4 class="name" id="defineConfig"><span class="type-signature"></span>defineCon

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line316">line 316</a>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line322">line 322</a>
</li></ul></dd>


Expand Down Expand Up @@ -392,6 +392,288 @@ <h5>Returns:</h5>



<h4 class="name" id="exportJSON"><span class="type-signature"></span>exportJSON<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>






<dl class="details">


<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line401">line 401</a>
</li></ul></dd>































</dl>





<div class="description">
<p>Exports the learning as a JSON, which may be saved as a text file for
later use via <a href="#importJSON"><code>importJSON()</code></a>.</p>
</div>









<h5>Example</h5>

<pre class="prettyprint"><code>myPerceptron.exportJSON();
// returns JSON.</code></pre>
















<h5>Returns:</h5>


<div class="param-desc">
<p>Learning in JSON format.</p>
</div>



<dl class="param-type">
<dt>
Type
</dt>
<dd>

<span class="param-type">string</span>


</dd>
</dl>









<h4 class="name" id="importJSON"><span class="type-signature"></span>importJSON<span class="signature">(json)</span><span class="type-signature"> &rarr; {boolean}</span></h4>






<dl class="details">


<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line426">line 426</a>
</li></ul></dd>































</dl>





<div class="description">
<p>Imports an existing JSON learning for prediction.
It is essential to <a href=""><code>definePrepTasks()</code></a>#definepreptasks and
<a href="#consolidate"><code>consolidate()</code></a> before attempting to predict.</p>
</div>











<h5>Parameters:</h5>


<table class="params">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>json</code></td>


<td class="type">


<span class="param-type">JSON</span>



</td>





<td class="description last"><p>containing learnings in as exported by <a href="#exportjson"><code>exportJSON</code></a>.</p></td>
</tr>


</tbody>
</table>












<h5>Throws:</h5>



<div class="param-desc">

<p>Error if <code>json</code> is invalid.</p>

</div>





<h5>Returns:</h5>


<div class="param-desc">
<p>Always true.</p>
</div>



<dl class="param-type">
<dt>
Type
</dt>
<dd>

<span class="param-type">boolean</span>


</dd>
</dl>









<h4 class="name" id="learn"><span class="type-signature"></span>learn<span class="signature">(examples)</span><span class="type-signature"> &rarr; {number}</span></h4>


Expand All @@ -404,7 +686,7 @@ <h4 class="name" id="learn"><span class="type-signature"></span>learn<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line259">line 259</a>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line261">line 261</a>
</li></ul></dd>


Expand Down Expand Up @@ -532,7 +814,7 @@ <h5>Throws:</h5>

<div class="param-desc">

<p>Error if all <code>examples</code> belong to only a single class.</p>
<p>Error if all <code>examples</code> belong to only <strong>one</strong> class.</p>

</div>

Expand Down Expand Up @@ -581,7 +863,7 @@ <h4 class="name" id="predict"><span class="type-signature"></span>predict<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line292">line 292</a>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line298">line 298</a>
</li></ul></dd>


Expand Down Expand Up @@ -755,7 +1037,7 @@ <h4 class="name" id="reset"><span class="type-signature"></span>reset<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line363">line 363</a>
<a href="wink-perceptron.js.html">wink-perceptron.js</a>, <a href="wink-perceptron.js.html#line369">line 369</a>
</li></ul></dd>


Expand Down Expand Up @@ -873,7 +1155,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 19 2018 19:13:50 GMT+0530 (IST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 20 2018 16:51:47 GMT+0530 (IST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
4 changes: 2 additions & 2 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<nav>

<h2><a href="index.html">Home</a></h2><h2><a href="http://winkjs.org" target="_blank" >Wink JS</a></h2><h2><a href="https://github.com/winkjs/wink-perceptron" target="_blank" >Github</a></h2><h3>Classes</h3><ul><li><a href="Perceptron.html">Perceptron</a><ul class='methods'><li data-type='method'><a href="Perceptron.html#defineConfig">defineConfig</a></li><li data-type='method'><a href="Perceptron.html#learn">learn</a></li><li data-type='method'><a href="Perceptron.html#predict">predict</a></li><li data-type='method'><a href="Perceptron.html#reset">reset</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#perceptron">perceptron</a></li></ul>
<h2><a href="index.html">Home</a></h2><h2><a href="http://winkjs.org" target="_blank" >Wink JS</a></h2><h2><a href="https://github.com/winkjs/wink-perceptron" target="_blank" >Github</a></h2><h3>Classes</h3><ul><li><a href="Perceptron.html">Perceptron</a><ul class='methods'><li data-type='method'><a href="Perceptron.html#defineConfig">defineConfig</a></li><li data-type='method'><a href="Perceptron.html#exportJSON">exportJSON</a></li><li data-type='method'><a href="Perceptron.html#importJSON">importJSON</a></li><li data-type='method'><a href="Perceptron.html#learn">learn</a></li><li data-type='method'><a href="Perceptron.html#predict">predict</a></li><li data-type='method'><a href="Perceptron.html#reset">reset</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#perceptron">perceptron</a></li></ul>
</nav>

<div id="main">
Expand Down Expand Up @@ -251,7 +251,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Oct 19 2018 19:13:50 GMT+0530 (IST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 20 2018 16:51:47 GMT+0530 (IST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down

0 comments on commit bdad34b

Please sign in to comment.