UNPKG

qminer

Version:

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

1,007 lines (1,006 loc) 134 kB
<!doctype html> <html> <head> <meta name="generator" content="JSDoc 3"> <meta charset="utf-8"> <title>Source: qminer_aggrdoc.js</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">Home</a> </div> </div> </nav> <div id="jsdoc-body-container"> <div id="jsdoc-content"> <div id="jsdoc-content-container"> <div id="jsdoc-banner" role="banner"> </div> <div id="jsdoc-main" role="main"> <header class="page-header"> <h1>Source: qminer_aggrdoc.js</h1> </header> <article> <pre class="prettyprint linenums"><code>/** * Copyright (c) 2015, Jozef Stefan Institute, Quintelligence d.o.o. and contributors * All rights reserved. * * This source code is licensed under the FreeBSD license found in the * LICENSE file in the root directory of this source tree. */ /** * QMiner module. * @module qm * @example * // import module * var qm &#x3D; require(&#x27;qminer&#x27;); */ /** * Stream Aggregate * @classdesc Represents a stream aggregate. The class can construct these {@link module:qm~StreamAggregator} objects. Also turn to these stream aggregators to see * which methods are implemented. * @class * @param {module:qm.Base} base - The base object on which it&#x27;s created. * @param {(module:qm~StreamAggregator | function)} arg - Constructor arguments. There are two argument types: * &amp;lt;br&gt;1. Using the {@link module:qm~StreamAggregator} object, * &amp;lt;br&gt;2. using a function/JavaScript class. The function has defined The object containing the schema of the stream aggregate or the function object defining the operations of the stream aggregate. * @param {(string | Array.&amp;lt;string&gt;)} [storeName] - The store names where the aggregate will be registered. * @example * // import qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a simple 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;Gendre&quot;, type: &quot;string&quot; }, * ] * }, * { * name: &quot;Laser&quot;, * fields: [ * { name: &quot;Time&quot;, type: &quot;datetime&quot; }, * { name: &quot;WaveLength&quot;, type: &quot;float&quot; } * ] * }] * }); * * // create a new stream aggregator for &#x27;People&#x27; store, get the length of the record name (with the function object) * var aggr &#x3D; new qm.StreamAggr(base, new function () { * var numOfAdds &#x3D; 0; * var numOfUpdates &#x3D; 0; * var numOfDeletes &#x3D; 0; * var time &#x3D; &quot;&quot;; * this.name &#x3D; &#x27;nameLength&#x27;, * this.onAdd &#x3D; function (rec) { * numOfAdds +&#x3D; 1; * }; * this.onUpdate &#x3D; function (rec) { * numOfUpdates +&#x3D; 1; * }; * this.onDelete &#x3D; function (rec) { * numOfDeletes +&#x3D; 1; * }; * this.onTime &#x3D; function (ts) { * time &#x3D; ts; * }; * this.saveJson &#x3D; function (limit) { * return { adds: numOfAdds, updates: numOfUpdates, deletes: numOfDeletes, time: time }; * }; * }, &quot;People&quot;); * * // create a new time series window buffer stream aggregator for &#x27;Laser&#x27; store (with the JSON object) * var wavelength &#x3D; { * name: &quot;WaveLengthLaser&quot;, * type: &quot;timeSeriesWinBuf&quot;, * store: &quot;Laser&quot;, * timestamp: &quot;Time&quot;, * value: &quot;WaveLength&quot;, * winsize: 10000 * } * var sa &#x3D; base.store(&quot;Laser&quot;).addStreamAggr(wavelength); * base.close(); */ exports.StreamAggr &#x3D; function (base, json, storeName) { return Object.create(require(&#x27;qminer&#x27;).StreamAggr.prototype); }; /** * @typedef {module:qm.StreamAggr} StreamAggregator * Stream aggregator types. * @property {module:qm~StreamAggrTimeSeriesWindow} timeSeries - The time series type. * @property {module:qm~StreamAggrTimeSeriesWindowVector} timeSeriesBufferVector - The time series buffer vector type. * @property {module:qm~StreamAggrTimeSeriesTick} tick - The time series tick type. * @property {module:qm~StreamAggrRecordBuffer} record-buffer - The record buffer type. * @property {module:qm~StreamAggrFeatureSpace} ftr-space - The feature space type. * @property {module:qm~StreamAggrSum} sum - The sum type. Calculates the sum of values. * @property {module:qm~StreamAggrMin} min - The minimal type. Saves the minimal value in the buffer. * @property {module:qm~StreamAggrMax} max - The maximal type. Saves the maximal value in the buffer. * @property {module:qm~StreamAggrSparseVecSum} sparse-vec-sum - The sparse-vector-sum type. * @property {module:qm~StreamAggrMovingAverage} ma - The moving average type. Calculates the average within the window. * @property {module:qm~StreamAggrEMA} ema - The exponental moving average type. Calculates the exponental average of the values. * @property {module:qm~StreamAggrEMASpVec} ema-sp-vec - The exponental moving average for sparse vectors type. * @property {module:qm~StreamAggrMovingVariance} var - The moving variance type. Calculates the variance of values within the window. * @property {module:qm~StreamAggrMovingCovariance} cov - The moving covariance type. Calculates the covariance of values within the window. * @property {module:qm~StreamAggrMovingCorrelation} cor - The moving correlation type. Calculates the correlation of values within the window. * @property {module:qm~StreamAggrResampler} res - The resampler type. Resamples the records so that they come in in the same time interval. * @property {module:qm~StreamAggrAggrResampler} aggr-res - The aggregating (avg/sum) resampler type. Resamplers the records so that it takes the * records in the time window and returns one sample. * @property {module:qm~StreamAggrMerger} mer - The merger type. Merges the records from two stream series. * @property {module:qm~StreamAggrHistogram} hist - The online histogram type. * @property {module:qm~StreamAggrSlottedHistogram} slotted-hist - The online slotted-histogram type. * @property {module:qm~StreamAggrVecDiff} vec-diff - The difference of two vectors (e.g. online histograms) type. * @property {module:qm~StreamAggrSimpleLinearRegression} lin-reg - The linear regressor type. * @property {module:qm~StreamAggrAnomalyDetectorNN} detector-nn - The anomaly detector type. Detects anomalies using the k nearest neighbour algorithm. * @property {module:qm~StreamAggrThreshold} treshold - The threshold indicator type. * @property {module:qm~StreamAggrTDigest} tdigest - The quantile estimator type. It estimates the quantiles of the given data using {@link module:analytics.TDigest TDigest}. * @property {module:qm~StreamAggrRecordSwitch} record-switch-aggr - The record switch type. * @property {module:qm~StreamAggrPageHinkley} pagehinkley - The Page-Hinkley test for concept drift detection type. */ /** * @typedef {module:qm.StreamAggr} StreamAggrTimeSeriesWindow * This stream aggregator represents the time series window buffer. It stores the values inside a moving window. * It implements all the stream aggregate methods &amp;lt;b&gt;except&amp;lt;/b&gt; {@link module:qm.StreamAggr#getFloat} and {@link module:qm.StreamAggr#getTimestamp}. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;timeSeriesWinBuf&#x27;&#x60;. * @property {string} store - The name of the store from which to takes the data. * @property {string} timestamp - The field of the store, where it takes the timestamp. * @property {string} value - The field of the store, where it takes the values. * @property {number} winsize - The size of the window, in milliseconds. * @property {number} delay - Delay in milliseconds. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 2 seconds (2000ms). * var aggr &#x3D; { * name: &#x27;TimeSeriesAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27;, * winsize: 2000 * }; * base.store(&quot;Heat&quot;).addStreamAggr(aggr); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrTimeSeriesWindowVector * This stream aggregator represents the values read from a time series window buffer. * It implements {@link module:qm.StreamAggr#getFloatVector}, {@link module:qm.StreamAggr#getFloatAt} and {@link module:qm.StreamAggr#getFloatLength}. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;timeSeriesWinBuf&#x27;&#x60;. * @property {string} store - The name of the store from which to takes the data. * @property {string} inAggr - The name of the window buffer aggregate that represents the input. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [{ * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * var store &#x3D; base.store(&quot;Heat&quot;); * var tick &#x3D; store.addStreamAggr({ * type: &#x27;timeSeriesTick&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27; * }); * * var winbufvec &#x3D; store.addStreamAggr({ * type: &#x27;timeSeriesWinBufVector&#x27;, * inAggr: tick.name, * winsize: 2000 * }); * * store.push({ Time: &#x27;2015-06-10T14:13:32.0&#x27;, Celsius: 1 }); * winbufvec.getFloatVector().print(); // prints 1 * store.push({ Time: &#x27;2015-06-10T14:33:30.0&#x27;, Celsius: 2 }); * winbufvec.getFloatVector().print(); // prints 2 * store.push({ Time: &#x27;2015-06-10T14:33:31.0&#x27;, Celsius: 3 }); * winbufvec.getFloatVector().print(); // prints 2,3 * store.push({ Time: &#x27;2015-06-10T14:33:32.0&#x27;, Celsius: 4 }); * winbufvec.getFloatVector().print(); // prints 2,3,4 * * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrRecordBuffer * This stream aggregator represents record buffer. It stores the values inside a moving window. * It implements all the stream aggregate methods &amp;lt;b&gt;except&amp;lt;/b&gt; {@link module:qm.StreamAggr#getFloat} and {@link module:qm.StreamAggr#getTimestamp}. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;recordBuffer&#x27;&#x60;. * @property {number} size - The size of the window. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store. The size of the window is 3 records. * var aggr &#x3D; { * name: &#x27;Delay&#x27;, * type: &#x27;recordBuffer&#x27;, * size: 3 * }; * base.store(&quot;Heat&quot;).addStreamAggr(aggr); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrSum * This stream aggregator represents the sum moving window buffer. It sums all the values, that are in the connected stream aggregator. * It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the sum of the values of the records in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;winBufSum&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Income&quot;, * fields: [ * { name: &quot;Amount&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Income&#x27; store, that takes the values from the &#x27;Amount&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window should 1 week. * var timeser &#x3D; { * name: &#x27;TimeSeriesAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Income&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Amount&#x27;, * winsize: 604800000 // 7 days in miliseconds * }; * var timeSeries &#x3D; base.store(&quot;Income&quot;).addStreamAggr(timeser); * * // add a sum aggregator, that is connected with the &#x27;TimeSeriesAggr&#x27; aggregator * var sum &#x3D; { * name: &#x27;SumAggr&#x27;, * type: &#x27;winBufSum&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;TimeSeriesAggr&#x27; * }; * var sumAggr &#x3D; base.store(&quot;Income&quot;).addStreamAggr(sum); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrMin * This stream aggregator represents the minimum moving window buffer. It monitors the minimal value in the connected stream aggregator. * It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the minimal value of the records in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;winBufMin&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 1 day. * var timeser &#x3D; { * name: &#x27;TimeSeriesAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27;, * winsize: 86400000 // 1 day in miliseconds * }; * var timeSeries &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(timeser); * * // add a min aggregator, that is connected with the &#x27;TimeSeriesAggr&#x27; aggregator * var min &#x3D; { * name: &#x27;MinAggr&#x27;, * type: &#x27;winBufMin&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;TimeSeriesAggr&#x27; * }; * var minimal &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(min); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrMax * This stream aggregator represents the maximum moving window buffer. It monitors the maximal value in the connected stream aggregator. * It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the maximal value of the records in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type for the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;winBufMax&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 1 day. * var timeser &#x3D; { * name: &#x27;TimeSeriesAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27;, * winsize: 86400000 // one day in miliseconds * }; * var timeSeries &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(timeser); * * // add a max aggregator, that is connected with the &#x27;TimeSeriesAggr&#x27; aggregator * var max &#x3D; { * name: &#x27;MaxAggr&#x27;, * type: &#x27;winBufMax&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;TimeSeriesAggr&#x27; * }; * var maximal &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(max); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrSparseVecSum * This stream aggregator represents the sparse-vector-sum moving window buffer. It sums all the sparse-vector values, that are in the connected stream aggregator. * It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getValueVector} returns the sum of the values of the records in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;winBufSpVecSum&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * @example * var qm &#x3D; require(&#x27;qminer&#x27;); * var base &#x3D; new qm.Base({ * mode: &#x27;createClean&#x27;, * schema: [{ * name: &#x27;Docs&#x27;, * fields: [ * { name: &#x27;Time&#x27;, type: &#x27;datetime&#x27; }, * { name: &#x27;Text&#x27;, type: &#x27;string&#x27; } * ] * }] * }); * var store &#x3D; base.store(&#x27;Docs&#x27;); * * var aggr &#x3D; { * name: &#x27;featureSpaceWindow&#x27;, * type: &#x27;timeSeriesWinBufFeatureSpace&#x27;, * store: &#x27;Docs&#x27;, * timestamp: &#x27;Time&#x27;, * featureSpace: { * type: &quot;categorical&quot;, * source: &quot;Docs&quot;, * field: &quot;Text&quot; * }, * winsize: 1000 * }; * var sa &#x3D; store.addStreamAggr(aggr); * * var aggr2 &#x3D; { * name: &#x27;sparseVectorSum&#x27;, * type: &#x27;winBufSpVecSum&#x27;, * store: &#x27;Docs&#x27;, * inAggr: &#x27;featureSpaceWindow&#x27; * }; * var sa2 &#x3D; store.addStreamAggr(aggr2); * * store.push({ Time: &#x27;2015-06-10T14:13:32.0&#x27;, Text: &#x27;a&#x27; }); // 0 * store.push({ Time: &#x27;2015-06-10T14:13:33.0&#x27;, Text: &#x27;b&#x27; }); // 1 * store.push({ Time: &#x27;2015-06-10T14:14:34.0&#x27;, Text: &#x27;c&#x27; }); // 2 * store.push({ Time: &#x27;2015-06-10T14:15:35.0&#x27;, Text: &#x27;d&#x27; }); // 3 * store.push({ Time: &#x27;2015-06-10T14:15:36.0&#x27;, Text: &#x27;e&#x27; }); // 4 * store.push({ Time: &#x27;2015-06-10T14:15:37.0&#x27;, Text: &#x27;f&#x27; }); // 5 * * var valVec2 &#x3D; sa2.getValueVector(); // [0, 0, 0, 0, 1, 1] - only vectors 4 and 5 remain in window * * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrTimeSeriesTick * This stream aggregator represents the time series tick window buffer. It exposes the data to other stream aggregators * (similar to {@link module:qm~StreamAggrTimeSeriesWindow}). It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the last value added in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;timeSeriesTick&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} value - The name of the store field, from which it takes the values. * @property {string} timestamp - The name of the store field, from which it takes the timestamp. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Students&quot;, * fields: [ * { name: &quot;Id&quot;, type: &quot;float&quot; }, * { name: &quot;TimeOfGraduation&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series tick stream aggregator for the &#x27;Students&#x27; store, that takes the values from the &#x27;Id&#x27; field * // and the timestamp from the &#x27;TimeOfGraduation&#x27; field. * var tick &#x3D; { * name: &#x27;TimeSeriesTickAggr&#x27;, * type: &#x27;timeSeriesTick&#x27;, * store: &#x27;Students&#x27;, * timestamp: &#x27;TimeOfGraduation&#x27;, * value: &#x27;Id&#x27;, * }; * var timeSeriesTick &#x3D; base.store(&quot;Students&quot;).addStreamAggr(tick); * base.close(); */ /** * @typedef {module:qmStreamAggr} StreamAggrMovingAverage * This stream aggregator represents the moving average window buffer. It calculates the moving average value of the connected stream aggregator values. * It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the average of the values in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name of the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;ma&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window should be 1 day. * var timeser &#x3D; { * name: &#x27;TimeSeriesAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27;, * winsize: 86400000 * }; * var timeSeries &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(timeser); * * // add a moving average aggregator, that is connected with the &#x27;TimeSeriesAggr&#x27; aggregator * var ma &#x3D; { * name: &#x27;movingAverageAggr&#x27;, * type: &#x27;ma&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;TimeSeriesAggr&#x27; * }; * var movingAverage &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(ma); * base.close(); */ /** * @typedef {module:qmStreamAggr} StreamAggrEMA * This stream aggregator represents the exponential moving average window buffer. It calculates the weighted moving average * of the values in the connected stream aggregator, where the weights are exponentially decreasing. It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the exponentional average of the values in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;ema&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * It &amp;lt;b&gt;cannot&amp;lt;/b&gt; be connect to the {@link module:qm~StreamAggrTimeSeriesWindow}. * @property {string} emaType - The type of interpolation. Possible options are: * &amp;lt;br&gt;1. &#x60;&#x27;previous&#x27;&#x60; - Interpolates with the previous value. * &amp;lt;br&gt;2. &#x60;&#x27;next&#x27;&#x60; - Interpolates with the next value. * &amp;lt;br&gt;3. &#x60;&#x27;linear&#x27;&#x60; - Makes a linear interpolation. * @property {number} interval - The time interval defining the decay. It must be greater than &#x60;initWindow&#x60;. * @property {number} initWindow - The time window of required values for initialization. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series tick stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window should be 1 hour. * var timeser &#x3D; { * name: &#x27;TimeSeriesAggr&#x27;, * type: &#x27;timeSeriesTick&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27; * }; * var timeSeries &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(timeser); * * // add an exponentional moving average aggregator, that is connected with the &#x27;TimeSeriesAggr&#x27; aggregator. * // It should interpolate with the previous value, the decay should be 3 seconds and the initWindow should be 2 seconds. * var ema &#x3D; { * name: &#x27;emaAggr&#x27;, * type: &#x27;ema&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;TimeSeriesAggr&#x27;, * emaType: &#x27;previous&#x27;, * interval: 3000, * initWindow: 2000 * }; * var expoMovingAverage &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(ema); * base.close(); */ /** * @typedef {module:qmStreamAggr} StreamAggrThreshold * This stream aggregator represents a threshold indicator. It outputs 1 if the current value in the data streams is * above the threshold and 0 otherwise. It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the exponentional average of the values in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;ema&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * It &amp;lt;b&gt;cannot&amp;lt;/b&gt; be connect to the {@link module:qm~StreamAggrTimeSeriesWindow}. * @property {string} threshold - The threshold mentioned above. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series tick stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window should be 1 hour. * var timeser &#x3D; { * name: &#x27;TimeSeriesTickAggr&#x27;, * type: &#x27;timeSeriesTick&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27; * }; * var timeSeries &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(timeser); * * // a threshold aggregator, that is connected wit hthe &#x27;TimeSeriesAggr&#x27; aggregator. * // It should output 1 when the temperature is over 3 degrees Celsius and 0 otherwise * var thresholdAggr &#x3D; { * name: &#x27;thresholdAggr1&#x27;, * type: &#x27;threshold&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;TimeSeriesTickAggr&#x27;, * threshold: 3 * }; * var expoMovingAverage &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(thresholdAggr); * base.close(); */ /** * @typedef {module:qmStreamAggr} StreamAggrEMASpVec * This stream aggregator represents the exponential moving average window buffer for sparse vectors. It calculates the weighted moving average * of the values in the connected stream aggregator, where the weights are exponentially decreasing. It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getValueVector} returns the exponentional average of the sparse vector values in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;ema&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * It &amp;lt;b&gt;cannot&amp;lt;/b&gt; be connect to the {@link module:qm~StreamAggrTimeSeriesWindow}. * @property {string} emaType - The type of interpolation. Possible options: * &amp;lt;br&gt;1. &#x60;&#x27;previous&#x27;&#x60; - Interpolates with the previous value. * &amp;lt;br&gt;2. &#x60;&#x27;next&#x27;&#x60; - Interpolates with the next value. * &amp;lt;br&gt;3. &#x60;&#x27;linear&#x27;&#x60; - Makes a linear interpolation. * @property {number} interval - The time interval defining the decay. It must be greater than &#x60;initWindow&#x60;. * @property {number} [initWindow&#x3D;0] - The time window of required values for initialization. * @property {number} [cuttof&#x3D;0.001] - Minimal value for any dimension. If value of certain dimension falls bellow this value, the dimension is pruned from average. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Data&quot;, * fields: [ * { name: &quot;Text&quot;, type: &quot;string&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * var store &#x3D; base.store(&quot;Data&quot;); * // create a new time series that emits data as sparse vector, based on text * var aggr &#x3D; { * name: &#x27;featureSpaceWindow&#x27;, * type: &#x27;timeSeriesWinBufFeatureSpace&#x27;, * store: store.name, * timestamp: &#x27;Time&#x27;, * featureSpace: { * type: &quot;categorical&quot;, * source: store.name, * field: &quot;Text&quot; * }, * winsize: 1 // keep only most recent value in window * }; * // attach sum * var sa &#x3D; store.addStreamAggr(aggr); * var aggr2 &#x3D; { * name: &#x27;sparseVectorSum&#x27;, * type: &#x27;winBufSpVecSum&#x27;, * store: store.name, * inAggr: aggr.name // this means that sum is equal to the most recent data * }; * // ok, now attach EMA * var sa2 &#x3D; store.addStreamAggr(aggr2); * var ema_def &#x3D; { * name: &#x27;sparseVectorEma&#x27;, * type: &#x27;emaSpVec&#x27;, * store: store.name, * inAggr: aggr2.name, * emaType: &quot;next&quot;, * interval: 2000, * initWindow: 0 * }; * var ema &#x3D; store.addStreamAggr(ema_def); * // add some data * store.push({ Time: 1000, Text: &#x27;a&#x27; }); * store.push({ Time: 2000, Text: &#x27;b&#x27; }); * store.push({ Time: 3000, Text: &#x27;c&#x27; }); * // display EMA data * ema.getValueVector().print(); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrMovingVariance * This stream aggregator represents the moving variance window buffer. It calculates the moving variance of the stream aggregator, that it&#x27;s connected to. * It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the variance of the values in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;variance&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggr - The name of the stream aggregator to which it connects and gets data. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 1 day * var timeser &#x3D; { * name: &#x27;TimeSeriesAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27;, * winsize: 86400000 * }; * var timeSeries &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(timeser); * * // add a variance aggregator, that is connected with the &#x27;TimeSeriesAggr&#x27; aggregator * var variance &#x3D; { * name: &#x27;varAggr&#x27;, * type: &#x27;variance&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;TimeSeriesAggr&#x27; * }; * var varianceAggr &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(variance); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrMovingCovariance * This stream aggregator represents the moving covariance window buffer. It calculates the moving covariance of the two stream aggregators, that it&#x27;s connected to. * It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the covariance of the values in its buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in its buffer window. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;covariance&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggrX - The name of the first stream aggregator to which it connects and gets data. * @property {string} inAggrY - The name of the recond stream aggregator to which it connects and gets data. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;WaterConsumption&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 1 day. * var Celsius &#x3D; { * name: &#x27;CelsiusAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27;, * winsize: 86400000 * }; base.store(&quot;Heat&quot;).addStreamAggr(Celsius); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;WaterConsumption&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 1 day. * var water &#x3D; { * name: &#x27;WaterAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;WaterConsumption&#x27;, * winsize: 86400000 * }; base.store(&quot;Heat&quot;).addStreamAggr(water); * * // add a covariance aggregator, that is connected with the &#x27;CelsiusAggr&#x27; and &#x27;WaterAggr&#x27; stream aggregators * var covariance &#x3D; { * name: &#x27;covAggr&#x27;, * type: &#x27;covariance&#x27;, * store: &#x27;Heat&#x27;, * inAggrX: &#x27;CelsiusAggr&#x27;, * inAggrY: &#x27;WaterAggr&#x27; * }; * var covarianceAggr &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(covariance); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrMovingCorrelation * This stream aggregator represents the moving covariance window buffer. It calculates the moving correlation of the three stream aggregators, * that it&#x27;s connected to. It implements the following methods: * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the correlation of the values in it&#x27;s buffer window. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the newest record in it&#x27;s buffer window. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;correlation&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} inAggrCov - The name of the covariance stream aggregator. * @property {string} inAggrVarX - The name of the first variance stream aggregator. * @property {string} inAggrVarY - The name of the second variance stream aggregator. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;WaterConsumption&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 1 day * var Celsius &#x3D; { * name: &#x27;CelsiusAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;Celsius&#x27;, * winsize: 86400000 * }; base.store(&quot;Heat&quot;).addStreamAggr(Celsius); * * // create a new time series stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;WaterConsumption&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The size of the window is 1 day * var water &#x3D; { * name: &#x27;WaterAggr&#x27;, * type: &#x27;timeSeriesWinBuf&#x27;, * store: &#x27;Heat&#x27;, * timestamp: &#x27;Time&#x27;, * value: &#x27;WaterConsumption&#x27;, * winsize: 86400000 * }; base.store(&quot;Heat&quot;).addStreamAggr(water); * * // add a covariance aggregator, that is connected with the &#x27;CelsiusAggr&#x27; and &#x27;WaterAggr&#x27; aggregators * var covariance &#x3D; { * name: &#x27;covarianceAggr&#x27;, * type: &#x27;covariance&#x27;, * store: &#x27;Heat&#x27;, * inAggrX: &#x27;CelsiusAggr&#x27;, * inAggrY: &#x27;WaterAggr&#x27; * }; base.store(&quot;Heat&quot;).addStreamAggr(covariance); * * // add the two variance aggregators, that take from the &#x27;Celsius&#x27; and &#x27;WaterConsumption&#x27; fields, respectively * var celVar &#x3D; { * name: &#x27;CelsiusVarAggr&#x27;, * type: &#x27;variance&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;CelsiusAggr&#x27; * }; base.store(&quot;Heat&quot;).addStreamAggr(celVar); * * var waterVar &#x3D; { * name: &#x27;waterVarAggr&#x27;, * type: &#x27;variance&#x27;, * store: &#x27;Heat&#x27;, * inAggr: &#x27;WaterAggr&#x27; * }; base.store(&quot;Heat&quot;).addStreamAggr(waterVar); * * // add a correlation aggregator, that is connected to &#x27;CovarianceAggr&#x27;, &#x27;CelsiusVarAggr&#x27; and &#x27;WaterValAggr&#x27; aggregators * var corr &#x3D; { * name: &#x27;corrAggr&#x27;, * type: &#x27;correlation&#x27;, * store: &#x27;Heat&#x27;, * inAggrCov: &#x27;covarianceAggr&#x27;, * inAggrVarX: &#x27;CelsiusVarAggr&#x27;, * inAggrVarY: &#x27;waterVarAggr&#x27; * }; * var correlation &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(corr); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrResampler * This stream aggregator represents the resampler window buffer. It creates new values that are interpolated by using the values from an existing store. * No methods are implemented for this aggregator. * @property {string} name - The given name for the stream aggregator. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;resampler&#x27;&#x60;. * @property {string} store - The name of the store from which it takes the data. * @property {string} outStore - The store in which the samples are stored. * @property {string} timestamp - The store field from which it takes the timestamps. * @property {Array.&amp;lt;Object&gt;} fields - The array off &#x60;field&#x60; objects from which it takes the values. The &#x60;field&#x60; object contain the properties: * &amp;lt;br&gt;&#x60;field.name&#x60; - The store field from which it takes the values. Type &#x60;string&#x60;. * &amp;lt;br&gt;&#x60;field.interpolator&#x60; - The type of the interpolation. The options are &#x60;&#x27;previous&#x27;&#x60;, &#x60;&#x27;next&#x27;&#x60; and &#x60;&#x27;linear&#x27;&#x60;. Type &#x60;string&#x60;. * @property {boolean} createStore - If true, &#x60;outStore&#x60; must be created. * @property {number} interval - The interval size. The frequency on which it makes the interpolated values. * @example * // import the qm module * var qm &#x3D; require(&#x27;qminer&#x27;); * // create a base with a simple store * var base &#x3D; new qm.Base({ * mode: &quot;createClean&quot;, * schema: [ * { * name: &quot;Heat&quot;, * fields: [ * { name: &quot;Celsius&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }, * { * name: &quot;interpolatedValues&quot;, * fields: [ * { name: &quot;Value&quot;, type: &quot;float&quot; }, * { name: &quot;Time&quot;, type: &quot;datetime&quot; } * ] * }] * }); * // create a new resampler stream aggregator for the &#x27;Heat&#x27; store, that takes the values from the &#x27;Celsius&#x27; field * // and the timestamp from the &#x27;Time&#x27; field. The interpolated values are stored in the &#x27;interpolatedValues&#x27; store. * // The interpolation should be linear and the interval should be 2 seconds * var res &#x3D; { * name: &#x27;resamplerAggr&#x27;, * type: &#x27;resampler&#x27;, * store: &#x27;Heat&#x27;, * outStore: &#x27;interpolatedValues&#x27;, * timestamp: &#x27;Time&#x27;, * fields: [{ * name: &#x27;Celsius&#x27;, * interpolator: &#x27;linear&#x27; * }], * createStore: false, * interval: 2000 * }; * var resampler &#x3D; base.store(&quot;Heat&quot;).addStreamAggr(res); * base.close(); */ /** * @typedef {module:qm.StreamAggr} StreamAggrAggrResampler * This stream aggregate resamples an input time series to a new time seris * of equally spaced measurements. Each new measurement corresponds to an * aggregate (sum,avg,min,max) computed over an interval. The aggregate * exposes the following methods. * &amp;lt;br&gt;1. {@link module:qm.StreamAggr#getFloat} returns the last resampled value. * &amp;lt;br&gt;2. {@link module:qm.StreamAggr#getTimestamp} returns the timestamp of the last resampled value. * &amp;lt;br&gt;3. {@link module:qm.StreamAggr#onStep} reads from an input aggregate and tries to resample. * &amp;lt;br&gt;4. {@link module:qm.StreamAggr#onTime} updates the current time (no data has arrived, but time has passed) and tries to resample. * &amp;lt;br&gt;5. {@link module:qm.StreamAggr#getParams} returns a parameter object. * &amp;lt;br&gt;6. {@link module:qm.StreamAggr#setParams} used primarily for setting the out-aggregate. * &amp;lt;br&gt;The stream aggregate exposes its results through &#x60;getFloat&#x60; and &#x60;getTimestamp&#x60; methods (itself represents timeseries). * The resampler has an input time-series aggregate (supports &#x60;getFloat&#x60; and &#x60;getTimestamp&#x60;), from where it reads time series values. * The reading and resampling occourrs wehen resamplers &#x60;onStep()&#x60; or &#x60;onTime()&#x60; methods are called. * When resampling succeeds (all the data needed for the computation becomes available), the resampler * will trigger the &#x60;onStep()&#x60; method of an output stream aggregate that will read the resamplers state through &#x60;getFloat&#x60; and &#x60;getTime&#x60;. * @property {string} type - The type of the stream aggregator. &amp;lt;b&gt;Important:&amp;lt;/b&gt; It must be equal to &#x60;&#x27;aggrResampler&#x27;&#x60;. * @property {number} interval - Interval size in milliseconds * @property {string} aggType - Must be one of the values: &#x60;&quot;sum&quot;&#x60;, &#x60;&quot;avg&quot;&#x60;, &#x60;&quot;min&quot;&#x60; or &#x60;&quot;max&q