UNPKG

qminer

Version:

A C++ based data analytics platform for processing large-scale real-time streams containing structured and unstructured data

1,040 lines (1,038 loc) 89.1 kB
<!doctype html> <html> <head> <meta name="generator" content="JSDoc 3"> <meta charset="utf-8"> <title>Class: RecordSet</title> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css"> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css"> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css"> <link href="css/baseline.css" rel="stylesheet"> </head> <body onload="prettyPrint()"> <nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar"> <div id="jsdoc-navbar-container"> <div id="jsdoc-navbar-content"> <a href="index.html" class="jsdoc-navbar-package-name">QMiner JavaScript API v9.4.0</a> </div> </div> </nav> <div id="jsdoc-body-container"> <div id="jsdoc-content"> <div id="jsdoc-content-container"> <div id="jsdoc-main" role="main"> <header class="page-header"> <div class="symbol-detail-labels"><span class="label label-kind">class</span>&nbsp;<span class="label label-static">static</span></div> <h1><small><a href="module-qm.html">qm</a>.<wbr></small><span class="symbol-name">RecordSet</span></h1> <p class="source-link">Source: <a href="qminerdoc.js.html#source-line-1706">qminerdoc.<wbr>js:1706</a></p> <dl class="dl-compact"> </dl> </header> <section id="summary"> <div class="summary-callout"> <h2 class="summary-callout-heading">Properties</h2> <div class="summary-content"> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.RecordSet.html#empty">empty</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#length">length</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.RecordSet.html#store">store</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#weighted">weighted</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> </div> </div> </div> <div class="summary-callout"> <h2 class="summary-callout-heading">Methods</h2> <div class="summary-content"> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.RecordSet.html#clone">clone()</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#deleteRecords">deleteRecords(rs)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#each">each(callback)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#filter">filter(callback)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#filterByField">filterByField(fieldName, minVal, maxVal)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#filterByFq">filterByFq([minFq][, maxFq])</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#filterById">filterById([minId][, maxId])</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#getMatrix">getMatrix(fieldName)</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.RecordSet.html#getVector">getVector(fieldName)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#join">join(joinName[, sampleSize])</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#map">map(callback)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#reverse">reverse()</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#sample">sample(num)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#setDiff">setDiff(rs)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#setIntersect">setIntersect(rs)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#setUnion">setUnion(rs)</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.RecordSet.html#shuffle">shuffle([seed])</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#sort">sort(callback)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#sortByField">sortByField(fieldName[, asc])</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#sortByFq">sortByFq([asc])</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#sortById">sortById([asc])</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#split">split(callback)</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#toJSON">toJSON()</a></dt> <dd> </dd> <dt><a href="module-qm.RecordSet.html#trunc">trunc(limit_num[, offset_num])</a></dt> <dd> </dd> </dl> </div> </div> </div> </section> <section> <h2 id="RecordSet"><span class="symbol-name">RecordSet</span><span class="signature"><span class="signature-params">()</span></span></h2> <p>Record Set is a set of records. <br> <b>Factory pattern</b>: this class cannot be construced using the new keyword. This class is constructed when calling a specific method or attribute, e.g. using <a href="module-qm.Store.html#allRecords">module:qm.Store#allRecords</a> to get all the records in the store as a record set. </p> <dl class="dl-compact"> </dl> </section> <section> <h2>Properties</h2> <section> <h3 id="empty"><span class="symbol-name">empty</span></h3> <p>Checks if the record set is empty. If the record set is empty, then it returns true. Otherwise, it returns false. Type <code>boolean</code>.</p> <dl class="dl-compact"> </dl> <h3 id="length"><span class="symbol-name">length</span></h3> <p>Returns the number of records in record set. Type <code>number</code>.</p> <dl class="dl-compact"> </dl> <h3 id="store"><span class="symbol-name">store</span></h3> <p>Returns the store, where the records in the record set are stored. Type <a href="module-qm.Store.html">module:qm.Store</a>.</p> <dl class="dl-compact"> </dl> <h3 id="weighted"><span class="symbol-name">weighted</span></h3> <p>Checks if the record set is weighted. If the record set is weighted, then it returns true. Otherwise, it returns false. Type <code>boolean</code>.</p> <dl class="dl-compact"> </dl> </section> <h2>Methods</h2> <section> <h3 id="clone"><span class="symbol-name">clone</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Creates a new instance of the record set.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;Philosophers&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;Era&quot;, type: &quot;string&quot; } ] }] }); // put some records in the store base.store(&quot;Philosophers&quot;).push({ Name: &quot;Plato&quot;, Era: &quot;Ancient philosophy&quot; }); base.store(&quot;Philosophers&quot;).push({ Name: &quot;Immanuel Kant&quot;, Era: &quot;18th-century philosophy&quot; }); base.store(&quot;Philosophers&quot;).push({ Name: &quot;Emmanuel Levinas&quot;, Era: &quot;20th-century philosophy&quot; }); base.store(&quot;Philosophers&quot;).push({ Name: &quot;Rene Descartes&quot;, Era: &quot;17th-century philosophy&quot; }); base.store(&quot;Philosophers&quot;).push({ Name: &quot;Confucius&quot;, Era: &quot;Ancient philosophy&quot; }); // create a record set out of the records in store var recordSet &#x3D; base.store(&quot;Philosophers&quot;).allRecords; // clone the record set of the &quot;Philosophers&quot; store var philosophers &#x3D; recordSet.clone(); base.close();</code></pre> </div> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B A copy of the record set.</p> </dd> </dl> <h3 id="deleteRecords"><span class="symbol-name">deleteRecords</span><span class="signature"><span class="signature-params">(rs)</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Deletes the records, that are also in the second record set.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;BookWriters&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;Genre&quot;, type: &quot;string&quot; }, { name: &quot;Books&quot;, type: &quot;string_v&quot; } ] }] }); // set new records in the store base.store(&quot;BookWriters&quot;).push({ Name: &quot;Terry Pratchett&quot;, Genre: &quot;Fantasy&quot;, Books: [&quot;The Colour of Magic&quot;, &quot;Going Postal&quot;, &quot;Mort&quot;, &quot;Guards! Guards!&quot;] }); base.store(&quot;BookWriters&quot;).push({ Name: &quot;Douglas Adams&quot;, Genre: &quot;Sci-fi&quot;, Books: [&quot;The Hitchhiker&#x27;s Guide to the Galaxy&quot;, &quot;So Long, and Thanks for All the Fish&quot;] }); base.store(&quot;BookWriters&quot;).push({ Name: &quot;Fyodor Dostoyevsky&quot;, Genre: &quot;Drama&quot;, Books: [&quot;Crime and Punishment&quot;, &quot;Demons&quot;] }); base.store(&quot;BookWriters&quot;).push({ Name: &quot;J.R.R. Tolkien&quot;, Genre: &quot;Fantasy&quot;, Books: [&quot;The Hobbit&quot;, &quot;The Two Towers&quot;, &quot;The Silmarillion&quot; ] }); base.store(&quot;BookWriters&quot;).push({ Name: &quot;George R.R. Martin&quot;, Genre: &quot;Fantasy&quot;, Books: [&quot;A Game of Thrones&quot;, &quot;A Feast of Crows&quot;] }); base.store(&quot;BookWriters&quot;).push({ Name: &quot;J. K. Rowling&quot;, Genre: &quot;Fantasy&quot;, Books: [&quot;Harry Potter and the Philosopher&#x27;s Stone&quot;] }); base.store(&quot;BookWriters&quot;).push({ Name: &quot;Ivan Cankar&quot;, Genre: &quot;Drama&quot;, Books: [&quot;On the Hill&quot;, &quot;The King of Betajnova&quot;, &quot;The Serfs&quot;] }); // create one record set containing all records of store var recordSet &#x3D; base.store(&quot;BookWriters&quot;).allRecords; // create one record set containing the records with genre &quot;Fantasy&quot; var fantasy &#x3D; base.store(&quot;BookWriters&quot;).allRecords.filterByField(&quot;Genre&quot;, &quot;Fantasy&quot;); // delete the records in recordSet, that are also in fantasy recordSet.deleteRecords(fantasy); // returns self, containing only three records: &quot;Douglas Adams&quot;, &quot;Fyodor Dostoyevsky&quot; and &quot;Ivan Cankar&quot; base.close();</code></pre> </div> </section> <section> <h4>Parameter</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>rs</p> </td> <td> <p><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The second record set.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B Self. Contains only the records, that are not in <code>rs</code>.</p> </dd> </dl> <h3 id="each"><span class="symbol-name">each</span><span class="signature"><span class="signature-params">(callback)</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Executes a function on each record in record set.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;People&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;Gender&quot;, type: &quot;string&quot; } ] }] }); // put some records in the store base.store(&quot;People&quot;).push({ Name: &quot;Eric Sugar&quot;, Gender: &quot;Male&quot; }); base.store(&quot;People&quot;).push({ Name: &quot;Jane Tokyo&quot;, Gender: &quot;Female&quot; }); base.store(&quot;People&quot;).push({ Name: &quot;Mister Tea&quot;, Gender: &quot;Male&quot; }); // create a record set out of the records of the store var recordSet &#x3D; base.store(&quot;People&quot;).allRecords; // change the Name of all records into &quot;Anonymous&quot; recordSet.each(function (rec) { rec.Name &#x3D; &quot;Anonymous&quot;; }); // returns self, all record&#x27;s Name are &quot;Anonymous&quot; base.close();</code></pre> </div> </section> <section> <h4>Parameter</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>callback</p> </td> <td> <p>function()</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Function to be executed. It takes two parameters: <br>1. <code>rec</code> - The current record. Type <a href="module-qm.Record.html">module:qm.Record</a>. Warning: Do not use <code>rec</code> outside the scope of the callback. An internal optimization re-uses <code>rec</code> object between calls to <code>callback</code>. <br>2. <code>idx</code> - The index of the current record (<i>optional</i>). Type <code>number</code>. </p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B Self.</p> </dd> </dl> <h3 id="filter"><span class="symbol-name">filter</span><span class="signature"><span class="signature-params">(callback)</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Keeps only the records that pass the callback function.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;ArcheryChampionship&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;ScorePerRound&quot;, type: &quot;float_v&quot; } ] }] }); // set new records in the store base.store(&quot;ArcheryChampionship&quot;).push({ Name: &quot;Robin Hood&quot;, ScorePerRound: [50, 48, 48] }); base.store(&quot;ArcheryChampionship&quot;).push({ Name: &quot;Oliver Queen&quot;, ScorePerRound: [44, 46, 44] }); base.store(&quot;ArcheryChampionship&quot;).push({ Name: &quot;Legolas&quot;, ScorePerRound: [50, 50, 48] }); // create a record set out of the records of the store var recordSet &#x3D; base.store(&quot;ArcheryChampionship&quot;).allRecords; // filter the records: which archers have scored 48 points in the third round recordSet.filter(function (rec) { return rec.ScorePerRound[2] &#x3D;&#x3D; 48; }); // keeps only the records, where the score of the third round is equal 48 base.close();</code></pre> </div> </section> <section> <h4>Parameter</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>callback</p> </td> <td> <p>function()</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The filter function. It takes one parameter: <br>1. <code>rec</code> - The record in the record set. Type <a href="module-qm.Record.html">module:qm.Record</a>. <br> Returns a <code>boolean</code> value. </p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B Self. Contains only the records that pass the callback function.</p> </dd> </dl> <h3 id="filterByField"><span class="symbol-name">filterByField</span><span class="signature"><span class="signature-params">(fieldName, minVal, maxVal)</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Keeps only the records with a specific value of some field.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;WeatherForcast&quot;, fields: [ { name: &quot;Weather&quot;, type: &quot;string&quot; }, { name: &quot;Date&quot;, type: &quot;datetime&quot; }, { name: &quot;TemperatureDegrees&quot;, type: &quot;int&quot; }, ] }] }); // put some records in the &quot;WeatherForecast&quot; store base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Partly Cloudy&quot;, Date: &quot;2015-05-27T11:00:00&quot;, TemperatureDegrees: 19 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Partly Cloudy&quot;, Date: &quot;2015-05-28T11:00:00&quot;, TemperatureDegrees: 22 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Mostly Cloudy&quot;, Date: &quot;2015-05-29T11:00:00&quot;, TemperatureDegrees: 25 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Mostly Cloudy&quot;, Date: &quot;2015-05-30T11:00:00&quot;, TemperatureDegrees: 25 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Scattered Showers&quot;, Date: &quot;2015-05-31T11:00:00&quot;, TemperatureDegrees: 24 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Mostly Cloudy&quot;, Date: &quot;2015-06-01T11:00:00&quot;, TemperatureDegrees: 27 }); // get the record set containing the records from the &quot;WeatherForcast&quot; store var recordSet &#x3D; base.store(&quot;WeatherForcast&quot;).allRecords; // filter only the records, where the weather is Mostly Cloudy recordSet.filterByField(&quot;Weather&quot;, &quot;Mostly Cloudy&quot;); // returns self, containing only the records, where the weather is &quot;Mostly Cloudy&quot; base.close();</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>fieldName</p> </td> <td> <p>string</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The field by which the records will be filtered.</p> </td> </tr> <tr> <td> <p>minVal</p> </td> <td> <p>(string or number)</p> </td> <td> <p>&nbsp;</p> </td> <td> <p><br>1. If the field type is a <code>string</code>, the exact string to compare. Type <code>number</code>. <br>2. If the field type is a <code>number</code>, the minimal value for comparison. Type <code>number</code>. <br>3. TODO Time field </p> </td> </tr> <tr> <td> <p>maxVal</p> </td> <td> <p>number</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Only in combination with <code>minVal</code> for non-string fields. The maximal value for comparison.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B Self. <br>1. If the <code>fieldName</code> field type is <code>number</code>, contains only the records with the <code>fieldName</code> value between <code>minVal</code> and <code>maxVal</code>. <br>2. If the <code>fieldName</code> field type is <code>string</code>, contains only the records with <code>fieldName</code> equal to <code>minVal</code>. </p> </dd> </dl> <h3 id="filterByFq"><span class="symbol-name">filterByFq</span><span class="signature"><span class="signature-params">([minFq][, maxFq])</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Keeps only the records with weight between two values.</p> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>minFq</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>The minimum value.</p> </td> </tr> <tr> <td> <p>maxFq</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>The maximum value.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B Self. <br>1. Contains only the records of the original with weights between <code>minFq</code> and <code>maxFq</code>, if parameters are given. <br>2. Contains all the records of the original, if no parameter is given. </p> </dd> </dl> <h3 id="filterById"><span class="symbol-name">filterById</span><span class="signature"><span class="signature-params">([minId][, maxId])</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Keeps only records with ids between or equal two values.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm require var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;FrankSinatraGreatestHits&quot;, fields: [ { name: &quot;Title&quot;, type: &quot;string&quot; }, { name: &quot;Length&quot;, type: &quot;int&quot; } ] }] }); // put some records in the &quot;FrankSinatraGreatesHits&quot; store base.store(&quot;FrankSinatraGreatestHits&quot;).push({ Title: &quot;Strangers in the Night&quot;, Length: 145 }); base.store(&quot;FrankSinatraGreatestHits&quot;).push({ Title: &quot;Summer Wind&quot;, Length: 173 }); base.store(&quot;FrankSinatraGreatestHits&quot;).push({ Title: &quot;It Was a Very Good Year&quot;, Length: 265 }); base.store(&quot;FrankSinatraGreatestHits&quot;).push({ Title: &quot;Somewhere in Your Heart&quot;, Length: 146 }); base.store(&quot;FrankSinatraGreatestHits&quot;).push({ Title: &quot;Forget Domani&quot;, Length: 156 }); base.store(&quot;FrankSinatraGreatestHits&quot;).push({ Title: &quot;Somethin&#x27; Stupid&quot;, Length: 155 }); base.store(&quot;FrankSinatraGreatestHits&quot;).push({ Title: &quot;This Town&quot;, Length: 186 }); // get the records of the store as a record set var recordSet &#x3D; base.store(&quot;FrankSinatraGreatestHits&quot;).allRecords; // from the record set keep the records with indeces between or equal 2 and 5 recordSet.filterById(2, 5); base.close();</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>minId</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>The minimum id.</p> </td> </tr> <tr> <td> <p>maxId</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>The maximum id.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B Self. <br>1. Contains only the records of the original with IDs between <code>minId</code> and <code>maxId</code>, if parameters are given. <br>2. Contains all the records of the original, if no parameter is given. </p> </dd> </dl> <h3 id="getMatrix"><span class="symbol-name">getMatrix</span><span class="signature"><span class="signature-params">(fieldName)</span>&nbsp;&rarr; <span class="signature-returns"> (<a href="module-la.Matrix.html">module:la.Matrix</a> or <a href="module-la.SparseMatrix.html">module:la.SparseMatrix</a>)</span></span></h3> <p>Creates a vector containing the field values of records.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;ArcheryChampionship&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;ScorePerRound&quot;, type: &quot;float_v&quot; } ] }] }); // set new records in the store base.store(&quot;ArcheryChampionship&quot;).push({ Name: &quot;Robin Hood&quot;, ScorePerRound: [50, 48, 48] }); base.store(&quot;ArcheryChampionship&quot;).push({ Name: &quot;Oliver Queen&quot;, ScorePerRound: [44, 46, 44] }); base.store(&quot;ArcheryChampionship&quot;).push({ Name: &quot;Legolas&quot;, ScorePerRound: [50, 50, 48] }); // create a record set of the records in store var recordSet &#x3D; base.store(&quot;ArcheryChampionship&quot;).allRecords; // create a matrix from the &quot;ScorePerRound&quot; field // the i-th column of the matrix is the data of the i-th record in record set // the matrix will look like // 50 44 50 // 48 46 50 // 48 44 48 var matrix &#x3D; recordSet.getMatrix(&quot;ScorePerRound&quot;); base.close();</code></pre> </div> </section> <section> <h4>Parameter</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>fieldName</p> </td> <td> <p>string</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The field from which to take the values. It's type must be numeric, e.g. <code>int</code>, <code>float</code>, <code>float_v</code>, <code>num_sp_v</code>...</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code>(<a href="module-la.Matrix.html">module:la.Matrix</a> or <a href="module-la.SparseMatrix.html">module:la.SparseMatrix</a>)</code>B The matrix containing the field values of records.</p> </dd> </dl> <h3 id="getVector"><span class="symbol-name">getVector</span><span class="signature"><span class="signature-params">(fieldName)</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-la.Vector.html">module:la.Vector</a></span></span></h3> <p>Creates a vector containing the field values of records.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;TVSeries&quot;, fields: [ { name: &quot;Title&quot;, type: &quot;string&quot;, &quot;primary&quot;: true }, { name: &quot;NumberOfEpisodes&quot;, type: &quot;int&quot; } ] }] }); // add some records in the store base.store(&quot;TVSeries&quot;).push({ Title: &quot;Archer&quot;, NumberOfEpisodes: 75 }); base.store(&quot;TVSeries&quot;).push({ Title: &quot;The Simpsons&quot;, NumberOfEpisodes: 574 }); base.store(&quot;TVSeries&quot;).push({ Title: &quot;New Girl&quot;, NumberOfEpisodes: 94 }); base.store(&quot;TVSeries&quot;).push({ Title: &quot;Rick and Morty&quot;, NumberOfEpisodes: 11 }); base.store(&quot;TVSeries&quot;).push({ Title: &quot;Game of Thrones&quot;, NumberOfEpisodes: 47 }); // create a record set of the records of store var recordSet &#x3D; base.store(&quot;TVSeries&quot;).allRecords; // create a vector containing the number of episodes for each series // the vector will look like [75, 574, 94, 11, 47] var vector &#x3D; recordSet.getVector(&quot;NumberOfEpisodes&quot;); base.close();</code></pre> </div> </section> <section> <h4>Parameter</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>fieldName</p> </td> <td> <p>string</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The field from which to take the values. It's type must be one-dimensional, e.g. <code>int</code>, <code>float</code>, <code>string</code>...</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-la.Vector.html">module:la.Vector</a></code>B The vector containing the field values of records. The type it contains is dependant of the field type.</p> </dd> </dl> <h3 id="join"><span class="symbol-name">join</span><span class="signature"><span class="signature-params">(joinName[, sampleSize])</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Creates a new record set out of the join attribute of records.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing two stores, with join attributes var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [ { name: &quot;Musicians&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;Instruments&quot;, type: &quot;string_v&quot; } ], joins: [ { name: &quot;PlaysIn&quot;, type: &quot;index&quot;, store: &quot;Bands&quot;, inverse: &quot;Members&quot; } ] }, { name: &quot;Bands&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;Genre&quot;, type: &quot;string&quot; } ], joins: [ { name: &quot;Members&quot;, type: &quot;index&quot;, store: &quot;Musicians&quot;, inverse: &quot;PlaysIn&quot; } ] }] }); // add some new records to both stores base.store(&quot;Musicians&quot;).push({ Name: &quot;Robert Plant&quot;, Instruments: [&quot;Vocals&quot;], PlaysIn: [{Name: &quot;Led Zeppelin&quot;, &quot;Genre&quot;: &quot;Rock&quot; }] }); base.store(&quot;Musicians&quot;).push({ Name: &quot;Jimmy Page&quot;, Instruments: [&quot;Guitar&quot;], PlaysIn: [{Name: &quot;Led Zeppelin&quot;, &quot;Genre&quot;: &quot;Rock&quot; }] }); base.store(&quot;Bands&quot;).push({ Name: &quot;The White Stripes&quot;, Genre: &quot;Rock&quot; }); // create a record set containing the musicians, that are members of some bend // returns a record set containing the records of &quot;Robert Plant&quot; and &quot;Jimmy Page&quot; var ledZeppelin &#x3D; base.store(&quot;Bands&quot;).allRecords.join(&quot;Members&quot;); // create a record set containing the first musician, that is a member of some band // returns a record set containing only one record, which is &quot;Robert Plant&quot; or &quot;Jimmy Page&quot; var ledMember &#x3D; base.store(&quot;Bands&quot;).allRecords.join(&quot;Members&quot;, 1); base.close();</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>joinName</p> </td> <td> <p>string</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The name of the join attribute.</p> </td> </tr> <tr> <td> <p>sampleSize</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>The number of records to be used for construction of the record set.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B The record set containing the join records.</p> </dd> </dl> <h3 id="map"><span class="symbol-name">map</span><span class="signature"><span class="signature-params">(callback)</span>&nbsp;&rarr; <span class="signature-returns"> Array of Object</span></span></h3> <p>Creates an array of function outputs created from the records in record set.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;People&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot; }, { name: &quot;Gender&quot;, type: &quot;string&quot; } ] }] }); // put some records in the store base.store(&quot;People&quot;).push({ Name: &quot;Eric Sugar&quot;, Gender: &quot;Male&quot; }); base.store(&quot;People&quot;).push({ Name: &quot;Jane Tokyo&quot;, Gender: &quot;Female&quot; }); base.store(&quot;People&quot;).push({ Name: &quot;Mister Tea&quot;, Gender: &quot;Male&quot; }); // create a record set out of the records of the store var recordSet &#x3D; base.store(&quot;People&quot;).allRecords; // make an array of record Names var arr &#x3D; recordSet.map(function (rec) { return rec.Name; }); // returns an array: [&quot;Eric Sugar&quot;, &quot;Jane Tokyo&quot;, &quot;Mister Tea&quot;] base.close();</code></pre> </div> </section> <section> <h4>Parameter</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>callback</p> </td> <td> <p>function()</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Function that generates the array. It takes two parameters: <br>1. <code>rec</code> - The current record. Type <a href="module-qm.Record.html">module:qm.Record</a>. Warning: Do not use <code>rec</code> outside the scope of the callback. An internal optimization re-uses <code>rec</code> object between calls to <code>callback</code>. <br>2. <code>idx</code> - The index of the current record (<i>optional</i>). Type <code>number</code>. </p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code>Array of Object</code>B The array created by the callback function.</p> </dd> </dl> <h3 id="reverse"><span class="symbol-name">reverse</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>It reverses the record order.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;WeatherForcast&quot;, fields: [ { name: &quot;Weather&quot;, type: &quot;string&quot; }, { name: &quot;Date&quot;, type: &quot;datetime&quot; }, { name: &quot;TemperatureDegrees&quot;, type: &quot;int&quot; }, ] }] }); // put some records in the &quot;WeatherForecast&quot; store base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Partly Cloudy&quot;, Date: &quot;2015-05-27T11:00:00&quot;, TemperatureDegrees: 19 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Partly Cloudy&quot;, Date: &quot;2015-05-28T11:00:00&quot;, TemperatureDegrees: 22 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Mostly Cloudy&quot;, Date: &quot;2015-05-29T11:00:00&quot;, TemperatureDegrees: 25 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Mostly Cloudy&quot;, Date: &quot;2015-05-30T11:00:00&quot;, TemperatureDegrees: 25 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Scattered Showers&quot;, Date: &quot;2015-05-31T11:00:00&quot;, TemperatureDegrees: 24 }); base.store(&quot;WeatherForcast&quot;).push({ Weather: &quot;Mostly Cloudy&quot;, Date: &quot;2015-06-01T11:00:00&quot;, TemperatureDegrees: 27 }); // get the record set containing the records from the &quot;WeatherForcast&quot; store var recordSet &#x3D; base.store(&quot;WeatherForcast&quot;).allRecords; // reverse the record order in the record set recordSet.reverse(); // returns self, the records in the record set are in the reverse order base.close();</code></pre> </div> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.RecordSet.html">module:qm.RecordSet</a></code>B Self. Records are in reversed order.</p> </dd> </dl> <h3 id="sample"><span class="symbol-name">sample</span><span class="signature"><span class="signature-params">(num)</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.RecordSet.html">module:qm.RecordSet</a></span></span></h3> <p>Creates a random sample of records of the record set.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base with one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;Movies&quot;, fields: [ { name: &quot;Title&quot;, type: &quot;string&quot; }, { name: &quo