-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathml3.3.0.min.js
16 lines (16 loc) · 218 KB
/
ml3.3.0.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/** [email protected], MIT licensed. https://github.com/mljs/ml */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ML=e():t.ML=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=53)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(5);Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g(n).default}}),Object.defineProperty(e,"Matrix",{enumerable:!0,get:function(){return g(n).default}});var i=r(7);Object.defineProperty(e,"abstractMatrix",{enumerable:!0,get:function(){return g(i).default}});var o=r(66);Object.defineProperty(e,"wrap",{enumerable:!0,get:function(){return o.wrap}});var s=r(20);Object.defineProperty(e,"WrapperMatrix2D",{enumerable:!0,get:function(){return g(s).default}});var a=r(19);Object.defineProperty(e,"WrapperMatrix1D",{enumerable:!0,get:function(){return g(a).default}});var u=r(67);Object.defineProperty(e,"solve",{enumerable:!0,get:function(){return u.solve}}),Object.defineProperty(e,"inverse",{enumerable:!0,get:function(){return u.inverse}});var h=r(68);Object.defineProperty(e,"linearDependencies",{enumerable:!0,get:function(){return h.linearDependencies}});var l=r(8);Object.defineProperty(e,"SingularValueDecomposition",{enumerable:!0,get:function(){return g(l).default}}),Object.defineProperty(e,"SVD",{enumerable:!0,get:function(){return g(l).default}});var c=r(69);Object.defineProperty(e,"EigenvalueDecomposition",{enumerable:!0,get:function(){return g(c).default}}),Object.defineProperty(e,"EVD",{enumerable:!0,get:function(){return g(c).default}});var f=r(70);Object.defineProperty(e,"CholeskyDecomposition",{enumerable:!0,get:function(){return g(f).default}}),Object.defineProperty(e,"CHO",{enumerable:!0,get:function(){return g(f).default}});var d=r(10);Object.defineProperty(e,"LuDecomposition",{enumerable:!0,get:function(){return g(d).default}}),Object.defineProperty(e,"LU",{enumerable:!0,get:function(){return g(d).default}});var m=r(21);function g(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"QrDecomposition",{enumerable:!0,get:function(){return g(m).default}}),Object.defineProperty(e,"QR",{enumerable:!0,get:function(){return g(m).default}})},function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;n<t.length;n++)r+=(t[n]-e[n])*(t[n]-e[n]);return r}function i(t,e){return Math.sqrt(n(t,e))}t.exports=i,i.squared=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(121);Object.defineProperty(e,"maybeToPrecision",{enumerable:!0,get:function(){return o(n).default}});var i=r(122);function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"checkArrayLength",{enumerable:!0,get:function(){return o(i).default}});class s{constructor(){if(new.target===s)throw new Error("BaseRegression must be subclassed")}predict(t){if("number"==typeof t)return this._predict(t);if(Array.isArray(t)){for(var e=new Array(t.length),r=0;r<t.length;r++)e[r]=this._predict(t[r]);return e}throw new TypeError("x must be a number or array")}_predict(){throw new Error("_predict must be implemented")}train(){}toString(){return""}toLaTeX(){return""}score(t,e){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)throw new Error("x and y must be arrays of the same length");for(var r=t.length,n=new Array(r),i=0;i<r;i++)n[i]=this._predict(t[i]);for(var o=0,s=0,a=0,u=0,h=0,l=0,c=0,f=0;f<r;f++)o+=n[f],s+=e[f],h+=n[f]*n[f],l+=e[f]*e[f],c+=n[f]*e[f],0!==e[f]&&(a+=(e[f]-n[f])*(e[f]-n[f])/e[f]),u=(e[f]-n[f])*(e[f]-n[f]);var d=(r*c-o*s)/Math.sqrt((r*h-o*o)*(r*l-s*s));return{r:d,r2:d*d,chi2:a,rmsd:u*u/r}}}e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(r(7)),i=o(r(5));function o(t){return t&&t.__esModule?t:{default:t}}e.default=class extends((0,n.default)()){constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}static get[Symbol.species](){return i.default}}},function(t,e,r){"use strict";e.array=r(24),e.matrix=r(9)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(r(7)),i=r(6);class o extends((0,n.default)(Array)){constructor(t,e){var r;if(1===arguments.length&&"number"==typeof t)return new Array(t);if(o.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>0){if(super(t),!(Number.isInteger(e)&&e>0))throw new TypeError("nColumns must be a positive integer");for(r=0;r<t;r++)this[r]=new Array(e)}else{if(!Array.isArray(t))throw new TypeError("First argument must be a positive number or an array");var n=t;if(t=n.length,"number"!=typeof(e=n[0].length)||0===e)throw new TypeError("Data must be a 2D array with at least one element");for(super(t),r=0;r<t;r++){if(n[r].length!==e)throw new RangeError("Inconsistent array dimensions");this[r]=[].concat(n[r])}}return this.rows=t,this.columns=e,this}set(t,e,r){return this[t][e]=r,this}get(t,e){return this[t][e]}removeRow(t){if((0,i.checkRowIndex)(this,t),1===this.rows)throw new RangeError("A matrix cannot have less than one row");return this.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),(0,i.checkRowIndex)(this,t,!0),e=(0,i.checkRowVector)(this,e,!0),this.splice(t,0,e),this.rows+=1,this}removeColumn(t){if((0,i.checkColumnIndex)(this,t),1===this.columns)throw new RangeError("A matrix cannot have less than one column");for(var e=0;e<this.rows;e++)this[e].splice(t,1);return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),(0,i.checkColumnIndex)(this,t,!0),e=(0,i.checkColumnVector)(this,e);for(var r=0;r<this.rows;r++)this[r].splice(t,0,e[r]);return this.columns+=1,this}}e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.checkRowIndex=function(t,e,r){var n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")},e.checkColumnIndex=function(t,e,r){var n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")},e.checkRowVector=function(t,e){e.to1DArray&&(e=e.to1DArray());if(e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e},e.checkColumnVector=function(t,e){e.to1DArray&&(e=e.to1DArray());if(e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e},e.checkIndices=function(t,e,r){return{row:i(t,e),column:o(t,r)}},e.checkRowIndices=i,e.checkColumnIndices=o,e.checkRange=function(t,e,r,n,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(s("startRow",e),s("endRow",r),s("startColumn",n),s("endColumn",i),e>r||n>i||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")},e.getRange=function(t,e){for(var r=new Array(e-t+1),n=0;n<r.length;n++)r[n]=t+n;return r},e.sumByRow=function(t){for(var e=n.default.zeros(t.rows,1),r=0;r<t.rows;++r)for(var i=0;i<t.columns;++i)e.set(r,0,e.get(r,0)+t.get(r,i));return e},e.sumByColumn=function(t){for(var e=n.default.zeros(1,t.columns),r=0;r<t.rows;++r)for(var i=0;i<t.columns;++i)e.set(0,i,e.get(0,i)+t.get(r,i));return e},e.sumAll=function(t){for(var e=0,r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)e+=t.get(r,n);return e};var n=function(t){return t&&t.__esModule?t:{default:t}}(r(5));function i(t,e){if("object"!=typeof e)throw new TypeError("unexpected type for row indices");if(e.some(e=>e<0||e>=t.rows))throw new RangeError("row indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function o(t,e){if("object"!=typeof e)throw new TypeError("unexpected type for column indices");if(e.some(e=>e<0||e>=t.columns))throw new RangeError("column indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function s(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){void 0===t&&(t=Object);class e extends t{static get[Symbol.species](){return this}static from1DArray(t,e,r){var n=t*e;if(n!==r.length)throw new RangeError("Data length does not match given dimensions");for(var i=new this(t,e),o=0;o<t;o++)for(var s=0;s<e;s++)i.set(o,s,r[o*e+s]);return i}static rowVector(t){for(var e=new this(1,t.length),r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){for(var e=new this(t.length,1),r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static empty(t,e){return new this(t,e)}static zeros(t,e){return this.empty(t,e).fill(0)}static ones(t,e){return this.empty(t,e).fill(1)}static rand(t,e,r){void 0===r&&(r=Math.random);for(var n=this.empty(t,e),i=0;i<t;i++)for(var o=0;o<e;o++)n.set(i,o,r());return n}static randInt(t,e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=Math.random);for(var i=this.empty(t,e),o=0;o<t;o++)for(var s=0;s<e;s++){var a=Math.floor(n()*r);i.set(o,s,a)}return i}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);for(var n=Math.min(t,e),i=this.zeros(t,e),o=0;o<n;o++)i.set(o,o,r);return i}static diag(t,e,r){var n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);for(var i=Math.min(n,e,r),o=this.zeros(e,r),s=0;s<i;s++)o.set(s,s,t[s]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);for(var r=t.rows,n=t.columns,i=new this(r,n),o=0;o<r;o++)for(var s=0;s<n;s++)i.set(o,s,Math.min(t.get(o,s),e.get(o,s)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);for(var r=t.rows,n=t.columns,i=new this(r,n),o=0;o<r;o++)for(var s=0;s<n;s++)i.set(o,s,Math.max(t.get(o,s),e.get(o,s)));return i}static checkMatrix(t){return e.isMatrix(t)?t:new this(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(var e=this.rows,r=this.columns,n=0;n<e;n++)for(var i=0;i<r;i++)t.call(this,n,i);return this}to1DArray(){for(var t=new Array(this.size),e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t[e*this.columns+r]=this.get(e,r);return t}to2DArray(){for(var t=new Array(this.rows),e=0;e<this.rows;e++){t[e]=new Array(this.columns);for(var r=0;r<this.columns;r++)t[e][r]=this.get(e,r)}return t}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isSymmetric(){if(this.isSquare()){for(var t=0;t<this.rows;t++)for(var e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}set(t,e,r){throw new Error("set method is unimplemented")}get(t,e){throw new Error("get method is unimplemented")}repeat(t,e){t=t||1,e=e||1;for(var r=new this.constructor[Symbol.species](this.rows*t,this.columns*e),n=0;n<t;n++)for(var i=0;i<e;i++)r.setSubMatrix(this,this.rows*n,this.columns*i);return r}fill(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){(0,s.checkRowIndex)(this,t);for(var e=new Array(this.columns),r=0;r<this.columns;r++)e[r]=this.get(t,r);return e}getRowVector(t){return this.constructor.rowVector(this.getRow(t))}setRow(t,e){(0,s.checkRowIndex)(this,t),e=(0,s.checkRowVector)(this,e);for(var r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){(0,s.checkRowIndex)(this,t),(0,s.checkRowIndex)(this,e);for(var r=0;r<this.columns;r++){var n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){(0,s.checkColumnIndex)(this,t);for(var e=new Array(this.rows),r=0;r<this.rows;r++)e[r]=this.get(r,t);return e}getColumnVector(t){return this.constructor.columnVector(this.getColumn(t))}setColumn(t,e){(0,s.checkColumnIndex)(this,t),e=(0,s.checkColumnVector)(this,e);for(var r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){(0,s.checkColumnIndex)(this,t),(0,s.checkColumnIndex)(this,e);for(var r=0;r<this.rows;r++){var n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=(0,s.checkRowVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=(0,s.checkRowVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=(0,s.checkRowVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=(0,s.checkRowVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=(0,s.checkColumnVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=(0,s.checkColumnVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=(0,s.checkColumnVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=(0,s.checkColumnVector)(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){(0,s.checkRowIndex)(this,t);for(var r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){(0,s.checkColumnIndex)(this,t);for(var r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(){for(var t=this.get(0,0),e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}maxIndex(){for(var t=this.get(0,0),e=[0,0],r=0;r<this.rows;r++)for(var n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(){for(var t=this.get(0,0),e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}minIndex(){for(var t=this.get(0,0),e=[0,0],r=0;r<this.rows;r++)for(var n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){(0,s.checkRowIndex)(this,t);for(var e=this.get(t,0),r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){(0,s.checkRowIndex)(this,t);for(var e=this.get(t,0),r=[t,0],n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){(0,s.checkRowIndex)(this,t);for(var e=this.get(t,0),r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){(0,s.checkRowIndex)(this,t);for(var e=this.get(t,0),r=[t,0],n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){(0,s.checkColumnIndex)(this,t);for(var e=this.get(0,t),r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){(0,s.checkColumnIndex)(this,t);for(var e=this.get(0,t),r=[0,t],n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){(0,s.checkColumnIndex)(this,t);for(var e=this.get(0,t),r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){(0,s.checkColumnIndex)(this,t);for(var e=this.get(0,t),r=[0,t],n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){for(var t=Math.min(this.rows,this.columns),e=new Array(t),r=0;r<t;r++)e[r]=this.get(r,r);return e}sum(t){switch(t){case"row":return(0,s.sumByRow)(this);case"column":return(0,s.sumByColumn)(this);default:return(0,s.sumAll)(this)}}mean(){return this.sum()/this.size}prod(){for(var t=1,e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t*=this.get(e,r);return t}norm(t="frobenius"){var e=0;if("max"===t)return this.max();if("frobenius"===t){for(var r=0;r<this.rows;r++)for(var n=0;n<this.columns;n++)e+=this.get(r,n)*this.get(r,n);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){for(var t=0,e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){e.isMatrix(t)&&(t=t.to1DArray());var r=this.to1DArray();if(r.length!==t.length)throw new RangeError("vectors do not have the same size");for(var n=0,i=0;i<r.length;i++)n+=r[i]*t[i];return n}mmul(t){t=this.constructor.checkMatrix(t),this.columns!==t.rows&&console.warn("Number of columns of left matrix are not equal to number of rows of right matrix.");for(var e=this.rows,r=this.columns,n=t.columns,i=new this.constructor[Symbol.species](e,n),o=new Array(r),s=0;s<n;s++){for(var a=0;a<r;a++)o[a]=t.get(a,s);for(var u=0;u<e;u++){var h=0;for(a=0;a<r;a++)h+=this.get(u,a)*o[a];i.set(u,s,h)}}return i}strassen2x2(t){var e=new this.constructor[Symbol.species](2,2),r=this.get(0,0),n=t.get(0,0),i=this.get(0,1),o=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),l=(r+u)*(n+h),c=(s+u)*n,f=r*(o-h),d=u*(a-n),m=(r+i)*h,g=(s-r)*(n+o),p=(i-u)*(a+h),v=l+d-m+p,w=f+m,y=c+d,x=l-c+f+g;return e.set(0,0,v),e.set(0,1,w),e.set(1,0,y),e.set(1,1,x),e}strassen3x3(t){var e=new this.constructor[Symbol.species](3,3),r=this.get(0,0),n=this.get(0,1),i=this.get(0,2),o=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=this.get(2,1),l=this.get(2,2),c=t.get(0,0),f=t.get(0,1),d=t.get(0,2),m=t.get(1,0),g=t.get(1,1),p=t.get(1,2),v=t.get(2,0),w=t.get(2,1),y=t.get(2,2),x=(r+n+i-o-s-h-l)*g,M=(r-o)*(-f+g),b=s*(-c+f+m-g-p-v+y),A=(-r+o+s)*(c-f+g),S=(o+s)*(-c+f),_=r*c,R=(-r+u+h)*(c-d+p),E=(-r+u)*(d-p),O=(u+h)*(-c+d),k=(r+n+i-s-a-u-h)*p,P=h*(-c+d+m-g-p-v+w),C=(-i+h+l)*(g+v-w),j=(i-l)*(g-w),T=i*v,N=(h+l)*(-v+w),V=(-i+s+a)*(p+v-y),D=(i-a)*(p-y),z=(s+a)*(-v+y),F=n*m,L=a*w,I=o*d,q=u*f,X=l*y,B=_+T+F,U=x+A+S+_+C+T+N,W=_+R+O+k+T+V+z,Y=M+b+A+_+T+V+D,$=M+A+S+_+L,J=T+V+D+z+I,G=_+R+E+P+C+j+T,K=C+j+T+N+q,Z=_+R+E+O+X;return e.set(0,0,B),e.set(0,1,U),e.set(0,2,W),e.set(1,0,Y),e.set(1,1,$),e.set(1,2,J),e.set(2,0,G),e.set(2,1,K),e.set(2,2,Z),e}mmulStrassen(t){var r=this.clone(),n=r.rows,i=r.columns,o=t.rows,s=t.columns;function a(t,r,n){var i=t.rows,o=t.columns;if(i===r&&o===n)return t;var s=e.zeros(r,n);return s=s.setSubMatrix(t,0,0)}i!==o&&console.warn(`Multiplying ${n} x ${i} and ${o} x ${s} matrix: dimensions do not match.`);var u=Math.max(n,o),h=Math.max(i,s);return r=a(r,u,h),t=a(t,u,h),function t(r,n,i,o){if(i<=512||o<=512)return r.mmul(n);i%2==1&&o%2==1?(r=a(r,i+1,o+1),n=a(n,i+1,o+1)):i%2==1?(r=a(r,i+1,o),n=a(n,i+1,o)):o%2==1&&(r=a(r,i,o+1),n=a(n,i,o+1));var s=parseInt(r.rows/2,10);var u=parseInt(r.columns/2,10);var h=r.subMatrix(0,s-1,0,u-1);var l=n.subMatrix(0,s-1,0,u-1);var c=r.subMatrix(0,s-1,u,r.columns-1);var f=n.subMatrix(0,s-1,u,n.columns-1);var d=r.subMatrix(s,r.rows-1,0,u-1);var m=n.subMatrix(s,n.rows-1,0,u-1);var g=r.subMatrix(s,r.rows-1,u,r.columns-1);var p=n.subMatrix(s,n.rows-1,u,n.columns-1);var v=t(e.add(h,g),e.add(l,p),s,u);var w=t(e.add(d,g),l,s,u);var y=t(h,e.sub(f,p),s,u);var x=t(g,e.sub(m,l),s,u);var M=t(e.add(h,c),p,s,u);var b=t(e.sub(d,h),e.add(l,f),s,u);var A=t(e.sub(c,g),e.add(m,p),s,u);var S=e.add(v,x);S.sub(M);S.add(A);var _=e.add(y,M);var R=e.add(w,x);var E=e.sub(v,w);E.add(y);E.add(b);var O=e.zeros(2*S.rows,2*S.columns);O=O.setSubMatrix(S,0,0);O=O.setSubMatrix(_,S.rows,0);O=O.setSubMatrix(R,0,S.columns);O=O.setSubMatrix(E,S.rows,S.columns);return O.subMatrix(0,i-1,0,o-1)}(r,t,u,h)}scaleRows(t,e){if((t=void 0===t?0:t)>=(e=void 0===e?1:e))throw new RangeError("min should be strictly smaller than max");for(var r=this.constructor.empty(this.rows,this.columns),i=0;i<this.rows;i++){var o=(0,n.default)(this.getRow(i),{min:t,max:e});r.setRow(i,o)}return r}scaleColumns(t,e){if((t=void 0===t?0:t)>=(e=void 0===e?1:e))throw new RangeError("min should be strictly smaller than max");for(var r=this.constructor.empty(this.rows,this.columns),i=0;i<this.columns;i++){var o=(0,n.default)(this.getColumn(i),{min:t,max:e});r.setColumn(i,o)}return r}kroneckerProduct(t){t=this.constructor.checkMatrix(t);for(var e=this.rows,r=this.columns,n=t.rows,i=t.columns,o=new this.constructor[Symbol.species](e*n,r*i),s=0;s<e;s++)for(var a=0;a<r;a++)for(var u=0;u<n;u++)for(var h=0;h<i;h++)o[n*s+u][i*a+h]=this.get(s,a)*t.get(u,h);return o}transpose(){for(var t=new this.constructor[Symbol.species](this.columns,this.rows),e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t){void 0===t&&(t=r);for(var e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t){void 0===t&&(t=r);for(var e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){(0,s.checkRange)(this,t,e,r,n);for(var i=new this.constructor[Symbol.species](e-t+1,n-r+1),o=t;o<=e;o++)for(var a=r;a<=n;a++)i[o-t][a-r]=this.get(o,a);return i}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");for(var n=new this.constructor[Symbol.species](t.length,r-e+1),i=0;i<t.length;i++)for(var o=e;o<=r;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,o-e,this.get(t[i],o))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");for(var n=new this.constructor[Symbol.species](r-e+1,t.length),i=0;i<t.length;i++)for(var o=e;o<=r;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(o-e,i,this.get(o,t[i]))}return n}setSubMatrix(t,e,r){t=this.constructor.checkMatrix(t);var n=e+t.rows-1,i=r+t.columns-1;(0,s.checkRange)(this,e,n,r,i);for(var o=0;o<t.rows;o++)for(var a=0;a<t.columns;a++)this[e+o][r+a]=t.get(o,a);return this}selection(t,e){for(var r=(0,s.checkIndices)(this,t,e),n=new this.constructor[Symbol.species](t.length,e.length),i=0;i<r.row.length;i++)for(var o=r.row[i],a=0;a<r.column.length;a++){var u=r.column[a];n[i][a]=this.get(o,u)}return n}trace(){for(var t=Math.min(this.rows,this.columns),e=0,r=0;r<t;r++)e+=this.get(r,r);return e}transposeView(){return new a.default(this)}rowView(t){return(0,s.checkRowIndex)(this,t),new u.default(this,t)}columnView(t){return(0,s.checkColumnIndex)(this,t),new d.default(this,t)}flipRowView(){return new m.default(this)}flipColumnView(){return new g.default(this)}subMatrixView(t,e,r,n){return new h.default(this,t,e,r,n)}selectionView(t,e){return new l.default(this,t,e)}rowSelectionView(t){return new c.default(this,t)}columnSelectionView(t){return new f.default(this,t)}det(){var t,e,r,n,o,s,a;if(this.isSquare())return 2===this.columns?(t=this.get(0,0),e=this.get(0,1),r=this.get(1,0),n=this.get(1,1),t*n-e*r):3===this.columns?(o=this.selectionView([1,2],[1,2]),s=this.selectionView([1,2],[0,2]),a=this.selectionView([1,2],[0,1]),t=this.get(0,0),e=this.get(0,1),r=this.get(0,2),t*o.det()-e*s.det()+r*a.det()):new i.default(this).determinant;throw Error("Determinant can only be calculated for a square matrix.")}pseudoInverse(t){void 0===t&&(t=Number.EPSILON);for(var e=new o.default(this,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,i=e.diagonal,s=0;s<i.length;s++)Math.abs(i[s])>t?i[s]=1/i[s]:i[s]=0;return i=this.constructor[Symbol.species].diag(i),n.mmul(i.mmul(r.transposeView()))}clone(){for(var t=new this.constructor[Symbol.species](this.rows,this.columns),e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}}function r(t,e){return t-e}e.prototype.klass="Matrix",e.random=e.rand,e.diagonal=e.diag,e.prototype.diagonal=e.prototype.diag,e.identity=e.eye,e.prototype.negate=e.prototype.neg,e.prototype.tensorProduct=e.prototype.kroneckerProduct,e.prototype.determinant=e.prototype.det;var p,v="\n(function %name%(matrix, %args%) {\n var newMatrix = new this[Symbol.species](matrix);\n return newMatrix.%name%(%args%);\n})\n",w=eval;for(var y of[["+","add"],["-","sub","subtract"],["*","mul","multiply"],["/","div","divide"],["%","mod","modulus"],["&","and"],["|","or"],["^","xor"],["<<","leftShift"],[">>","signPropagatingRightShift"],[">>>","rightShift","zeroFillRightShift"]]){var x=w(z("\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n",{name:y[1],op:y[0]})),M=w(z("\n(function %name%S(value) {\n for (var i = 0; i < this.rows; i++) {\n for (var j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) %op% value);\n }\n }\n return this;\n})\n",{name:`${y[1]}S`,op:y[0]})),b=w(z("\n(function %name%M(matrix) {\n matrix = this.constructor.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\n for (var i = 0; i < this.rows; i++) {\n for (var j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) %op% matrix.get(i, j));\n }\n }\n return this;\n})\n",{name:`${y[1]}M`,op:y[0]})),A=w(z("\n(function %name%(matrix, value) {\n var newMatrix = new this[Symbol.species](matrix);\n return newMatrix.%name%(value);\n})\n",{name:y[1]}));for(p=1;p<y.length;p++)e.prototype[y[p]]=x,e.prototype[`${y[p]}S`]=M,e.prototype[`${y[p]}M`]=b,e[y[p]]=A}var S=[["~","not"]];for(var _ of(["abs","acos","acosh","asin","asinh","atan","atanh","cbrt","ceil","clz32","cos","cosh","exp","expm1","floor","fround","log","log1p","log10","log2","round","sign","sin","sinh","sqrt","tan","tanh","trunc"].forEach(function(t){S.push([`Math.${t}`,t])}),S)){var R=w(z("\n(function %name%() {\n for (var i = 0; i < this.rows; i++) {\n for (var j = 0; j < this.columns; j++) {\n this.set(i, j, %method%(this.get(i, j)));\n }\n }\n return this;\n})\n",{name:_[1],method:_[0]})),E=w(z("\n(function %name%(matrix) {\n var newMatrix = new this[Symbol.species](matrix);\n return newMatrix.%name%();\n})\n",{name:_[1]}));for(p=1;p<_.length;p++)e.prototype[_[p]]=R,e[_[p]]=E}for(var O of[["Math.pow",1,"pow"]]){var k="arg0";for(p=1;p<O[1];p++)k+=`, arg${p}`;if(1!==O[1]){var P=w(z("\n(function %name%(%args%) {\n for (var i = 0; i < this.rows; i++) {\n for (var j = 0; j < this.columns; j++) {\n this.set(i, j, %method%(this.get(i, j), %args%));\n }\n }\n return this;\n})\n",{name:O[2],method:O[0],args:k})),C=w(z(v,{name:O[2],args:k}));for(p=2;p<O.length;p++)e.prototype[O[p]]=P,e[O[p]]=C}else{var j={name:O[2],args:k,method:O[0]},T=w(z("\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n",j)),N=w(z("\n(function %name%S(value) {\n for (var i = 0; i < this.rows; i++) {\n for (var j = 0; j < this.columns; j++) {\n this.set(i, j, %method%(this.get(i, j), value));\n }\n }\n return this;\n})\n",j)),V=w(z("\n(function %name%M(matrix) {\n matrix = this.constructor.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\n for (var i = 0; i < this.rows; i++) {\n for (var j = 0; j < this.columns; j++) {\n this.set(i, j, %method%(this.get(i, j), matrix.get(i, j)));\n }\n }\n return this;\n})\n",j)),D=w(z("\n(function %name%(matrix, %args%) {\n var newMatrix = new this[Symbol.species](matrix);\n return newMatrix.%name%(%args%);\n})\n",j));for(p=2;p<O.length;p++)e.prototype[O[p]]=T,e.prototype[`${O[p]}M`]=V,e.prototype[`${O[p]}S`]=N,e[O[p]]=D}}function z(t,e){for(var r in e)t=t.replace(new RegExp(`%${r}%`,"g"),e[r]);return t}return e};var n=p(r(55)),i=p(r(10)),o=p(r(8)),s=r(6),a=p(r(57)),u=p(r(58)),h=p(r(59)),l=p(r(60)),c=p(r(61)),f=p(r(62)),d=p(r(63)),m=p(r(64)),g=p(r(65));function p(t){return t&&t.__esModule?t:{default:t}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(11);e.default=class{constructor(t,e={}){var r,o=(t=n.WrapperMatrix2D.checkMatrix(t)).rows,s=t.columns,a=e.computeLeftSingularVectors,u=void 0===a||a,h=e.computeRightSingularVectors,l=void 0===h||h,c=e.autoTranspose,f=void 0!==c&&c,d=Boolean(u),m=Boolean(l),g=!1;if(o<s)if(f){o=(r=t.transpose()).rows,s=r.columns,g=!0;var p=d;d=m,m=p}else r=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else r=t.clone();for(var v=Math.min(o,s),w=Math.min(o+1,s),y=new Array(w),x=(0,i.getFilled2DArray)(o,v,0),M=(0,i.getFilled2DArray)(s,s,0),b=new Array(s),A=new Array(o),S=new Array(w),_=0;_<w;_++)S[_]=_;for(var R=Math.min(o-1,s),E=Math.max(0,Math.min(s-2,o)),O=Math.max(R,E),k=0;k<O;k++){if(k<R){y[k]=0;for(var P=k;P<o;P++)y[k]=(0,i.hypotenuse)(y[k],r[P][k]);if(0!==y[k]){r[k][k]<0&&(y[k]=-y[k]);for(var C=k;C<o;C++)r[C][k]/=y[k];r[k][k]+=1}y[k]=-y[k]}for(var j=k+1;j<s;j++){if(k<R&&0!==y[k]){for(var T=0,N=k;N<o;N++)T+=r[N][k]*r[N][j];T=-T/r[k][k];for(var V=k;V<o;V++)r[V][j]+=T*r[V][k]}b[j]=r[k][j]}if(d&&k<R)for(var D=k;D<o;D++)x[D][k]=r[D][k];if(k<E){b[k]=0;for(var z=k+1;z<s;z++)b[k]=(0,i.hypotenuse)(b[k],b[z]);if(0!==b[k]){b[k+1]<0&&(b[k]=0-b[k]);for(var F=k+1;F<s;F++)b[F]/=b[k];b[k+1]+=1}if(b[k]=-b[k],k+1<o&&0!==b[k]){for(var L=k+1;L<o;L++)A[L]=0;for(var I=k+1;I<o;I++)for(var q=k+1;q<s;q++)A[I]+=b[q]*r[I][q];for(var X=k+1;X<s;X++)for(var B=-b[X]/b[k+1],U=k+1;U<o;U++)r[U][X]+=B*A[U]}if(m)for(var W=k+1;W<s;W++)M[W][k]=b[W]}}var Y=Math.min(s,o+1);if(R<s&&(y[R]=r[R][R]),o<Y&&(y[Y-1]=0),E+1<Y&&(b[E]=r[E][Y-1]),b[Y-1]=0,d){for(var $=R;$<v;$++){for(var J=0;J<o;J++)x[J][$]=0;x[$][$]=1}for(var G=R-1;G>=0;G--)if(0!==y[G]){for(var K=G+1;K<v;K++){for(var Z=0,H=G;H<o;H++)Z+=x[H][G]*x[H][K];Z=-Z/x[G][G];for(var Q=G;Q<o;Q++)x[Q][K]+=Z*x[Q][G]}for(var tt=G;tt<o;tt++)x[tt][G]=-x[tt][G];x[G][G]=1+x[G][G];for(var et=0;et<G-1;et++)x[et][G]=0}else{for(var rt=0;rt<o;rt++)x[rt][G]=0;x[G][G]=1}}if(m)for(var nt=s-1;nt>=0;nt--){if(nt<E&&0!==b[nt])for(var it=nt+1;it<s;it++){for(var ot=0,st=nt+1;st<s;st++)ot+=M[st][nt]*M[st][it];ot=-ot/M[nt+1][nt];for(var at=nt+1;at<s;at++)M[at][it]+=ot*M[at][nt]}for(var ut=0;ut<s;ut++)M[ut][nt]=0;M[nt][nt]=1}for(var ht=Y-1,lt=Number.EPSILON;Y>0;){var ct=void 0,ft=void 0;for(ct=Y-2;ct>=-1&&-1!==ct;ct--){var dt=Number.MIN_VALUE+lt*Math.abs(y[ct]+Math.abs(y[ct+1]));if(Math.abs(b[ct])<=dt||Number.isNaN(b[ct])){b[ct]=0;break}}if(ct===Y-2)ft=4;else{var mt=void 0;for(mt=Y-1;mt>=ct&&mt!==ct;mt--){var gt=(mt!==Y?Math.abs(b[mt]):0)+(mt!==ct+1?Math.abs(b[mt-1]):0);if(Math.abs(y[mt])<=lt*gt){y[mt]=0;break}}mt===ct?ft=3:mt===Y-1?ft=1:(ft=2,ct=mt)}switch(ct++,ft){case 1:var pt=b[Y-2];b[Y-2]=0;for(var vt=Y-2;vt>=ct;vt--){var wt=(0,i.hypotenuse)(y[vt],pt),yt=y[vt]/wt,xt=pt/wt;if(y[vt]=wt,vt!==ct&&(pt=-xt*b[vt-1],b[vt-1]=yt*b[vt-1]),m)for(var Mt=0;Mt<s;Mt++)wt=yt*M[Mt][vt]+xt*M[Mt][Y-1],M[Mt][Y-1]=-xt*M[Mt][vt]+yt*M[Mt][Y-1],M[Mt][vt]=wt}break;case 2:var bt=b[ct-1];b[ct-1]=0;for(var At=ct;At<Y;At++){var St=(0,i.hypotenuse)(y[At],bt),_t=y[At]/St,Rt=bt/St;if(y[At]=St,bt=-Rt*b[At],b[At]=_t*b[At],d)for(var Et=0;Et<o;Et++)St=_t*x[Et][At]+Rt*x[Et][ct-1],x[Et][ct-1]=-Rt*x[Et][At]+_t*x[Et][ct-1],x[Et][At]=St}break;case 3:var Ot=Math.max(Math.abs(y[Y-1]),Math.abs(y[Y-2]),Math.abs(b[Y-2]),Math.abs(y[ct]),Math.abs(b[ct])),kt=y[Y-1]/Ot,Pt=y[Y-2]/Ot,Ct=b[Y-2]/Ot,jt=y[ct]/Ot,Tt=b[ct]/Ot,Nt=((Pt+kt)*(Pt-kt)+Ct*Ct)/2,Vt=kt*Ct*(kt*Ct),Dt=0;0===Nt&&0===Vt||(Dt=Vt/(Nt+(Dt=Nt<0?0-Math.sqrt(Nt*Nt+Vt):Math.sqrt(Nt*Nt+Vt))));for(var zt=(jt+kt)*(jt-kt)+Dt,Ft=jt*Tt,Lt=ct;Lt<Y-1;Lt++){var It=(0,i.hypotenuse)(zt,Ft);0===It&&(It=Number.MIN_VALUE);var qt=zt/It,Xt=Ft/It;if(Lt!==ct&&(b[Lt-1]=It),zt=qt*y[Lt]+Xt*b[Lt],b[Lt]=qt*b[Lt]-Xt*y[Lt],Ft=Xt*y[Lt+1],y[Lt+1]=qt*y[Lt+1],m)for(var Bt=0;Bt<s;Bt++)It=qt*M[Bt][Lt]+Xt*M[Bt][Lt+1],M[Bt][Lt+1]=-Xt*M[Bt][Lt]+qt*M[Bt][Lt+1],M[Bt][Lt]=It;if(0===(It=(0,i.hypotenuse)(zt,Ft))&&(It=Number.MIN_VALUE),qt=zt/It,Xt=Ft/It,y[Lt]=It,zt=qt*b[Lt]+Xt*y[Lt+1],y[Lt+1]=-Xt*b[Lt]+qt*y[Lt+1],Ft=Xt*b[Lt+1],b[Lt+1]=qt*b[Lt+1],d&&Lt<o-1)for(var Ut=0;Ut<o;Ut++)It=qt*x[Ut][Lt]+Xt*x[Ut][Lt+1],x[Ut][Lt+1]=-Xt*x[Ut][Lt]+qt*x[Ut][Lt+1],x[Ut][Lt]=It}b[Y-2]=zt;break;case 4:if(y[ct]<=0&&(y[ct]=y[ct]<0?-y[ct]:0,m))for(var Wt=0;Wt<=ht;Wt++)M[Wt][ct]=-M[Wt][ct];for(;ct<ht&&!(y[ct]>=y[ct+1]);){var Yt=y[ct];if(y[ct]=y[ct+1],y[ct+1]=Yt,m&&ct<s-1)for(var $t=0;$t<s;$t++)Yt=M[$t][ct+1],M[$t][ct+1]=M[$t][ct],M[$t][ct]=Yt;if(d&&ct<o-1)for(var Jt=0;Jt<o;Jt++)Yt=x[Jt][ct+1],x[Jt][ct+1]=x[Jt][ct],x[Jt][ct]=Yt;ct++}Y--}}if(g){var Gt=M;M=x,x=Gt}this.m=o,this.n=s,this.s=y,this.U=x,this.V=M}solve(t){for(var e=t,r=this.threshold,i=this.s.length,o=n.Matrix.zeros(i,i),s=0;s<i;s++)Math.abs(this.s[s])<=r?o[s][s]=0:o[s][s]=1/this.s[s];for(var a=this.U,u=this.rightSingularVectors,h=u.mmul(o),l=u.rows,c=a.length,f=n.Matrix.zeros(l,c),d=0;d<l;d++)for(var m=0;m<c;m++){for(var g=0,p=0;p<i;p++)g+=h[d][p]*a[m][p];f[d][m]=g}return f.mmul(e)}solveForDiagonal(t){return this.solve(n.Matrix.diag(t))}inverse(){for(var t=this.V,e=this.threshold,r=t.length,i=t[0].length,o=new n.Matrix(r,this.s.length),s=0;s<r;s++)for(var a=0;a<i;a++)Math.abs(this.s[a])>e?o[s][a]=t[s][a]/this.s[a]:o[s][a]=0;for(var u=this.U,h=u.length,l=u[0].length,c=new n.Matrix(r,h),f=0;f<r;f++)for(var d=0;d<h;d++){for(var m=0,g=0;g<l;g++)m+=o[f][g]*u[d][g];c[f][d]=m}return c}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){for(var t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s,n=0,i=r.length;n<i;n++)r[n]>t&&e++;return e}get diagonal(){return this.s}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return n.Matrix.isMatrix(this.U)||(this.U=new n.Matrix(this.U)),this.U}get rightSingularVectors(){return n.Matrix.isMatrix(this.V)||(this.V=new n.Matrix(this.V)),this.V}get diagonalMatrix(){return n.Matrix.diag(this.s)}}},function(t,e,r){"use strict";var n=r(24);function i(t,e){return t-e}e.max=function(t){for(var e=-1/0,r=0;r<t.length;r++)for(var n=0;n<t[r].length;n++)t[r][n]>e&&(e=t[r][n]);return e},e.min=function(t){for(var e=1/0,r=0;r<t.length;r++)for(var n=0;n<t[r].length;n++)t[r][n]<e&&(e=t[r][n]);return e},e.minMax=function(t){for(var e=1/0,r=-1/0,n=0;n<t.length;n++)for(var i=0;i<t[n].length;i++)t[n][i]<e&&(e=t[n][i]),t[n][i]>r&&(r=t[n][i]);return{min:e,max:r}},e.entropy=function(t,e){void 0===e&&(e=0);for(var r=0,n=t.length,i=t[0].length,o=0;o<n;o++)for(var s=0;s<i;s++)r+=t[o][s]*Math.log(t[o][s]+e);return-r},e.mean=function(t,e){void 0===e&&(e=0);var r,n,i,o,s=t.length,a=t[0].length;if(-1===e){for(r=[0],n=s*a,i=0;i<s;i++)for(o=0;o<a;o++)r[0]+=t[i][o];r[0]/=n}else if(0===e)for(r=new Array(a),n=s,o=0;o<a;o++){for(r[o]=0,i=0;i<s;i++)r[o]+=t[i][o];r[o]/=n}else{if(1!==e)throw new Error("Invalid dimension");for(r=new Array(s),n=a,o=0;o<s;o++){for(r[o]=0,i=0;i<a;i++)r[o]+=t[o][i];r[o]/=n}}return r},e.sum=function(t,e){void 0===e&&(e=0);var r,n,i,o=t.length,s=t[0].length;if(-1===e)for(r=[0],n=0;n<o;n++)for(i=0;i<s;i++)r[0]+=t[n][i];else if(0===e)for(r=new Array(s),i=0;i<s;i++)for(r[i]=0,n=0;n<o;n++)r[i]+=t[n][i];else{if(1!==e)throw new Error("Invalid dimension");for(r=new Array(o),i=0;i<o;i++)for(r[i]=0,n=0;n<s;n++)r[i]+=t[i][n]}return r},e.product=function(t,e){void 0===e&&(e=0);var r,n,i,o=t.length,s=t[0].length;if(-1===e)for(r=[1],n=0;n<o;n++)for(i=0;i<s;i++)r[0]*=t[n][i];else if(0===e)for(r=new Array(s),i=0;i<s;i++)for(r[i]=1,n=0;n<o;n++)r[i]*=t[n][i];else{if(1!==e)throw new Error("Invalid dimension");for(r=new Array(o),i=0;i<o;i++)for(r[i]=1,n=0;n<s;n++)r[i]*=t[i][n]}return r},e.standardDeviation=function(t,r,n){for(var i=e.variance(t,r,n),o=i.length,s=0;s<o;s++)i[s]=Math.sqrt(i[s]);return i},e.variance=function(t,r,n){void 0===n&&(n=!0),r=r||e.mean(t);var i=t.length;if(0===i)return[];for(var o=t[0].length,s=new Array(o),a=0;a<o;a++){for(var u=0,h=0,l=0,c=0;c<i;c++)u+=l=t[c][a]-r[a],h+=l*l;s[a]=n?(h-u*u/i)/(i-1):(h-u*u/i)/i}return s},e.median=function(t){for(var e=t.length,r=t[0].length,n=new Array(r),o=0;o<r;o++){for(var s=new Array(e),a=0;a<e;a++)s[a]=t[a][o];s.sort(i);var u=s.length;n[o]=u%2==0?.5*(s[u/2]+s[u/2-1]):s[Math.floor(u/2)]}return n},e.mode=function(t){var e,r,n=t.length,i=t[0].length,o=new Array(i);for(e=0;e<i;e++){for(var s=new Array(n),a=0;a<n;a++)s[a]=0;var u=new Array(n),h=0;for(r=0;r<n;r++){var l=u.indexOf(t[r][e]);l>=0?s[l]++:(u[h]=t[r][e],s[h]=1,h++)}var c=0,f=0;for(r=0;r<h;r++)s[r]>c&&(c=s[r],f=r);o[e]=u[f]}return o},e.skewness=function(t,r){void 0===r&&(r=!0);for(var n=e.mean(t),i=t.length,o=n.length,s=new Array(o),a=0;a<o;a++){for(var u=0,h=0,l=0;l<i;l++){var c=t[l][a]-n[a];u+=c*c,h+=c*c*c}var f=u/i,d=h/i/Math.pow(f,1.5);if(r){var m=Math.sqrt(i*(i-1)),g=i-2;s[a]=m/g*d}else s[a]=d}return s},e.kurtosis=function(t,r){void 0===r&&(r=!0);for(var n=e.mean(t),i=t.length,o=t[0].length,s=new Array(o),a=0;a<o;a++){for(var u=0,h=0,l=0;l<i;l++){var c=t[l][a]-n[a];u+=c*c,h+=c*c*c*c}var f=u/i,d=h/i;if(r){var m=u/(i-1),g=i*(i+1)/((i-1)*(i-2)*(i-3)),p=h/(m*m),v=(i-1)*(i-1)/((i-2)*(i-3));s[a]=g*p-3*v}else s[a]=d/(f*f)-3}return s},e.standardError=function(t){for(var r=t.length,n=e.standardDeviation(t),i=n.length,o=new Array(i),s=Math.sqrt(r),a=0;a<i;a++)o[a]=n[a]/s;return o},e.covariance=function(t,r){return e.scatter(t,void 0,r)},e.scatter=function(t,r,n){void 0===n&&(n=0),void 0===r&&(0===n?r=t.length-1:1===n&&(r=t[0].length-1));var i=e.mean(t,n),o=t.length;if(0===o)return[[]];var s,a,u,h,l,c=t[0].length;if(0===n){for(s=new Array(c),a=0;a<c;a++)s[a]=new Array(c);for(a=0;a<c;a++)for(u=a;u<c;u++){for(h=0,l=0;l<o;l++)h+=(t[l][u]-i[u])*(t[l][a]-i[a]);h/=r,s[a][u]=h,s[u][a]=h}}else{if(1!==n)throw new Error("Invalid dimension");for(s=new Array(o),a=0;a<o;a++)s[a]=new Array(o);for(a=0;a<o;a++)for(u=a;u<o;u++){for(h=0,l=0;l<c;l++)h+=(t[u][l]-i[u])*(t[a][l]-i[a]);h/=r,s[a][u]=h,s[u][a]=h}}return s},e.correlation=function(t){var r,n,i=e.mean(t),o=e.standardDeviation(t,!0,i),s=e.zScores(t,i,o),a=t.length,u=t[0].length,h=new Array(u);for(r=0;r<u;r++)h[r]=new Array(u);for(r=0;r<u;r++)for(n=r;n<u;n++){for(var l=0,c=0,f=s.length;c<f;c++)l+=s[c][n]*s[c][r];l/=a-1,h[r][n]=l,h[n][r]=l}return h},e.zScores=function(t,r,n){return r=r||e.mean(t),void 0===n&&(n=e.standardDeviation(t,!0,r)),e.standardize(e.center(t,r,!1),n,!0)},e.center=function(t,r,n){r=r||e.mean(t);var i,o,s,a=t,u=t.length;if(!n)for(a=new Array(u),i=0;i<u;i++)a[i]=new Array(t[i].length);for(i=0;i<u;i++){var h=a[i];for(o=0,s=h.length;o<s;o++)h[o]=t[i][o]-r[o]}return a},e.standardize=function(t,r,n){void 0===r&&(r=e.standardDeviation(t));var i,o,s,a=t,u=t.length;if(!n)for(a=new Array(u),i=0;i<u;i++)a[i]=new Array(t[i].length);for(i=0;i<u;i++){var h=a[i],l=t[i];for(o=0,s=h.length;o<s;o++)0===r[o]||isNaN(r[o])||(h[o]=l[o]/r[o])}return a},e.weightedVariance=function(t,r){var n=e.mean(t),i=t.length;if(0===i)return[];for(var o=t[0].length,s=new Array(o),a=0;a<o;a++){for(var u=0,h=0,l=0,c=0;c<i;c++){var f=t[c][a]-n[a],d=r[c];u+=d*(f*f),l+=d,h+=d*d}s[a]=u*(l/(l*l-h))}return s},e.weightedMean=function(t,e,r){void 0===r&&(r=0);var i=t.length;if(0===i)return[];var o,s,a,u,h,l,c=t[0].length;if(0===r){for(o=new Array(c),s=0;s<c;s++)o[s]=0;for(s=0;s<i;s++)for(l=t[s],h=e[s],u=0;u<c;u++)o[u]+=l[u]*h}else{if(1!==r)throw new Error("Invalid dimension");for(o=new Array(i),s=0;s<i;s++)o[s]=0;for(u=0;u<i;u++)for(l=t[u],h=e[u],s=0;s<c;s++)o[u]+=l[s]*h}var f=n.sum(e);if(0!==f)for(s=0,a=o.length;s<a;s++)o[s]/=f;return o},e.weightedCovariance=function(t,r,n,i){i=i||0,n=n||e.weightedMean(t,r,i);for(var o=0,s=0,a=0,u=r.length;a<u;a++)o+=r[a],s+=r[a]*r[a];var h=o/(o*o-s);return e.weightedScatter(t,r,n,h,i)},e.weightedScatter=function(t,r,n,i,o){o=o||0,n=n||e.weightedMean(t,r,o),void 0===i&&(i=1);var s=t.length;if(0===s)return[[]];var a,u,h,l,c,f=t[0].length;if(0===o){for(a=new Array(f),u=0;u<f;u++)a[u]=new Array(f);for(u=0;u<f;u++)for(h=u;h<f;h++){for(c=0,l=0;l<s;l++)c+=r[l]*(t[l][h]-n[h])*(t[l][u]-n[u]);a[u][h]=c*i,a[h][u]=c*i}}else{if(1!==o)throw new Error("Invalid dimension");for(a=new Array(s),u=0;u<s;u++)a[u]=new Array(s);for(u=0;u<s;u++)for(h=u;h<s;h++){for(c=0,l=0;l<f;l++)c+=r[l]*(t[h][l]-n[h])*(t[u][l]-n[u]);a[u][h]=c*i,a[h][u]=c*i}}return a}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0);e.default=class{constructor(t){var e,r,i,o,s,a,u,h,l,c=(t=n.WrapperMatrix2D.checkMatrix(t)).clone(),f=c.rows,d=c.columns,m=new Array(f),g=1;for(e=0;e<f;e++)m[e]=e;for(h=new Array(f),r=0;r<d;r++){for(e=0;e<f;e++)h[e]=c.get(e,r);for(e=0;e<f;e++){for(l=Math.min(e,r),s=0,i=0;i<l;i++)s+=c.get(e,i)*h[i];h[e]-=s,c.set(e,r,h[e])}for(o=r,e=r+1;e<f;e++)Math.abs(h[e])>Math.abs(h[o])&&(o=e);if(o!==r){for(i=0;i<d;i++)a=c.get(o,i),c.set(o,i,c.get(r,i)),c.set(r,i,a);u=m[o],m[o]=m[r],m[r]=u,g=-g}if(r<f&&0!==c.get(r,r))for(e=r+1;e<f;e++)c.set(e,r,c.get(e,r)/c.get(r,r))}this.LU=c,this.pivotVector=m,this.pivotSign=g}isSingular(){for(var t=this.LU,e=t.columns,r=0;r<e;r++)if(0===t[r][r])return!0;return!1}solve(t){t=n.Matrix.checkMatrix(t);var e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");var r,i,o,s=t.columns,a=t.subMatrixRow(this.pivotVector,0,s-1),u=e.columns;for(o=0;o<u;o++)for(r=o+1;r<u;r++)for(i=0;i<s;i++)a[r][i]-=a[o][i]*e[r][o];for(o=u-1;o>=0;o--){for(i=0;i<s;i++)a[o][i]/=e[o][o];for(r=0;r<o;r++)for(i=0;i<s;i++)a[r][i]-=a[o][i]*e[r][o]}return a}get determinant(){var t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");for(var e=this.pivotSign,r=t.columns,n=0;n<r;n++)e*=t[n][n];return e}get lowerTriangularMatrix(){for(var t=this.LU,e=t.rows,r=t.columns,i=new n.Matrix(e,r),o=0;o<e;o++)for(var s=0;s<r;s++)i[o][s]=o>s?t[o][s]:o===s?1:0;return i}get upperTriangularMatrix(){for(var t=this.LU,e=t.rows,r=t.columns,i=new n.Matrix(e,r),o=0;o<e;o++)for(var s=0;s<r;s++)i[o][s]=o<=s?t[o][s]:0;return i}get pivotPermutationVector(){return this.pivotVector.slice()}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hypotenuse=function(t,e){var r=0;if(Math.abs(t)>Math.abs(e))return r=e/t,Math.abs(t)*Math.sqrt(1+r*r);if(0!==e)return r=t/e,Math.abs(e)*Math.sqrt(1+r*r);return 0},e.getFilled2DArray=function(t,e,r){for(var n=new Array(t),i=0;i<t;i++){n[i]=new Array(e);for(var o=0;o<e;o++)n[i][o]=r}return n}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){if(!Array.isArray(t))throw new Error("input must be an array");if(0===t.length)throw new Error("input must not be empty");for(var e=0,r=0;r<t.length;r++)e+=t[r];return e/t.length}},function(t,e,r){"use strict";var n=r(83);function i(){this.children=[],this.distance=-1,this.index=[]}i.prototype.cut=function(t){if(t<0)throw new RangeError("Threshold too small");var e=new i;e.children=this.children,e.distance=this.distance,e.index=this.index;for(var r=[e],n=[];r.length>0;){var o=r.shift();t>=o.distance?n.push(o):r=r.concat(o.children)}return n},i.prototype.group=function(t){if(!Number.isInteger(t)||t<1)throw new RangeError("Number of groups must be a positive integer");var e=new n(function(t,e){return e.distance-t.distance});for(e.push(this);e.size()<t;){var r=e.pop();if(0===r.children.length)break;r.children.forEach(t=>e.push(t))}var o=new i;return o.children=e.toArray(),o.distance=this.distance,o},i.prototype.traverse=function(t){!function t(e,r){if(r(e),e.children)for(var n=e.children.length-1;n>=0;n--)t(e.children[n],r)}(this,t)},t.exports=i},function(t,e,r){"use strict";var n=r(0).Matrix,i=r(97),o=r(98),s=r(99),a=r(100),u=r(101),h=r(102),l=r(103),c=r(104),f=r(105),d=r(106),m={gaussian:i,rbf:i,polynomial:o,poly:o,anova:s,cauchy:a,exponential:u,histogram:h,min:h,laplacian:l,multiquadratic:c,rational:f,sigmoid:d,mlp:d};t.exports=class{constructor(t,e){if(this.kernelType=t,"linear"!==t)if("string"==typeof t){t=t.toLowerCase();var r=m[t];if(!r)throw new Error("unsupported kernel type: "+t);this.kernelFunction=new r(e)}else{if("object"!=typeof t||"function"!=typeof t.compute)throw new TypeError("first argument must be a valid kernel type or instance");this.kernelFunction=t}}compute(t,e){if(void 0===e&&(e=t),"linear"===this.kernelType)return new n(t).mmul(new n(e).transposeView());var r,i,o=new n(t.length,e.length);if(t===e)for(r=0;r<t.length;r++)for(i=r;i<t.length;i++)o[r][i]=o[i][r]=this.kernelFunction.compute(t[r],t[i]);else for(r=0;r<t.length;r++)for(i=0;i<e.length;i++)o[r][i]=this.kernelFunction.compute(t[r],e[i]);return o}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=function(t){return t&&t.__esModule?t:{default:t}}(n);class o extends i.default{constructor(t,e){super(),!0===t?(this.slope=e.slope,this.intercept=e.intercept,this.coefficients=[e.intercept,e.slope]):((0,n.checkArrayLength)(t,e),function(t,e,r){for(var n=e.length,i=0,o=0,s=0,a=0,u=0;u<n;u++)i+=e[u],o+=r[u],s+=e[u]*e[u],a+=e[u]*r[u];var h=n*a-i*o;t.slope=h/(n*s-i*i),t.intercept=1/n*o-t.slope*(1/n)*i,t.coefficients=[t.intercept,t.slope]}(this,t,e))}toJSON(){return{name:"simpleLinearRegression",slope:this.slope,intercept:this.intercept}}_predict(t){return this.slope*t+this.intercept}computeX(t){return(t-this.intercept)/this.slope}toString(t){var e="f(x) = ";if(0!==this.slope){var r=(0,n.maybeToPrecision)(this.slope,t);if(e+=("1"===r?"":r+" * ")+"x",this.intercept){var i=Math.abs(this.intercept);e+=` ${i===this.intercept?"+":"-"} ${(0,n.maybeToPrecision)(i,t)}`}}else e+=(0,n.maybeToPrecision)(this.intercept,t);return e}toLaTeX(t){return this.toString(t)}static load(t){if("simpleLinearRegression"!==t.name)throw new TypeError("not a SLR model");return new o(!0,t)}}e.default=o},function(t,e,r){"use strict";var n=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===i.call(t)},u=function(t){if(!t||"[object Object]"!==i.call(t))return!1;var e,r=n.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&n.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!o)return!1;for(e in t);return void 0===e||n.call(t,e)},h=function(t,e){o&&"__proto__"===e.name?o(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},l=function(t,e){if("__proto__"===e){if(!n.call(t,e))return;if(s)return s(t,e).value}return t[e]};t.exports=function t(){var e,r,n,i,o,s,c=arguments[0],f=1,d=arguments.length,m=!1;for("boolean"==typeof c&&(m=c,c=arguments[1]||{},f=2),(null==c||"object"!=typeof c&&"function"!=typeof c)&&(c={});f<d;++f)if(null!=(e=arguments[f]))for(r in e)n=l(c,r),c!==(i=l(e,r))&&(m&&i&&(u(i)||(o=a(i)))?(o?(o=!1,s=n&&a(n)?n:[]):s=n&&u(n)?n:{},h(c,{name:r,newValue:t(m,s,i)})):void 0!==i&&h(c,{name:r,newValue:i}));return c}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(54);Object.defineProperty(e,"DecisionTreeClassifier",{enumerable:!0,get:function(){return n.DecisionTreeClassifier}});var i=r(72);Object.defineProperty(e,"DecisionTreeRegression",{enumerable:!0,get:function(){return i.DecisionTreeRegression}})},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){if(!Array.isArray(t))throw new Error("input must be an array");if(0===t.length)throw new Error("input must not be empty");for(var e=t[0],r=1;r<t.length;r++)t[r]>e&&(e=t[r]);return e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(r(7)),i=o(r(5));function o(t){return t&&t.__esModule?t:{default:t}}e.default=class extends((0,n.default)()){constructor(t,e={}){var r=e.rows,n=void 0===r?1:r;if(t.length%n!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,r){var n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){var r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}static get[Symbol.species](){return i.default}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(r(7)),i=o(r(5));function o(t){return t&&t.__esModule?t:{default:t}}e.default=class extends((0,n.default)()){constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}static get[Symbol.species](){return i.default}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(11);e.default=class{constructor(t){var e,r,o,s,a=(t=n.WrapperMatrix2D.checkMatrix(t)).clone(),u=t.rows,h=t.columns,l=new Array(h);for(o=0;o<h;o++){var c=0;for(e=o;e<u;e++)c=(0,i.hypotenuse)(c,a.get(e,o));if(0!==c){for(a.get(o,o)<0&&(c=-c),e=o;e<u;e++)a.set(e,o,a.get(e,o)/c);for(a.set(o,o,a.get(o,o)+1),r=o+1;r<h;r++){for(s=0,e=o;e<u;e++)s+=a.get(e,o)*a.get(e,r);for(s=-s/a.get(o,o),e=o;e<u;e++)a.set(e,r,a.get(e,r)+s*a.get(e,o))}}l[o]=-c}this.QR=a,this.Rdiag=l}solve(t){t=n.Matrix.checkMatrix(t);var e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");var i,o,s,a,u=t.columns,h=t.clone(),l=e.columns;for(s=0;s<l;s++)for(o=0;o<u;o++){for(a=0,i=s;i<r;i++)a+=e[i][s]*h[i][o];for(a=-a/e[s][s],i=s;i<r;i++)h[i][o]+=a*e[i][s]}for(s=l-1;s>=0;s--){for(o=0;o<u;o++)h[s][o]/=this.Rdiag[s];for(i=0;i<s;i++)for(o=0;o<u;o++)h[i][o]-=h[s][o]*e[i][s]}return h.subMatrix(0,l-1,0,u-1)}isFullRank(){for(var t=this.QR.columns,e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){var t,e,r=this.QR,i=r.columns,o=new n.Matrix(i,i);for(t=0;t<i;t++)for(e=0;e<i;e++)o[t][e]=t<e?r[t][e]:t===e?this.Rdiag[t]:0;return o}get orthogonalMatrix(){var t,e,r,i,o=this.QR,s=o.rows,a=o.columns,u=new n.Matrix(s,a);for(r=a-1;r>=0;r--){for(t=0;t<s;t++)u[t][r]=0;for(u[r][r]=1,e=r;e<a;e++)if(0!==o[r][r]){for(i=0,t=r;t<s;t++)i+=o[t][r]*u[t][e];for(i=-i/o[r][r],t=r;t<s;t++)u[t][e]+=i*o[t][r]}}return u}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=s(r(0)),i=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(r(71)),o=s(r(12));function s(t){return t&&t.__esModule?t:{default:t}}var a={gini:i.giniGain,regression:i.regressionError},u={mean:i.mean};class h{constructor(t){this.kind=t.kind,this.gainFunction=t.gainFunction,this.splitFunction=t.splitFunction,this.minNumSamples=t.minNumSamples,this.maxDepth=t.maxDepth}bestSplit(t,e){for(var r,n,i="classifier"===this.kind?-1/0:1/0,o="classifier"===this.kind?(t,e)=>t>e:(t,e)=>t<e,s=0;s<t.rows;++s)for(var u=t[s],h=this.featureSplit(u,e),l=0;l<h.length;++l){var c=h[l],f=this.split(u,e,c),d=a[this.gainFunction](e,f);o(d,i)&&(r=s,n=c,i=d)}return{maxGain:i,maxColumn:r,maxValue:n}}split(t,e,r){for(var n=[],i=[],o=0;o<t.length;++o)t[o]<r?n.push(e[o]):i.push(e[o]);return{greater:i,lesser:n}}featureSplit(t,e){var r=[],n=i.zip(t,e);n.sort(function(t,e){return t[0]-e[0]});for(var o=1;o<n.length;++o)n[o-1][1]!==n[o][1]&&r.push(u[this.splitFunction](n[o-1][0],n[o][0]));return r}calculatePrediction(t){if("classifier"===this.kind){if(this.distribution=i.toDiscreteDistribution(t,i.getNumberOfClasses(t)),0===this.distribution.columns)throw new TypeError("Error on calculate the prediction")}else this.distribution=(0,o.default)(t)}train(t,e,r,o){if(t.rows<=this.minNumSamples)this.calculatePrediction(e);else{void 0===o&&(o=0);var s=t.transpose(),a=this.bestSplit(s,e);this.splitValue=a.maxValue,this.splitColumn=a.maxColumn,this.gain=a.maxGain;var u=i.matrixSplitter(t,e,this.splitColumn,this.splitValue);if(r<this.maxDepth&&this.gain>.01&&this.gain!==o&&u.lesserX.length>0&&u.greaterX.length>0){this.left=new h(this),this.right=new h(this);var l=new n.default(u.lesserX),c=new n.default(u.greaterX);this.left.train(l,u.lesserY,r+1,this.gain),this.right.train(c,u.greaterY,r+1,this.gain)}else this.calculatePrediction(e)}}classify(t){return this.right&&this.left?t[this.splitColumn]<this.splitValue?this.left.classify(t):this.right.classify(t):this.distribution}setNodeParameters(t){void 0!==t.distribution?this.distribution=t.distribution.constructor===Array?new n.default(t.distribution):t.distribution:(this.distribution=void 0,this.splitValue=t.splitValue,this.splitColumn=t.splitColumn,this.gain=t.gain,this.left=new h(this),this.right=new h(this),t.left!=={}&&this.left.setNodeParameters(t.left),t.right!=={}&&this.right.setNodeParameters(t.right))}}e.default=h},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RandomForestBase=void 0;var n=r(17),i=r(0),o=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(r(75));e.RandomForestBase=class{constructor(t,e){if(!0===t){this.replacement=e.replacement,this.maxFeatures=e.maxFeatures,this.nEstimators=e.nEstimators,this.treeOptions=e.treeOptions,this.isClassifier=e.isClassifier,this.seed=e.seed,this.n=e.n,this.indexes=e.indexes,this.useSampleBagging=e.useSampleBagging;var r=this.isClassifier?n.DecisionTreeClassifier:n.DecisionTreeRegression;this.estimators=e.estimators.map(t=>r.load(t))}else this.replacement=t.replacement,this.maxFeatures=t.maxFeatures,this.nEstimators=t.nEstimators,this.treeOptions=t.treeOptions,this.isClassifier=t.isClassifier,this.seed=t.seed,this.useSampleBagging=t.useSampleBagging}train(t,e){if(t=i.Matrix.checkMatrix(t),this.maxFeatures=this.maxFeatures||t.columns,o.checkFloat(this.maxFeatures))this.n=Math.floor(t.columns*this.maxFeatures);else{if(!Number.isInteger(this.maxFeatures))throw new RangeError(`Cannot process the maxFeatures parameter ${this.maxFeatures}`);if(this.maxFeatures>t.columns)throw new RangeError(`The maxFeatures parameter should be less than ${t.columns}`);this.n=this.maxFeatures}if(this.isClassifier)var r=n.DecisionTreeClassifier;else r=n.DecisionTreeRegression;this.estimators=new Array(this.nEstimators),this.indexes=new Array(this.nEstimators);for(var s=0;s<this.nEstimators;++s){var a=this.useSampleBagging?o.examplesBaggingWithReplacement(t,e,this.seed):{X:t,y:e},u=a.X,h=a.y;u=(a=o.featureBagging(u,this.n,this.replacement,this.seed)).X,this.indexes[s]=a.usedIndex,this.estimators[s]=new r(this.treeOptions),this.estimators[s].train(u,h)}}selection(t){throw new Error("Abstract method 'selection' not implemented!")}predict(t){var e=new Array(this.nEstimators);t=i.Matrix.checkMatrix(t);for(var r=0;r<this.nEstimators;++r){var n=t.columnSelectionView(this.indexes[r]);e[r]=this.estimators[r].predict(n)}e=new i.WrapperMatrix2D(e).transposeView();var o=new Array(e.rows);for(r=0;r<e.rows;++r)o[r]=this.selection(e.getRow(r));return o}toJSON(){return{indexes:this.indexes,n:this.n,replacement:this.replacement,maxFeatures:this.maxFeatures,nEstimators:this.nEstimators,treeOptions:this.treeOptions,isClassifier:this.isClassifier,seed:this.seed,estimators:this.estimators.map(t=>t.toJSON()),useSampleBagging:this.useSampleBagging}}}},function(t,e,r){"use strict";function n(t,e){return t-e}e.sum=function(t){for(var e=0,r=0;r<t.length;r++)e+=t[r];return e},e.max=function(t){for(var e=t[0],r=t.length,n=1;n<r;n++)t[n]>e&&(e=t[n]);return e},e.min=function(t){for(var e=t[0],r=t.length,n=1;n<r;n++)t[n]<e&&(e=t[n]);return e},e.minMax=function(t){for(var e=t[0],r=t[0],n=t.length,i=1;i<n;i++)t[i]<e&&(e=t[i]),t[i]>r&&(r=t[i]);return{min:e,max:r}},e.arithmeticMean=function(t){for(var e=0,r=t.length,n=0;n<r;n++)e+=t[n];return e/r},e.mean=e.arithmeticMean,e.geometricMean=function(t){for(var e=1,r=t.length,n=0;n<r;n++)e*=t[n];return Math.pow(e,1/r)},e.logMean=function(t){for(var e=0,r=t.length,n=0;n<r;n++)e+=Math.log(t[n]);return e/r},e.grandMean=function(t,e){for(var r=0,n=0,i=t.length,o=0;o<i;o++)r+=e[o]*t[o],n+=e[o];return r/n},e.truncatedMean=function(t,e,r){void 0===r&&(r=!1),r||(t=[].concat(t).sort(n));for(var i=t.length,o=Math.floor(i*e),s=0,a=o;a<i-o;a++)s+=t[a];return s/(i-2*o)},e.harmonicMean=function(t){for(var e=0,r=t.length,n=0;n<r;n++){if(0===t[n])throw new RangeError("value at index "+n+"is zero");e+=1/t[n]}return r/e},e.contraHarmonicMean=function(t){for(var e=0,r=0,n=t.length,i=0;i<n;i++)e+=t[i]*t[i],r+=t[i];if(r<0)throw new RangeError("sum of values is negative");return e/r},e.median=function(t,e){void 0===e&&(e=!1),e||(t=[].concat(t).sort(n));var r=t.length,i=Math.floor(r/2);return r%2==0?.5*(t[i-1]+t[i]):t[i]},e.variance=function(t,r){void 0===r&&(r=!0);for(var n=e.mean(t),i=0,o=t.length,s=0;s<o;s++){var a=t[s]-n;i+=a*a}return r?i/(o-1):i/o},e.standardDeviation=function(t,r){return Math.sqrt(e.variance(t,r))},e.standardError=function(t){return e.standardDeviation(t)/Math.sqrt(t.length)},e.robustMeanAndStdev=function(t){var e=0,r=t.length,i=0;for(i=0;i<r;i++)e+=t[i];e/=r;var o=new Array(r);for(i=0;i<r;i++)o[i]=Math.abs(t[i]-e);return o.sort(n),{mean:e,stdev:r%2==1?o[(r-1)/2]/.6745:.5*(o[r/2]+o[r/2-1])/.6745}},e.quartiles=function(t,r){void 0===r&&(r=!1),r||(t=[].concat(t).sort(n));var i=t.length/4;return{q1:t[Math.ceil(i)-1],q2:e.median(t,!0),q3:t[Math.ceil(3*i)-1]}},e.pooledStandardDeviation=function(t,r){return Math.sqrt(e.pooledVariance(t,r))},e.pooledVariance=function(t,r){void 0===r&&(r=!0);for(var n=0,i=0,o=t.length,s=0;s<o;s++){var a=t[s],u=e.variance(a);n+=(a.length-1)*u,i+=r?a.length-1:a.length}return n/i},e.mode=function(t){var e,r=t.length,n=new Array(r);for(e=0;e<r;e++)n[e]=0;var i=new Array(r),o=0;for(e=0;e<r;e++){var s=i.indexOf(t[e]);s>=0?n[s]++:(i[o]=t[e],n[o]=1,o++)}var a=0,u=0;for(e=0;e<o;e++)n[e]>a&&(a=n[e],u=e);return i[u]},e.covariance=function(t,r,n){void 0===n&&(n=!0);var i=e.mean(t),o=e.mean(r);if(t.length!==r.length)throw"Vectors do not have the same dimensions";for(var s=0,a=t.length,u=0;u<a;u++){s+=(t[u]-i)*(r[u]-o)}return n?s/(a-1):s/a},e.skewness=function(t,r){void 0===r&&(r=!0);for(var n=e.mean(t),i=0,o=0,s=t.length,a=0;a<s;a++){var u=t[a]-n;i+=u*u,o+=u*u*u}var h=i/s,l=o/s/Math.pow(h,1.5);return r?Math.sqrt(s*(s-1))/(s-2)*l:l},e.kurtosis=function(t,r){void 0===r&&(r=!0);for(var n=e.mean(t),i=t.length,o=0,s=0,a=0;a<i;a++){var u=t[a]-n;o+=u*u,s+=u*u*u*u}var h=o/i,l=s/i;if(r){var c=o/(i-1);return i*(i+1)/((i-1)*(i-2)*(i-3))*(s/(c*c))-3*((i-1)*(i-1)/((i-2)*(i-3)))}return l/(h*h)-3},e.entropy=function(t,e){void 0===e&&(e=0);for(var r=0,n=t.length,i=0;i<n;i++)r+=t[i]*Math.log(t[i]+e);return-r},e.weightedMean=function(t,e){for(var r=0,n=t.length,i=0;i<n;i++)r+=t[i]*e[i];return r},e.weightedStandardDeviation=function(t,r){return Math.sqrt(e.weightedVariance(t,r))},e.weightedVariance=function(t,r){for(var n=e.weightedMean(t,r),i=0,o=t.length,s=0,a=0,u=0;u<o;u++){var h=t[u]-n,l=r[u];i+=l*(h*h),a+=l,s+=l*l}return i*(a/(a*a-s))},e.center=function(t,r){void 0===r&&(r=!1);var n=t;r||(n=[].concat(t));for(var i=e.mean(n),o=n.length,s=0;s<o;s++)n[s]-=i},e.standardize=function(t,r,n){void 0===r&&(r=e.standardDeviation(t)),void 0===n&&(n=!1);for(var i=t.length,o=n?t:new Array(i),s=0;s<i;s++)o[s]=t[s]/r;return o},e.cumulativeSum=function(t){var e=t.length,r=new Array(e);r[0]=t[0];for(var n=1;n<e;n++)r[n]=r[n-1]+t[n];return r}},function(t,e,r){"use strict";var n=r(13);function i(t){n.call(this),this.index=t,this.distance=0,this.children=[]}r(85).inherits(i,n),t.exports=i},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=Array.from({length:r}).map(()=>Array.from({length:r})),i=0;i<r;i++)for(var o=0;o<=i;o++)n[i][o]=e(t[i],t[o]);for(var s=0;s<r;s++)for(var a=s+1;a<r;a++)n[s][a]=n[a][s];return n}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.calculateDistanceMatrix=function(t,e){for(var r=new Array(t.length),n=0;n<t.length;++n)for(var i=n;i<t.length;++i){r[n]||(r[n]=new Array(t.length)),r[i]||(r[i]=new Array(t.length));var o=e(t[n],t[i]);r[n][i]=o,r[i][n]=o}return r},e.updateClusterID=function(t,e,r,i){for(var o=0;o<t.length;o++)r[o]=(0,n.default)(e,t[o],{distanceFunction:i});return r},e.updateCenters=function(t,e,r,n){for(var i=e[0].length,o=new Array(n),s=new Array(n),a=0;a<n;a++){o[a]=new Array(i),s[a]=0;for(var u=0;u<i;u++)o[a][u]=0}for(var h=0;h<e.length;h++){s[r[h]]++;for(var l=0;l<i;l++)o[r[h]][l]+=e[h][l]}for(var c=0;c<n;c++)for(var f=0;f<i;f++)s[c]?o[c][f]/=s[c]:o[c][f]=t[c][f];return o},e.hasConverged=function(t,e,r,n){for(var i=0;i<t.length;i++)if(r(t[i],e[i])>n)return!1;return!0};var n=function(t){return t&&t.__esModule?t:{default:t}}(r(92))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(r(94));var i=r(29);e.default=class{constructor(t=Math.random){if("number"==typeof t){var e=new i(t);this.randomGenerator=e.random}else this.randomGenerator=t}choice(t,e){return(0,n.default)(t,e,this.randomGenerator)}random(){return this.randomGenerator()}randInt(t,e){return void 0===e&&(e=t,t=0),t+Math.floor(this.randomGenerator()*(e-t))}randomSample(t){for(var e=[],r=0;r<t;r++)e.push(this.random());return e}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();function i(t,e){var r=65535&(t>>>=0);return((t-r)*(e>>>=0)>>>0)+r*e>>>0}var o=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?Date.now():arguments[0];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.state=new Uint32Array(4),this.init(e)}return n(t,[{key:"init",value:function(t){this.state[0]=t,this.state[1]=0,this.state[2]=0,this.state[3]=0;for(var e=1;e<8;e++)this.state[3&e]^=e+i(1812433253,this.state[e-1&3]^this.state[e-1&3]>>>30>>>0)>>>0;!function(t){0===t.state[0]&&0===t.state[1]&&0===t.state[2]&&0===t.state[3]&&(t.state[0]=88,t.state[1]=83,t.state[2]=65,t.state[3]=68)}(this);for(e=0;e<8;e++)h(this)}},{key:"getUint32",value:function(){return h(this),this.state[3]+this.state[2]>>>0}},{key:"getFloat",value:function(){return(this.getUint32()>>>8)*(1/16777216)}},{key:"random",get:function(){return this._random||(this._random=this.getFloat.bind(this)),this._random}}]),t}();e.default=o;var s=15,a=18,u=11;function h(t){var e=t.state[0];e^=e<<s,e^=e>>>a,e^=t.state[3]<<u,t.state[0]=t.state[1],t.state[1]=t.state[2],t.state[2]=t.state[3],t.state[3]=e}t.exports=e.default},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.separateClasses=function(t,e){for(var r=t.columns,i=0,o=new Array(1e4),s=0;s<e.length;s++)void 0===o[e[s]]&&(o[e[s]]=0,i++),o[e[s]]++;var a=new Array(i),u=new Array(i);for(s=0;s<i;++s)a[s]=new n.default(o[s],r),u[s]=0;for(s=0;s<t.rows;++s)a[e[s]].setRow(u[e[s]],t.getRow(s)),u[e[s]]++;return a};var n=function(t){return t&&t.__esModule?t:{default:t}}(r(0))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.norm=function(t){return Math.sqrt(t.clone().apply(s).sum())},e.pow2array=s,e.featureNormalize=function(t){var e=i.default.mean(t),r=i.default.standardDeviation(t,e,!0);return{result:n.default.checkMatrix(t).subRowVector(e).divRowVector(r),means:e,std:r}},e.initializeMatrices=function(t,e){if(e)for(var r=0;r<t.length;++r)for(var i=0;i<t[r].length;++i){var o=t[r][i];t[r][i]=null!==o?new n.default(t[r][i]):void 0}else for(r=0;r<t.length;++r)t[r]=new n.default(t[r]);return t};var n=o(r(0)),i=o(r(9));function o(t){return t&&t.__esModule?t:{default:t}}function s(t,e){return this[t][e]=this[t][e]*this[t][e],this}},function(t,e,r){"use strict";class n{constructor(t,e){if(t.length!==t[0].length)throw new Error("Confusion matrix must be square");if(e.length!==t.length)throw new Error("Confusion matrix and labels should have the same length");this.labels=e,this.matrix=t}static fromLabels(t,e,r={}){if(e.length!==t.length)throw new Error("predicted and actual must have the same length");var i=void 0;i=r.labels?new Set(r.labels):new Set([...t,...e]),i=Array.from(i),r.sort&&i.sort(r.sort);for(var o=Array.from({length:i.length}),s=0;s<o.length;s++)o[s]=new Array(o.length),o[s].fill(0);for(var a=0;a<e.length;a++){var u=i.indexOf(t[a]),h=i.indexOf(e[a]);u>=0&&h>=0&&o[u][h]++}return new n(o,i)}getMatrix(){return this.matrix}getLabels(){return this.labels}getTotalCount(){for(var t=0,e=0;e<this.matrix.length;e++)for(var r=0;r<this.matrix.length;r++)t+=this.matrix[e][r];return t}getTrueCount(){for(var t=0,e=0;e<this.matrix.length;e++)t+=this.matrix[e][e];return t}getFalseCount(){return this.getTotalCount()-this.getTrueCount()}getTruePositiveCount(t){var e=this.getIndex(t);return this.matrix[e][e]}getTrueNegativeCount(t){for(var e=this.getIndex(t),r=0,n=0;n<this.matrix.length;n++)for(var i=0;i<this.matrix.length;i++)n!==e&&i!==e&&(r+=this.matrix[n][i]);return r}getFalsePositiveCount(t){for(var e=this.getIndex(t),r=0,n=0;n<this.matrix.length;n++)n!==e&&(r+=this.matrix[n][e]);return r}getFalseNegativeCount(t){for(var e=this.getIndex(t),r=0,n=0;n<this.matrix.length;n++)n!==e&&(r+=this.matrix[e][n]);return r}getPositiveCount(t){return this.getTruePositiveCount(t)+this.getFalseNegativeCount(t)}getNegativeCount(t){return this.getTrueNegativeCount(t)+this.getFalsePositiveCount(t)}getIndex(t){var e=this.labels.indexOf(t);if(-1===e)throw new Error("The label does not exist");return e}getTruePositiveRate(t){return this.getTruePositiveCount(t)/this.getPositiveCount(t)}getTrueNegativeRate(t){return this.getTrueNegativeCount(t)/this.getNegativeCount(t)}getPositivePredictiveValue(t){var e=this.getTruePositiveCount(t);return e/(e+this.getFalsePositiveCount(t))}getNegativePredictiveValue(t){var e=this.getTrueNegativeCount(t);return e/(e+this.getFalseNegativeCount(t))}getFalseNegativeRate(t){return 1-this.getTruePositiveRate(t)}getFalsePositiveRate(t){return 1-this.getTrueNegativeRate(t)}getFalseDiscoveryRate(t){var e=this.getFalsePositiveCount(t);return e/(e+this.getTruePositiveCount(t))}getFalseOmissionRate(t){var e=this.getFalseNegativeCount(t);return e/(e+this.getTruePositiveCount(t))}getF1Score(t){var e=this.getTruePositiveCount(t);return 2*e/(2*e+this.getFalsePositiveCount(t)+this.getFalseNegativeCount(t))}getMatthewsCorrelationCoefficient(t){var e=this.getTruePositiveCount(t),r=this.getTrueNegativeCount(t),n=this.getFalsePositiveCount(t),i=this.getFalseNegativeCount(t);return(e*r-n*i)/Math.sqrt((e+n)*(e+i)*(r+n)*(r+i))}getInformedness(t){return this.getTruePositiveRate(t)+this.getTrueNegativeRate(t)-1}getMarkedness(t){return this.getPositivePredictiveValue(t)+this.getNegativePredictiveValue(t)-1}getConfusionTable(t){return[[this.getTruePositiveCount(t),this.getFalseNegativeCount(t)],[this.getFalsePositiveCount(t),this.getTrueNegativeCount(t)]]}getAccuracy(){for(var t=0,e=0,r=0;r<this.matrix.length;r++)for(var n=0;n<this.matrix.length;n++)r===n?t+=this.matrix[r][n]:e+=this.matrix[r][n];return t/(t+e)}getCount(t,e){var r=this.getIndex(t),n=this.getIndex(e);return this.matrix[r][n]}get accuracy(){return this.getAccuracy()}get total(){return this.getTotalCount()}}t.exports=n},function(t,e,r){"use strict";var n=r(0).Matrix,i=r(34),o=r(35);class s{constructor(t){this.inputSize=t.inputSize,this.outputSize=t.outputSize,this.regularization=t.regularization,this.epsilon=t.epsilon,this.activation=t.activation,this.activationParam=t.activationParam;var e=o[t.activation],r=e.activation.length,i=r>1?r=>e.activation(r,t.activationParam):e.activation,s=r>1?r=>e.derivate(r,t.activationParam):e.derivate;this.activationFunction=function(t,e){this[t][e]=i(this[t][e])},this.derivate=function(t,e){this[t][e]=s(this[t][e])},t.model?(this.W=n.checkMatrix(t.W),this.b=n.checkMatrix(t.b)):(this.W=n.rand(this.inputSize,this.outputSize),this.b=n.zeros(1,this.outputSize),this.W.apply(function(e,r){this[e][r]/=Math.sqrt(t.inputSize)}))}forward(t){var e=t.mmul(this.W).addRowVector(this.b);return e.apply(this.activationFunction),this.a=e.clone(),e}backpropagation(t,e){this.dW=e.transposeView().mmul(t),this.db=i.sumCol(t);var r=e.clone();return t.mmul(this.W.transposeView()).mul(r.apply(this.derivate))}update(){this.dW.add(this.W.clone().mul(this.regularization)),this.W.add(this.dW.mul(-this.epsilon)),this.b.add(this.db.mul(-this.epsilon))}toJSON(){return{model:"Layer",inputSize:this.inputSize,outputSize:this.outputSize,regularization:this.regularization,epsilon:this.epsilon,activation:this.activation,W:this.W,b:this.b}}static load(t){if("Layer"!==t.model)throw new RangeError("the current model is not a Layer model");return new s(t)}}t.exports=s},function(t,e,r){"use strict";var n=r(0).Matrix;t.exports={dictOutputs:function(t){for(var e={},r={},n=0,i=0;i<t.length;i+=1)void 0===e[t[i]]&&(e[t[i]]=n,r[n]=t[i],n++);return{inputs:e,outputs:r}},sumCol:function(t){for(var e=n.zeros(1,t.columns),r=0;r<t.rows;++r)for(var i=0;i<t.columns;++i)e[0][i]+=t[r][i];return e},sumRow:function(t){for(var e=n.zeros(t.rows,1),r=0;r<t.rows;++r)for(var i=0;i<t.columns;++i)e[r][0]+=t[r][i];return e}}},function(t,e,r){"use strict";function n(t){return 1/(1+Math.exp(-t))}function i(t,e){return t<0?e*(Math.exp(t)-1):t}var o={tanh:{activation:Math.tanh,derivate:t=>1-t*t},identity:{activation:t=>t,derivate:()=>1},logistic:{activation:n,derivate:t=>n(t)*(1-n(t))},arctan:{activation:Math.atan,derivate:t=>1/(t*t+1)},softsign:{activation:t=>t/(1+Math.abs(t)),derivate:t=>1/((1+Math.abs(t))*(1+Math.abs(t)))},relu:{activation:t=>t<0?0:t,derivate:t=>t<0?0:1},softplus:{activation:t=>Math.log(1+Math.exp(t)),derivate:t=>1/(1+Math.exp(-t))},bent:{activation:t=>(Math.sqrt(t*t+1)-1)/2+t,derivate:t=>t/(2*Math.sqrt(t*t+1))+1},sinusoid:{activation:Math.sin,derivate:Math.cos},sinc:{activation:t=>0===t?1:Math.sin(t)/t,derivate:t=>0===t?0:Math.cos(t)/t-Math.sin(t)/(t*t)},gaussian:{activation:t=>Math.exp(-t*t),derivate:t=>-2*t*Math.exp(-t*t)},"parametric-relu":{activation:(t,e)=>t<0?e*t:t,derivate:(t,e)=>t<0?e:1},"exponential-elu":{activation:i,derivate:(t,e)=>t<0?i(t,e)+e:1},"soft-exponential":{activation:function(t,e){return e<0?-Math.log(1-e*(t+e))/e:e>0?(Math.exp(e*t)-1)/e+e:t},derivate:function(t,e){return e<0?1/(1-e*(e+t)):Math.exp(e*t)}}};t.exports=o},function(t,e,r){"use strict";function n(t,e,r,n){this.x=t,this.y=e,this.weights=r,this.som=n,this.neighbors={}}n.prototype.adjustWeights=function(t,e,r){for(var n=0,i=this.weights.length;n<i;n++)this.weights[n]+=e*r*(t[n]-this.weights[n])},n.prototype.getDistance=function(t){return Math.max(Math.abs(this.x-t.x),Math.abs(this.y-t.y))},n.prototype.getDistanceTorus=function(t){var e=Math.abs(this.x-t.x),r=Math.abs(this.y-t.y);return Math.max(Math.min(e,this.som.gridDim.x-e),Math.min(r,this.som.gridDim.y-r))},n.prototype.getNeighbors=function(t){if(!this.neighbors[t]){var e,r,n,i;if(this.neighbors[t]=new Array(2),this[t]>0?e=this[t]-1:this.som.torus&&(e=this.som.gridDim[t]-1),void 0!==e)"x"===t?(r=e,n=this.y):(r=this.x,n=e),this.neighbors[t][0]=this.som.nodes[r][n];this[t]<this.som.gridDim[t]-1?i=this[t]+1:this.som.torus&&(i=0),void 0!==i&&("x"===t?(r=i,n=this.y):(r=this.x,n=i),this.neighbors[t][1]=this.som.nodes[r][n])}return this.neighbors[t]},n.prototype.getPos=function(t,e){var r,n,i=this.getNeighbors(t),o=this.som.distance;i[0]?i[1]?o(e,i[0].weights)<o(e,i[1].weights)?(r=i[0],n=-1):(r=i[1],n=1):(r=i[0],n=-1):(r=i[1],n=1);var s=1-o(e,this.weights),a=1-o(e,r.weights);return.5+.5*((s-a)/(2-s-a))*n},n.prototype.getPosition=function(t){return[this.getPos("x",t),this.getPos("y",t)]},t.exports=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RobustPolynomialRegression=e.TheilSenRegression=e.PolinomialFitting2D=e.KRR=e.KernelRidgeRegression=e.NonLinearRegression=e.NLR=e.MultivariateLinearRegression=e.PowerRegression=e.ExponentialRegression=e.PolynomialRegression=e.SLR=e.SimpleLinearRegression=void 0;var n=r(15);Object.defineProperty(e,"SimpleLinearRegression",{enumerable:!0,get:function(){return f(n).default}}),Object.defineProperty(e,"SLR",{enumerable:!0,get:function(){return f(n).default}});var i=r(38);Object.defineProperty(e,"PolynomialRegression",{enumerable:!0,get:function(){return f(i).default}});var o=r(123);Object.defineProperty(e,"ExponentialRegression",{enumerable:!0,get:function(){return f(o).default}});var s=r(124);Object.defineProperty(e,"PowerRegression",{enumerable:!0,get:function(){return f(s).default}});var a=r(125);Object.defineProperty(e,"MultivariateLinearRegression",{enumerable:!0,get:function(){return f(a).default}});var u=r(126);Object.defineProperty(e,"KernelRidgeRegression",{enumerable:!0,get:function(){return f(u).default}}),Object.defineProperty(e,"KRR",{enumerable:!0,get:function(){return f(u).default}});var h=r(127);Object.defineProperty(e,"PolinomialFitting2D",{enumerable:!0,get:function(){return f(h).default}});var l=r(128);Object.defineProperty(e,"TheilSenRegression",{enumerable:!0,get:function(){return f(l).default}});var c=r(129);function f(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"RobustPolynomialRegression",{enumerable:!0,get:function(){return f(c).default}});var d={PotentialRegression:f(r(130)).default};e.NLR=d,e.NonLinearRegression=d},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=a(n),o=r(0),s=a(o);function a(t){return t&&t.__esModule?t:{default:t}}class u extends i.default{constructor(t,e,r){super(),!0===t?(this.degree=e.degree,this.powers=e.powers,this.coefficients=e.coefficients):((0,n.checkArrayLength)(t,e),function(t,e,r,n){var i=e.length,a=void 0;if(Array.isArray(n))n=(a=n).length;else{n++,a=new Array(n);for(var u=0;u<n;u++)a[u]=u}for(var h=new s.default(i,n),l=new s.default([r]),c=0;c<n;c++)for(var f=0;f<i;f++)0===a[c]?h[f][c]=1:h[f][c]=Math.pow(e[f],a[c]);var d=h.transposeView(),m=d.mmul(h),g=d.mmul(l.transposeView());t.degree=n-1,t.powers=a,t.coefficients=(0,o.solve)(m,g).to1DArray()}(this,t,e,r))}_predict(t){for(var e=0,r=0;r<this.powers.length;r++)e+=this.coefficients[r]*Math.pow(t,this.powers[r]);return e}toJSON(){return{name:"polynomialRegression",degree:this.degree,powers:this.powers,coefficients:this.coefficients}}toString(t){return this._toFormula(t,!1)}toLaTeX(t){return this._toFormula(t,!0)}_toFormula(t,e){var r="^",i="",o=" * ";e&&(r="^{",i="}",o="");for(var s="",a="",u=0;u<this.coefficients.length;u++)a="",0!==this.coefficients[u]&&(a=0===this.powers[u]?(0,n.maybeToPrecision)(this.coefficients[u],t):1===this.powers[u]?(0,n.maybeToPrecision)(this.coefficients[u],t)+o+"x":(0,n.maybeToPrecision)(this.coefficients[u],t)+o+"x"+r+this.powers[u]+i,this.coefficients[u]>0&&u!==this.coefficients.length-1?a=" + "+a:u!==this.coefficients.length-1&&(a=" "+a)),s=a+s;return"+"===s.charAt(0)&&(s=s.slice(1)),"f(x) = "+s}static load(t){if("polynomialRegression"!==t.name)throw new TypeError("not a polynomial regression model");return new u(!0,t)}}e.default=u},function(t,e,r){"use strict";var n=r(133),i=r(134),o=i.nextPrime,s=i.largestPrime,a=0,u=1,h=2,l=150,c=1/6,f=2/3;class d{constructor(t={}){if(t instanceof d)return this.table=t.table.slice(),this.values=t.values.slice(),this.state=t.state.slice(),this.minLoadFactor=t.minLoadFactor,this.maxLoadFactor=t.maxLoadFactor,this.distinct=t.distinct,this.freeEntries=t.freeEntries,this.lowWaterMark=t.lowWaterMark,void(this.highWaterMark=t.maxLoadFactor);var e=void 0===t.initialCapacity?l:t.initialCapacity;if(e<0)throw new RangeError(`initial capacity must not be less than zero: ${e}`);var r=void 0===t.minLoadFactor?c:t.minLoadFactor,i=void 0===t.maxLoadFactor?f:t.maxLoadFactor;if(r<0||r>=1)throw new RangeError(`invalid minLoadFactor: ${r}`);if(i<=0||i>=1)throw new RangeError(`invalid maxLoadFactor: ${i}`);if(r>=i)throw new RangeError(`minLoadFactor (${r}) must be smaller than maxLoadFactor (${i})`);var a=e;0===(a=o(a=a/i|0))&&(a=1),this.table=n(a,0),this.values=n(a,0),this.state=n(a,0),this.minLoadFactor=r,this.maxLoadFactor=a===s?1:i,this.distinct=0,this.freeEntries=a,this.lowWaterMark=0,this.highWaterMark=m(a,this.maxLoadFactor)}clone(){return new d(this)}get size(){return this.distinct}get(t){var e=this.indexOfKey(t);return e<0?0:this.values[e]}set(t,e){var r=this.indexOfInsertion(t);if(r<0)return r=-r-1,this.values[r]=e,!1;if(this.distinct>this.highWaterMark){var n=g(this.distinct+1,this.minLoadFactor,this.maxLoadFactor);return this.rehash(n),this.set(t,e)}if(this.table[r]=t,this.values[r]=e,this.state[r]===a&&this.freeEntries--,this.state[r]=u,this.distinct++,this.freeEntries<1){var i=g(this.distinct+1,this.minLoadFactor,this.maxLoadFactor);this.rehash(i)}return!0}remove(t,e){var r=this.indexOfKey(t);return!(r<0)&&(this.state[r]=h,this.distinct--,e||this.maybeShrinkCapacity(),!0)}delete(t,e){var r=this.indexOfKey(t);return!(r<0)&&(this.state[r]=a,this.distinct--,e||this.maybeShrinkCapacity(),!0)}maybeShrinkCapacity(){if(this.distinct<this.lowWaterMark){var t=function(t,e,r){return o(Math.max(t+1,4*t/(e+3*r)|0))}(this.distinct,this.minLoadFactor,this.maxLoadFactor);this.rehash(t)}}containsKey(t){return this.indexOfKey(t)>=0}indexOfKey(t){var e=this.table,r=this.state,n=this.table.length,i=2147483647&t,o=i%n,s=i%(n-2);for(0===s&&(s=1);r[o]!==a&&(r[o]===h||e[o]!==t);)(o-=s)<0&&(o+=n);return r[o]===a?-1:o}containsValue(t){return this.indexOfValue(t)>=0}indexOfValue(t){for(var e=this.values,r=this.state,n=0;n<r.length;n++)if(r[n]===u&&e[n]===t)return n;return-1}indexOfInsertion(t){var e=this.table,r=this.state,n=e.length,i=2147483647&t,o=i%n,s=i%(n-2);for(0===s&&(s=1);r[o]===u&&e[o]!==t;)(o-=s)<0&&(o+=n);if(r[o]===h){for(var l=o;r[o]!==a&&(r[o]===h||e[o]!==t);)(o-=s)<0&&(o+=n);r[o]===a&&(o=l)}return r[o]===u?-o-1:o}ensureCapacity(t){if(this.table.length<t){var e=o(t);this.rehash(e)}}rehash(t){var e=this.table.length;if(t<=this.distinct)throw new Error("Unexpected");var r=this.table,i=this.values,o=this.state,s=n(t,0),a=n(t,0),h=n(t,0);this.lowWaterMark=function(t,e){return t*e|0}(t,this.minLoadFactor),this.highWaterMark=m(t,this.maxLoadFactor),this.table=s,this.values=a,this.state=h,this.freeEntries=t-this.distinct;for(var l=0;l<e;l++)if(o[l]===u){var c=r[l],f=this.indexOfInsertion(c);s[f]=c,a[f]=i[l],h[f]=u}}forEachKey(t){for(var e=0;e<this.state.length;e++)if(this.state[e]===u&&!t(this.table[e]))return!1;return!0}forEachValue(t){for(var e=0;e<this.state.length;e++)if(this.state[e]===u&&!t(this.values[e]))return!1;return!0}forEachPair(t){for(var e=0;e<this.state.length;e++)if(this.state[e]===u&&!t(this.table[e],this.values[e]))return!1;return!0}}function m(t,e){return Math.min(t-2,t*e|0)}function g(t,e,r){return o(Math.max(t+1,4*t/(3*e+r)|0))}t.exports=d},function(t,e,r){"use strict";t.exports=function(t,e,r,n,i){var o,s;if(void 0===n)n=0;else if((n|=0)<0||n>=t.length)throw new RangeError("invalid lower bound");if(void 0===i)i=t.length-1;else if((i|=0)<n||i>=t.length)throw new RangeError("invalid upper bound");for(;n<=i;)if((s=+r(t[o=n+(i-n>>1)],e,o,t))<0)n=o+1;else{if(!(s>0))return o;i=o-1}return~n}},function(t,e,r){"use strict";var n=r(135);function i(t){if("number"!=typeof t||n(t))throw new TypeError("Expected a number")}e.asc=function(t,e){return i(t),i(e),t-e},e.desc=function(t,e){return i(t),i(e),e-t}},function(t,e,r){"use strict";e.distance=r(136),e.similarity=r(173)},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=0,i=0;i<t.length;i++)r+=Math.min(t[i],e[i]),n+=t[i]+e[i];return 2*r/n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0,s=0;s<r;s++)n+=t[s]*t[s],i+=e[s]*e[s],o+=(t[s]-e[s])*(t[s]-e[s]);return o/(n+i)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.min(t[i],e[i]);return 1-n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0,s=0,a=0;a<r;a++)n+=t[a]*e[a],i+=t[a]*t[a],o+=e[a]*e[a],s+=(t[a]-e[a])*(t[a]-e[a]);return s/(i+o-n)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0;o<r;o++)n+=Math.abs(t[o]-e[o]),i+=Math.min(t[o],e[o]);return n/i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0;o<r;o++)n+=Math.min(t[o],e[o]),i+=t[o]+e[o];return 1-n/i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=(Math.sqrt(t[i])-Math.sqrt(e[i]))*(Math.sqrt(t[i])-Math.sqrt(e[i]));return n}},function(t,e,r){"use strict";t.exports=function(t,e,r){if(r){for(var n=0,i=0,o=0;o<t.length;o++)n+=t[o]&&e[o],i+=t[o]||e[o];return 0===i?1:n/i}for(var s=t.length,a=0,u=0,h=0,l=0;l<s;l++)a+=t[l],u+=e[l],h+=Math.min(t[l],e[l]);return 1-(a+u-2*h)/(a+u-h)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0,s=0;s<r;s++)n+=t[s]*e[s],i+=t[s]*t[s],o+=e[s]*e[s];return n/(Math.sqrt(i)*Math.sqrt(o))}},function(t,e,r){"use strict";var n=r(16),i={size:1,value:0};t.exports=function(t,e){if(e=n({},i,e),Array.isArray(t))return Array.isArray(t[0])?function(t,e){throw t.length,t[0].length,void 0===e.size[0]&&(e.size=[e.size,e.size,e.size,e.size]),new Error("matrix not supported yet, sorry")}(t,e):function(t,e){var r=t.length;"number"==typeof e.size&&(e.size=[e.size,e.size]);var n,i,o=r+e.size[0]+e.size[1];if(e.output){if(e.output.length!==o)throw new RangeError("Wrong output size");n=e.output}else n=new Array(o);if("circular"===e.value)for(i=0;i<o;i++)i<e.size[0]?n[i]=t[(r-e.size[0]%r+i)%r]:i<e.size[0]+r?n[i]=t[i-e.size[0]]:n[i]=t[(i-e.size[0])%r];else if("replicate"===e.value)for(i=0;i<o;i++)i<e.size[0]?n[i]=t[0]:i<e.size[0]+r?n[i]=t[i-e.size[0]]:n[i]=t[r-1];else if("symmetric"===e.value){if(e.size[0]>r||e.size[1]>r)throw new RangeError("expanded value should not be bigger than the data length");for(i=0;i<o;i++)i<e.size[0]?n[i]=t[e.size[0]-1-i]:i<e.size[0]+r?n[i]=t[i-e.size[0]]:n[i]=t[2*r+e.size[0]-i-1]}else for(i=0;i<o;i++)i<e.size[0]?n[i]=e.value:i<e.size[0]+r?n[i]=t[i-e.size[0]]:n[i]=e.value;return n}(t,e);throw new TypeError("data should be an array")}},function(t,e,r){"use strict";var n=r(17),i=r(73),o=e;o.PCA=r(80),o.HClust=r(81),o.KMeans=r(91),o.SVM=r(96),o.NaiveBayes=r(107),o.KNN=r(110),o.PLS=r(112),o.CrossValidation=r(115),o.ConfusionMatrix=r(32),o.DecisionTreeClassifier=n.DecisionTreeClassifier,o.RandomForestClassifier=i.RandomForestClassifier,o.FNN=r(117),o.SOM=r(119);var s=r(37);o.SimpleLinearRegression=s.SimpleLinearRegression,o.PolynomialRegression=s.PolynomialRegression,o.MultivariateLinearRegression=s.MultivariateLinearRegression,o.PowerRegression=s.PowerRegression,o.ExponentialRegression=s.ExponentialRegression,o.TheilSenRegression=s.TheilSenRegression,o.RobustPolynomialRegression=s.RobustPolynomialRegression,o.DecisionTreeRegression=n.DecisionTreeRegression,o.RandomForestRegression=i.RandomForestRegression,o.levenbergMarquardt=r(131);var a=r(0);o.Matrix=a.Matrix,o.SVD=a.SVD,o.EVD=a.EVD,o.CholeskyDecomposition=a.CholeskyDecomposition,o.LuDecomposition=a.LuDecomposition,o.QrDecomposition=a.QrDecomposition,o.SparseMatrix=r(132),o.Kernel=r(14),o.Distance=r(42).distance,o.Similarity=r(42).similarity,o.distanceMatrix=r(26),o.XSadd=r(29),o.Performance=r(181),o.savitzkyGolay=r(183),o.savitzkyGolayGeneralized=r(184),o.BitArray=r(185),o.HashTable=r(39),o.padArray=r(52),o.binarySearch=r(40),o.numSort=r(41),o.Random=r(28),o.ArrayUtils=r(187),o.Regression=r(37),o.MatrixUtil=r(0),o.ArrayStat=r(4).array,o.MatrixStat=r(4).matrix},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DecisionTreeClassifier=void 0;var n=o(r(0)),i=o(r(22));function o(t){return t&&t.__esModule?t:{default:t}}var s={gainFunction:"gini",splitFunction:"mean",minNumSamples:3,maxDepth:1/0};class a{constructor(t,e){!0===t?(this.options=e.options,this.root=new i.default(e.options),this.root.setNodeParameters(e.root)):(this.options=Object.assign({},s,t),this.options.kind="classifier")}train(t,e){this.root=new i.default(this.options),t=n.default.checkMatrix(t),this.root.train(t,e,0,null)}predict(t){t=n.default.checkMatrix(t);for(var e=new Array(t.rows),r=0;r<t.rows;++r)e[r]=this.root.classify(t.getRow(r)).maxRowIndex(0)[1];return e}toJSON(){return{options:this.options,root:this.root,name:"DTClassifier"}}static load(t){if("DTClassifier"!==t.name)throw new RangeError("Invalid model: "+t.name);return new a(!0,t)}}e.DecisionTreeClassifier=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e={}){if(!Array.isArray(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=void 0;if(void 0!==e.output){if(!Array.isArray(e.output))throw new TypeError("output option must be an array if specified");r=e.output}else r=new Array(t.length);var o=(0,i.default)(t),s=(0,n.default)(t);if(o===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var a=e.min,u=void 0===a?e.autoMinMax?o:0:a,h=e.max,l=void 0===h?e.autoMinMax?s:1:h;if(u>=l)throw new RangeError("min option must be smaller than max option");for(var c=(l-u)/(s-o),f=0;f<t.length;f++)r[f]=(t[f]-o)*c+u;return r};var n=o(r(18)),i=o(r(56));function o(t){return t&&t.__esModule?t:{default:t}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){if(!Array.isArray(t))throw new Error("input must be an array");if(0===t.length)throw new Error("input must not be empty");for(var e=t[0],r=1;r<t.length;r++)t[r]<e&&(e=t[r]);return e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends n.default{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends n.default{constructor(t,e){super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(6),i=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends i.default{constructor(t,e,r,i,o){(0,n.checkRange)(t,e,r,i,o),super(t,r-e+1,o-i+1),this.startRow=e,this.startColumn=i}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(6),i=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends i.default{constructor(t,e,r){var i=(0,n.checkIndices)(t,e,r);super(t,i.row.length,i.column.length),this.rowIndices=i.row,this.columnIndices=i.column}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(6),i=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends i.default{constructor(t,e){super(t,(e=(0,n.checkRowIndices)(t,e)).length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(6),i=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends i.default{constructor(t,e){e=(0,n.checkColumnIndices)(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends n.default{constructor(t,e){super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends n.default{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(r(3));e.default=class extends n.default{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.wrap=function(t,e){if(Array.isArray(t))return t[0]&&Array.isArray(t[0])?new i.default(t):new n.default(t,e);throw new Error("the argument is not an array")};var n=o(r(19)),i=o(r(20));function o(t){return t&&t.__esModule?t:{default:t}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.inverse=function(t,e=!1){return t=s.WrapperMatrix2D.checkMatrix(t),e?new o.default(t).inverse():u(t,s.Matrix.eye(t.rows))},e.solve=u;var n=a(r(10)),i=a(r(21)),o=a(r(8)),s=r(0);function a(t){return t&&t.__esModule?t:{default:t}}function u(t,e,r=!1){return t=s.WrapperMatrix2D.checkMatrix(t),e=s.WrapperMatrix2D.checkMatrix(e),r?new o.default(t).solve(e):t.isSquare()?new n.default(t).solve(e):new i.default(t).solve(e)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.linearDependencies=function(t,e={}){for(var r=e.thresholdValue,s=void 0===r?1e-9:r,h=e.thresholdError,l=void 0===h?1e-9:h,c=t.rows,f=new i.default(c,c),d=0;d<c;d++){var m=i.default.columnVector(t.getRow(d)),g=t.subMatrixRow(a(c,d)).transposeView(),p=new o.default(g),v=p.solve(m),w=(0,n.default)(i.default.sub(m,g.mmul(v)).abs().to1DArray());f.setRow(d,u(w,v,d,s,l))}return f};var n=s(r(18)),i=s(r(5)),o=s(r(8));function s(t){return t&&t.__esModule?t:{default:t}}function a(t,e){for(var r=[],n=0;n<t;n++)n!==e&&r.push(n);return r}function u(t,e,r,n=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);for(var o=e.addRow(r,[0]),s=0;s<o.rows;s++)Math.abs(o.get(s,0))<n&&o.set(s,0,0);return o.to1DArray()}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(11);function o(t,e,r,n){var i,o;return Math.abs(r)>Math.abs(n)?[(t+(i=n/r)*e)/(o=r+i*n),(e-i*t)/o]:[((i=r/n)*t+e)/(o=n+i*r),(i*e-t)/o]}e.default=class{constructor(t,e={}){var r=e.assumeSymmetric,s=void 0!==r&&r;if(!(t=n.WrapperMatrix2D.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");var a,u,h=t.columns,l=(0,i.getFilled2DArray)(h,h,0),c=new Array(h),f=new Array(h),d=t;if(s||t.isSymmetric()){for(a=0;a<h;a++)for(u=0;u<h;u++)l[a][u]=d.get(a,u);!function(t,e,r,n){var i,o,s,a,u,h,l,c;for(u=0;u<t;u++)r[u]=n[t-1][u];for(a=t-1;a>0;a--){for(c=0,s=0,h=0;h<a;h++)c+=Math.abs(r[h]);if(0===c)for(e[a]=r[a-1],u=0;u<a;u++)r[u]=n[a-1][u],n[a][u]=0,n[u][a]=0;else{for(h=0;h<a;h++)r[h]/=c,s+=r[h]*r[h];for(i=r[a-1],o=Math.sqrt(s),i>0&&(o=-o),e[a]=c*o,s-=i*o,r[a-1]=i-o,u=0;u<a;u++)e[u]=0;for(u=0;u<a;u++){for(i=r[u],n[u][a]=i,o=e[u]+n[u][u]*i,h=u+1;h<=a-1;h++)o+=n[h][u]*r[h],e[h]+=n[h][u]*i;e[u]=o}for(i=0,u=0;u<a;u++)e[u]/=s,i+=e[u]*r[u];for(l=i/(s+s),u=0;u<a;u++)e[u]-=l*r[u];for(u=0;u<a;u++){for(i=r[u],o=e[u],h=u;h<=a-1;h++)n[h][u]-=i*e[h]+o*r[h];r[u]=n[a-1][u],n[a][u]=0}}r[a]=s}for(a=0;a<t-1;a++){if(n[t-1][a]=n[a][a],n[a][a]=1,0!==(s=r[a+1])){for(h=0;h<=a;h++)r[h]=n[h][a+1]/s;for(u=0;u<=a;u++){for(o=0,h=0;h<=a;h++)o+=n[h][a+1]*n[h][u];for(h=0;h<=a;h++)n[h][u]-=o*r[h]}}for(h=0;h<=a;h++)n[h][a+1]=0}for(u=0;u<t;u++)r[u]=n[t-1][u],n[t-1][u]=0;n[t-1][t-1]=1,e[0]=0}(h,f,c,l),function(t,e,r,n){var o,s,a,u,h,l,c,f,d,m,g,p,v,w,y,x;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;var M=0,b=0,A=Number.EPSILON;for(l=0;l<t;l++){for(b=Math.max(b,Math.abs(r[l])+Math.abs(e[l])),c=l;c<t&&!(Math.abs(e[c])<=A*b);)c++;if(c>l)do{for(o=r[l],f=(r[l+1]-o)/(2*e[l]),d=(0,i.hypotenuse)(f,1),f<0&&(d=-d),r[l]=e[l]/(f+d),r[l+1]=e[l]*(f+d),m=r[l+1],s=o-r[l],a=l+2;a<t;a++)r[a]-=s;for(M+=s,f=r[c],p=g=1,v=g,w=e[l+1],y=0,x=0,a=c-1;a>=l;a--)for(v=p,p=g,x=y,o=g*e[a],s=g*f,d=(0,i.hypotenuse)(f,e[a]),e[a+1]=y*d,y=e[a]/d,f=(g=f/d)*r[a]-y*o,r[a+1]=s+y*(g*o+y*r[a]),h=0;h<t;h++)s=n[h][a+1],n[h][a+1]=y*n[h][a]+g*s,n[h][a]=g*n[h][a]-y*s;f=-y*x*v*w*e[l]/m,e[l]=y*f,r[l]=g*f}while(Math.abs(e[l])>A*b);r[l]=r[l]+M,e[l]=0}for(a=0;a<t-1;a++){for(h=a,f=r[a],u=a+1;u<t;u++)r[u]<f&&(h=u,f=r[u]);if(h!==a)for(r[h]=r[a],r[a]=f,u=0;u<t;u++)f=n[u][a],n[u][a]=n[u][h],n[u][h]=f}}(h,f,c,l)}else{var m=(0,i.getFilled2DArray)(h,h,0),g=new Array(h);for(u=0;u<h;u++)for(a=0;a<h;a++)m[a][u]=d.get(a,u);!function(t,e,r,n){var i,o,s,a,u,h,l,c=t-1;for(h=1;h<=c-1;h++){for(l=0,a=h;a<=c;a++)l+=Math.abs(e[a][h-1]);if(0!==l){for(s=0,a=c;a>=h;a--)r[a]=e[a][h-1]/l,s+=r[a]*r[a];for(o=Math.sqrt(s),r[h]>0&&(o=-o),s-=r[h]*o,r[h]=r[h]-o,u=h;u<t;u++){for(i=0,a=c;a>=h;a--)i+=r[a]*e[a][u];for(i/=s,a=h;a<=c;a++)e[a][u]-=i*r[a]}for(a=0;a<=c;a++){for(i=0,u=c;u>=h;u--)i+=r[u]*e[a][u];for(i/=s,u=h;u<=c;u++)e[a][u]-=i*r[u]}r[h]=l*r[h],e[h][h-1]=l*o}}for(a=0;a<t;a++)for(u=0;u<t;u++)n[a][u]=a===u?1:0;for(h=c-1;h>=1;h--)if(0!==e[h][h-1]){for(a=h+1;a<=c;a++)r[a]=e[a][h-1];for(u=h;u<=c;u++){for(o=0,a=h;a<=c;a++)o+=r[a]*n[a][u];for(o=o/r[h]/e[h][h-1],a=h;a<=c;a++)n[a][u]+=o*r[a]}}}(h,m,g,l),function(t,e,r,n,i){var s,a,u,h,l,c,f,d,m,g,p,v,w,y,x,M=t-1,b=t-1,A=Number.EPSILON,S=0,_=0,R=0,E=0,O=0,k=0,P=0,C=0;for(s=0;s<t;s++)for((s<0||s>b)&&(r[s]=i[s][s],e[s]=0),a=Math.max(s-1,0);a<t;a++)_+=Math.abs(i[s][a]);for(;M>=0;){for(h=M;h>0&&(0===(k=Math.abs(i[h-1][h-1])+Math.abs(i[h][h]))&&(k=_),!(Math.abs(i[h][h-1])<A*k));)h--;if(h===M)i[M][M]=i[M][M]+S,r[M]=i[M][M],e[M]=0,M--,C=0;else if(h===M-1){if(f=i[M][M-1]*i[M-1][M],R=(i[M-1][M-1]-i[M][M])/2,E=R*R+f,P=Math.sqrt(Math.abs(E)),i[M][M]=i[M][M]+S,i[M-1][M-1]=i[M-1][M-1]+S,d=i[M][M],E>=0){for(P=R>=0?R+P:R-P,r[M-1]=d+P,r[M]=r[M-1],0!==P&&(r[M]=d-f/P),e[M-1]=0,e[M]=0,d=i[M][M-1],k=Math.abs(d)+Math.abs(P),R=d/k,E=P/k,O=Math.sqrt(R*R+E*E),R/=O,E/=O,a=M-1;a<t;a++)P=i[M-1][a],i[M-1][a]=E*P+R*i[M][a],i[M][a]=E*i[M][a]-R*P;for(s=0;s<=M;s++)P=i[s][M-1],i[s][M-1]=E*P+R*i[s][M],i[s][M]=E*i[s][M]-R*P;for(s=0;s<=b;s++)P=n[s][M-1],n[s][M-1]=E*P+R*n[s][M],n[s][M]=E*n[s][M]-R*P}else r[M-1]=d+R,r[M]=d+R,e[M-1]=P,e[M]=-P;M-=2,C=0}else{if(d=i[M][M],m=0,f=0,h<M&&(m=i[M-1][M-1],f=i[M][M-1]*i[M-1][M]),10===C){for(S+=d,s=0;s<=M;s++)i[s][s]-=d;k=Math.abs(i[M][M-1])+Math.abs(i[M-1][M-2]),d=m=.75*k,f=-.4375*k*k}if(30===C&&(k=(k=(m-d)/2)*k+f)>0){for(k=Math.sqrt(k),m<d&&(k=-k),k=d-f/((m-d)/2+k),s=0;s<=M;s++)i[s][s]-=k;S+=k,d=m=f=.964}for(C+=1,l=M-2;l>=h&&(P=i[l][l],R=((O=d-P)*(k=m-P)-f)/i[l+1][l]+i[l][l+1],E=i[l+1][l+1]-P-O-k,O=i[l+2][l+1],k=Math.abs(R)+Math.abs(E)+Math.abs(O),R/=k,E/=k,O/=k,l!==h)&&!(Math.abs(i[l][l-1])*(Math.abs(E)+Math.abs(O))<A*(Math.abs(R)*(Math.abs(i[l-1][l-1])+Math.abs(P)+Math.abs(i[l+1][l+1]))));)l--;for(s=l+2;s<=M;s++)i[s][s-2]=0,s>l+2&&(i[s][s-3]=0);for(u=l;u<=M-1&&(y=u!==M-1,u!==l&&(R=i[u][u-1],E=i[u+1][u-1],O=y?i[u+2][u-1]:0,0!==(d=Math.abs(R)+Math.abs(E)+Math.abs(O))&&(R/=d,E/=d,O/=d)),0!==d);u++)if(k=Math.sqrt(R*R+E*E+O*O),R<0&&(k=-k),0!==k){for(u!==l?i[u][u-1]=-k*d:h!==l&&(i[u][u-1]=-i[u][u-1]),d=(R+=k)/k,m=E/k,P=O/k,E/=R,O/=R,a=u;a<t;a++)R=i[u][a]+E*i[u+1][a],y&&(R+=O*i[u+2][a],i[u+2][a]=i[u+2][a]-R*P),i[u][a]=i[u][a]-R*d,i[u+1][a]=i[u+1][a]-R*m;for(s=0;s<=Math.min(M,u+3);s++)R=d*i[s][u]+m*i[s][u+1],y&&(R+=P*i[s][u+2],i[s][u+2]=i[s][u+2]-R*O),i[s][u]=i[s][u]-R,i[s][u+1]=i[s][u+1]-R*E;for(s=0;s<=b;s++)R=d*n[s][u]+m*n[s][u+1],y&&(R+=P*n[s][u+2],n[s][u+2]=n[s][u+2]-R*O),n[s][u]=n[s][u]-R,n[s][u+1]=n[s][u+1]-R*E}}}if(0!==_){for(M=t-1;M>=0;M--)if(R=r[M],0===(E=e[M]))for(h=M,i[M][M]=1,s=M-1;s>=0;s--){for(f=i[s][s]-R,O=0,a=h;a<=M;a++)O+=i[s][a]*i[a][M];if(e[s]<0)P=f,k=O;else if(h=s,0===e[s]?i[s][M]=0!==f?-O/f:-O/(A*_):(d=i[s][s+1],m=i[s+1][s],E=(r[s]-R)*(r[s]-R)+e[s]*e[s],c=(d*k-P*O)/E,i[s][M]=c,i[s+1][M]=Math.abs(d)>Math.abs(P)?(-O-f*c)/d:(-k-m*c)/P),c=Math.abs(i[s][M]),A*c*c>1)for(a=s;a<=M;a++)i[a][M]=i[a][M]/c}else if(E<0)for(h=M-1,Math.abs(i[M][M-1])>Math.abs(i[M-1][M])?(i[M-1][M-1]=E/i[M][M-1],i[M-1][M]=-(i[M][M]-R)/i[M][M-1]):(x=o(0,-i[M-1][M],i[M-1][M-1]-R,E),i[M-1][M-1]=x[0],i[M-1][M]=x[1]),i[M][M-1]=0,i[M][M]=1,s=M-2;s>=0;s--){for(g=0,p=0,a=h;a<=M;a++)g+=i[s][a]*i[a][M-1],p+=i[s][a]*i[a][M];if(f=i[s][s]-R,e[s]<0)P=f,O=g,k=p;else if(h=s,0===e[s]?(x=o(-g,-p,f,E),i[s][M-1]=x[0],i[s][M]=x[1]):(d=i[s][s+1],m=i[s+1][s],v=(r[s]-R)*(r[s]-R)+e[s]*e[s]-E*E,w=2*(r[s]-R)*E,0===v&&0===w&&(v=A*_*(Math.abs(f)+Math.abs(E)+Math.abs(d)+Math.abs(m)+Math.abs(P))),x=o(d*O-P*g+E*p,d*k-P*p-E*g,v,w),i[s][M-1]=x[0],i[s][M]=x[1],Math.abs(d)>Math.abs(P)+Math.abs(E)?(i[s+1][M-1]=(-g-f*i[s][M-1]+E*i[s][M])/d,i[s+1][M]=(-p-f*i[s][M]-E*i[s][M-1])/d):(x=o(-O-m*i[s][M-1],-k-m*i[s][M],P,E),i[s+1][M-1]=x[0],i[s+1][M]=x[1])),c=Math.max(Math.abs(i[s][M-1]),Math.abs(i[s][M])),A*c*c>1)for(a=s;a<=M;a++)i[a][M-1]=i[a][M-1]/c,i[a][M]=i[a][M]/c}for(s=0;s<t;s++)if(s<0||s>b)for(a=s;a<t;a++)n[s][a]=i[s][a];for(a=t-1;a>=0;a--)for(s=0;s<=b;s++){for(P=0,u=0;u<=Math.min(a,b);u++)P+=n[s][u]*i[u][a];n[s][a]=P}}}(h,f,c,l,m)}this.n=h,this.e=f,this.d=c,this.V=l}get realEigenvalues(){return this.d}get imaginaryEigenvalues(){return this.e}get eigenvectorMatrix(){return n.Matrix.isMatrix(this.V)||(this.V=new n.Matrix(this.V)),this.V}get diagonalMatrix(){var t,e,r=this.n,i=this.e,o=this.d,s=new n.Matrix(r,r);for(t=0;t<r;t++){for(e=0;e<r;e++)s[t][e]=0;s[t][t]=o[t],i[t]>0?s[t][t+1]=i[t]:i[t]<0&&(s[t][t-1]=i[t])}return s}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0);e.default=class{constructor(t){if(!(t=n.WrapperMatrix2D.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");var e,r,i,o=t,s=o.rows,a=new n.Matrix(s,s),u=!0;for(r=0;r<s;r++){var h=a[r],l=0;for(i=0;i<r;i++){var c=a[i],f=0;for(e=0;e<i;e++)f+=c[e]*h[e];h[i]=f=(o.get(r,i)-f)/a[i][i],l+=f*f}for(u&=(l=o.get(r,r)-l)>0,a[r][r]=Math.sqrt(Math.max(l,0)),i=r+1;i<s;i++)a[r][i]=0}if(!u)throw new Error("Matrix is not positive definite");this.L=a}solve(t){t=n.WrapperMatrix2D.checkMatrix(t);var e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");var i,o,s,a=t.columns,u=t.clone();for(s=0;s<r;s++)for(o=0;o<a;o++){for(i=0;i<s;i++)u[s][o]-=u[i][o]*e[s][i];u[s][o]/=e[s][s]}for(s=r-1;s>=0;s--)for(o=0;o<a;o++){for(i=s+1;i<r;i++)u[s][o]-=u[i][o]*e[i][s];u[s][o]/=e[s][s]}return u}get lowerTriangularMatrix(){return this.L}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toDiscreteDistribution=s,e.giniImpurity=a,e.getNumberOfClasses=u,e.giniGain=function(t,e){for(var r=0,n=["greater","lesser"],i=0;i<n.length;++i){var o=e[n[i]];r+=a(o)*o.length/t.length}return a(t)-r},e.squaredError=h,e.regressionError=function(t,e){for(var r=0,n=["greater","lesser"],i=0;i<n.length;++i){var o=e[n[i]];r+=h(o)}return r},e.matrixSplitter=function(t,e,r,n){for(var i=[],o=[],s=[],a=[],u=0;u<t.rows;++u)t[u][r]<n?(i.push(t[u]),s.push(e[u])):(o.push(t[u]),a.push(e[u]));return{greaterX:o,greaterY:a,lesserX:i,lesserY:s}},e.mean=function(t,e){return(t+e)/2},e.zip=function(t,e){if(t.length!==e.length)throw new TypeError("Error on zip: the size of a: "+t.length+" is different from b: "+e.length);for(var r=new Array(t.length),n=0;n<t.length;++n)r[n]=[t[n],e[n]];return r};var n=o(r(0)),i=o(r(12));function o(t){return t&&t.__esModule?t:{default:t}}function s(t,e){for(var r=new Array(e).fill(0),i=0;i<t.length;++i)r[t[i]]+=1/t.length;return n.default.rowVector(r)}function a(t){if(0===t.length)return 0;for(var e=s(t,u(t))[0],r=0,n=0;n<e.length;++n)r+=e[n]*e[n];return 1-r}function u(t){return t.filter(function(t,e,r){return r.indexOf(t)===e}).length}function h(t){for(var e=t.length,r=(0,i.default)(t),n=0,o=0;o<e;++o){var s=t[o];n+=(s-r)*(s-r)}return n}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DecisionTreeRegression=void 0;var n=o(r(0)),i=o(r(22));function o(t){return t&&t.__esModule?t:{default:t}}var s={gainFunction:"regression",splitFunction:"mean",minNumSamples:3,maxDepth:1/0};class a{constructor(t,e){!0===t?(this.options=e.options,this.root=new i.default(e.options),this.root.setNodeParameters(e.root)):(this.options=Object.assign({},s,t),this.options.kind="regression")}train(t,e){this.root=new i.default(this.options),void 0===t[0].length&&(t=n.default.columnVector(t)),t=n.default.checkMatrix(t),this.root.train(t,e,0)}predict(t){void 0!==t[0]&&void 0===t[0].length&&(t=n.default.columnVector(t)),t=n.default.checkMatrix(t);for(var e=new Array(t.rows),r=0;r<t.rows;++r)e[r]=this.root.classify(t.getRow(r));return e}toJSON(){return{options:this.options,root:this.root,name:"DTRegression"}}static load(t){if("DTRegression"!==t.name)throw new RangeError("Invalid model:"+t.name);return new a(!0,t)}}e.DecisionTreeRegression=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(74);Object.defineProperty(e,"RandomForestClassifier",{enumerable:!0,get:function(){return n.RandomForestClassifier}});var i=r(77);Object.defineProperty(e,"RandomForestRegression",{enumerable:!0,get:function(){return i.RandomForestRegression}})},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RandomForestClassifier=void 0;var n=r(23),i={maxFeatures:1,replacement:!0,nEstimators:10,seed:42,useSampleBagging:!1};class o extends n.RandomForestBase{constructor(t,e){!0===t?super(!0,e.baseModel):((t=Object.assign({},i,t)).isClassifier=!0,super(t))}selection(t){return function(t){return t.sort((e,r)=>t.filter(t=>t===e).length-t.filter(t=>t===r).length).pop()}(t)}toJSON(){return{baseModel:super.toJSON(),name:"RFClassifier"}}static load(t){if("RFClassifier"!==t.name)throw new RangeError(`Invalid model: ${t.name}`);return new o(!0,t)}}e.RandomForestClassifier=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.checkFloat=function(t){return t>0&&t<=1},e.examplesBaggingWithReplacement=function(t,e,r){var o=n.default.engines.mt19937(),s=n.default.integer(0,t.rows-1);if(void 0===r)o=o.autoSeed();else{if(!Number.isInteger(r))throw new RangeError(`Expected seed must be undefined or integer not ${r}`);o=o.seed(r)}for(var a=new Array(t.rows),u=new Array(t.rows),h=0;h<t.rows;++h){var l=s(o);a[h]=t[l],u[h]=e[l]}return{X:new i.default(a),y:u}},e.featureBagging=function(t,e,r,o){if(t.columns<e)throw new RangeError("N should be less or equal to the number of columns of X");var s=n.default.integer(0,t.columns-1),a=n.default.engines.mt19937();if(void 0===o)a=a.autoSeed();else{if(!Number.isInteger(o))throw new RangeError(`Expected seed must be undefined or integer not ${o}`);a=a.seed(o)}var u=new i.default(t.rows,e);if(r)for(var h=new Array(e),l=0;l<e;++l){var c=s(a);h[l]=c,u.setColumn(l,t.getColumn(c))}else{for(h=new Set,c=s(a),l=0;l<e;++l){for(;h.has(c);)c=s(a);u.setColumn(l,t.getColumn(c)),h.add(c)}h=Array.from(h)}return{X:u,usedIndex:h}};var n=o(r(76)),i=o(r(0));function o(t){return t&&t.__esModule?t:{default:t}}},function(t,e,r){"use strict";var n;!function(i){var o="function"!=typeof Math.imul||-5!==Math.imul(4294967295,5)?function(t,e){var r=65535&t,n=65535&e;return r*n+((t>>>16&65535)*n+r*(e>>>16&65535)<<16>>>0)|0}:Math.imul,s="function"==typeof String.prototype.repeat&&"xxx"==="x".repeat(3)?function(t,e){return t.repeat(e)}:function(t,e){for(var r="";e>0;)1&e&&(r+=t),e>>=1,t+=t;return r};function a(t){if(!(this instanceof a))return new a(t);if(null==t)t=a.engines.nativeMath;else if("function"!=typeof t)throw new TypeError("Expected engine to be a function, got "+typeof t);this.engine=t}var u=a.prototype;function h(t){return function(){return t}}function l(t,e){return 0===e?t:function(r){return t(r)+e}}function c(t){var e=+t;return e<0?Math.ceil(e):Math.floor(e)}function f(t,e){return t<0?Math.max(t+e,0):Math.min(t,e)}function d(){}a.engines={nativeMath:function(){return 4294967296*Math.random()|0},mt19937:function(t){function e(t){for(var e=0,r=0;(0|e)<227;e=e+1|0)r=2147483648&t[e]|2147483647&t[e+1|0],t[e]=t[e+397|0]^r>>>1^(1&r?2567483615:0);for(;(0|e)<623;e=e+1|0)r=2147483648&t[e]|2147483647&t[e+1|0],t[e]=t[e-227|0]^r>>>1^(1&r?2567483615:0);r=2147483648&t[623]|2147483647&t[0],t[623]=t[396]^r>>>1^(1&r?2567483615:0)}return function(){var r=new t(624),n=0,i=0;function s(){(0|n)>=624&&(e(r),n=0);var t=r[n];return n=n+1|0,i+=1,0|function(t){return t^=t>>>11,t^=t<<7&2636928640,(t^=t<<15&4022730752)^t>>>18}(t)}return s.getUseCount=function(){return i},s.discard=function(t){for(i+=t,(0|n)>=624&&(e(r),n=0);t-n>624;)t-=624-n,e(r),n=0;return n=n+t|0,s},s.seed=function(t){var e=0;r[0]=e=0|t;for(var a=1;a<624;a=a+1|0)r[a]=e=o(e^e>>>30,1812433253)+a|0;return n=624,i=0,s},s.seedWithArray=function(t){return s.seed(19650218),function(t,e){for(var r=1,n=0,i=e.length,s=0|Math.max(i,624),a=0|t[0];(0|s)>0;--s)t[r]=a=(t[r]^o(a^a>>>30,1664525))+(0|e[n])+(0|n)|0,++n,(0|(r=r+1|0))>623&&(t[0]=t[623],r=1),n>=i&&(n=0);for(s=623;(0|s)>0;--s)t[r]=a=(t[r]^o(a^a>>>30,1566083941))-r|0,(0|(r=r+1|0))>623&&(t[0]=t[623],r=1);t[0]=2147483648}(r,t),s},s.autoSeed=function(){return s.seedWithArray(a.generateEntropyArray())},s}}("function"==typeof Int32Array?Int32Array:Array),browserCrypto:"undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof Int32Array?function(){var t=null,e=128;return function(){return e>=128&&(null===t&&(t=new Int32Array(128)),crypto.getRandomValues(t),e=0),0|t[e++]}}():null},a.generateEntropyArray=function(){for(var t=[],e=a.engines.nativeMath,r=0;r<16;++r)t[r]=0|e();return t.push(0|(new Date).getTime()),t},a.int32=function(t){return 0|t()},u.int32=function(){return a.int32(this.engine)},a.uint32=function(t){return t()>>>0},u.uint32=function(){return a.uint32(this.engine)},a.uint53=function(t){return 4294967296*(2097151&t())+(t()>>>0)},u.uint53=function(){return a.uint53(this.engine)},a.uint53Full=function(t){for(;;){var e=0|t();if(!(2097152&e))return 4294967296*(2097151&e)+(t()>>>0);if(2097152==(4194303&e)&&0==(0|t()))return 9007199254740992}},u.uint53Full=function(){return a.uint53Full(this.engine)},a.int53=function(t){var e=0|t();return 4294967296*(2097151&e)+(t()>>>0)+(2097152&e?-9007199254740992:0)},u.int53=function(){return a.int53(this.engine)},a.int53Full=function(t){for(;;){var e=0|t();if(!(4194304&e))return 4294967296*(2097151&e)+(t()>>>0)+(2097152&e?-9007199254740992:0);if(4194304==(8388607&e)&&0==(0|t()))return 9007199254740992}},u.int53Full=function(){return a.int53Full(this.engine)},a.integer=function(){function t(t){return 0==(t+1&t)}function e(e){return t(e)?function(t){return function(e){return e()&t}}(e):function(t){var e=t+1,r=e*Math.floor(4294967296/e);return function(t){var n=0;do{n=t()>>>0}while(n>=r);return n%e}}(e)}function r(e){var r=e+1;if(function(t){return 0==(0|t)}(r)){var n=(r/4294967296|0)-1;if(t(n))return function(t){return function(e){return 4294967296*(e()&t)+(e()>>>0)}}(n)}return function(t){var e=t*Math.floor(9007199254740992/t);return function(r){var n=0;do{n=4294967296*(2097151&r())+(r()>>>0)}while(n>=e);return n%t}}(r)}function n(t,e){return function(r){var n=0;do{var i=0|r();n=4294967296*(2097151&i)+(r()>>>0)+(2097152&i?-9007199254740992:0)}while(n<t||n>e);return n}}return function(t,i){if(t=Math.floor(t),i=Math.floor(i),t<-9007199254740992||!isFinite(t))throw new RangeError("Expected min to be at least -9007199254740992");if(i>9007199254740992||!isFinite(i))throw new RangeError("Expected max to be at most 9007199254740992");var o=i-t;return o<=0||!isFinite(o)?h(t):4294967295===o?0===t?a.uint32:l(a.int32,t+2147483648):o<4294967295?l(e(o),t):9007199254740991===o?l(a.uint53,t):o<9007199254740991?l(r(o),t):i-1-t==9007199254740991?l(a.uint53Full,t):-9007199254740992===t&&9007199254740992===i?a.int53Full:-9007199254740992===t&&9007199254740991===i?a.int53:-9007199254740991===t&&9007199254740992===i?l(a.int53,1):9007199254740992===i?l(n(t-1,i-1),1):n(t,i)}}(),u.integer=function(t,e){return a.integer(t,e)(this.engine)},a.realZeroToOneInclusive=function(t){return a.uint53Full(t)/9007199254740992},u.realZeroToOneInclusive=function(){return a.realZeroToOneInclusive(this.engine)},a.realZeroToOneExclusive=function(t){return a.uint53(t)/9007199254740992},u.realZeroToOneExclusive=function(){return a.realZeroToOneExclusive(this.engine)},a.real=function(){return function(t,e,r){if(!isFinite(t))throw new RangeError("Expected left to be a finite number");if(!isFinite(e))throw new RangeError("Expected right to be a finite number");return l(function(t,e){return 1===e?t:0===e?function(){return 0}:function(r){return t(r)*e}}(r?a.realZeroToOneInclusive:a.realZeroToOneExclusive,e-t),t)}}(),u.real=function(t,e,r){return a.real(t,e,r)(this.engine)},a.bool=function(){function t(t){return 1==(1&t())}function e(t,e){return function(r){return t(r)<e}}return function(r,n){return null==n?null==r?t:function(t){if(t<=0)return h(!1);if(t>=1)return h(!0);var r=4294967296*t;return r%1==0?e(a.int32,r-2147483648|0):e(a.uint53,Math.round(9007199254740992*t))}(r):r<=0?h(!1):r>=n?h(!0):e(a.integer(0,n-1),r)}}(),u.bool=function(t,e){return a.bool(t,e)(this.engine)},a.pick=function(t,e,r,n){var i=e.length,o=null==r?0:f(c(r),i),s=void 0===n?i:f(c(n),i);if(!(o>=s))return e[a.integer(o,s-1)(t)]},u.pick=function(t,e,r){return a.pick(this.engine,t,e,r)};var m=Array.prototype.slice;a.picker=function(t,e,r){var n=m.call(t,e,r);if(!n.length)return d;var i=a.integer(0,n.length-1);return function(t){return n[i(t)]}},a.shuffle=function(t,e,r){var n=e.length;if(n){null==r&&(r=0);for(var i=n-1>>>0;i>r;--i){var o=a.integer(0,i)(t);if(i!==o){var s=e[i];e[i]=e[o],e[o]=s}}}return e},u.shuffle=function(t){return a.shuffle(this.engine,t)},a.sample=function(t,e,r){if(r<0||r>e.length||!isFinite(r))throw new RangeError("Expected sampleSize to be within 0 and the length of the population");if(0===r)return[];var n=m.call(e),i=n.length;if(i===r)return a.shuffle(t,n,0);var o=i-r;return a.shuffle(t,n,o-1).slice(o)},u.sample=function(t,e){return a.sample(this.engine,t,e)},a.die=function(t){return a.integer(1,t)},u.die=function(t){return a.die(t)(this.engine)},a.dice=function(t,e){var r=a.die(t);return function(t){var n=[];n.length=e;for(var i=0;i<e;++i)n[i]=r(t);return n}},u.dice=function(t,e){return a.dice(t,e)(this.engine)},a.uuid4=function(){function t(t,e){return s("0",e-t.length)+t}return function(e){var r=e()>>>0,n=0|e(),i=0|e(),o=e()>>>0;return t(r.toString(16),8)+"-"+t((65535&n).toString(16),4)+"-"+t((n>>4&4095|16384).toString(16),4)+"-"+t((16383&i|32768).toString(16),4)+"-"+t((i>>4&65535).toString(16),4)+t(o.toString(16),8)}}(),u.uuid4=function(){return a.uuid4(this.engine)},a.string=function(t){null==t&&(t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-");var e=t.length;if(!e)throw new Error("Expected pool not to be an empty string");var r=a.integer(0,e-1);return function(e,n){for(var i="",o=0;o<n;++o){var s=r(e);i+=t.charAt(s)}return i}},u.string=function(t,e){return a.string(e)(this.engine,t)},a.hex=function(){var t=a.string("0123456789abcdef"),e=a.string("0123456789abcdef".toUpperCase());return function(r){return r?e:t}}(),u.hex=function(t,e){return a.hex(e)(this.engine,t)},a.date=function(t,e){if(!(t instanceof Date))throw new TypeError("Expected start to be a Date, got "+typeof t);if(!(e instanceof Date))throw new TypeError("Expected end to be a Date, got "+typeof e);var r=a.integer(t.getTime(),e.getTime());return function(t){return new Date(r(t))}},u.date=function(t,e){return a.date(t,e)(this.engine)},void 0===(n=function(){return a}.call(e,r,e,t))||(t.exports=n)}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RandomForestRegression=void 0;var n=s(r(12)),i=s(r(78)),o=r(23);function s(t){return t&&t.__esModule?t:{default:t}}var a={mean:n.default,median:i.default},u={maxFeatures:1,replacement:!1,nEstimators:10,treeOptions:{},selectionMethod:"mean",seed:42,useSampleBagging:!1};class h extends o.RandomForestBase{constructor(t,e){if(!0===t)super(!0,e.baseModel),this.selectionMethod=e.selectionMethod;else{if("mean"!==(t=Object.assign({},u,t)).selectionMethod&&"median"!==t.selectionMethod)throw new RangeError(`Unsupported selection method ${t.selectionMethod}`);t.isClassifier=!1,super(t),this.selectionMethod=t.selectionMethod}}selection(t){return a[this.selectionMethod](t)}toJSON(){return{baseModel:super.toJSON(),selectionMethod:this.selectionMethod,name:"RFRegression"}}static load(t){if("RFRegression"!==t.name)throw new RangeError(`Invalid model: ${t.name}`);return new h(!0,t)}}e.RandomForestRegression=h},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){if(!Array.isArray(t))throw new Error("input must be an array");if(0===t.length)throw new Error("input must not be empty");return(0,n.default)(t.slice())};var n=function(t){return t&&t.__esModule?t:{default:t}}(r(79))},function(t,e,r){"use strict";!function(){function e(t){for(var e=0,i=t.length-1,o=void 0,s=void 0,a=void 0,u=n(e,i);;){if(i<=e)return t[u];if(i==e+1)return t[e]>t[i]&&r(t,e,i),t[u];for(t[o=n(e,i)]>t[i]&&r(t,o,i),t[e]>t[i]&&r(t,e,i),t[o]>t[e]&&r(t,o,e),r(t,o,e+1),s=e+1,a=i;;){do{s++}while(t[e]>t[s]);do{a--}while(t[a]>t[e]);if(a<s)break;r(t,s,a)}r(t,e,a),a<=u&&(e=s),a>=u&&(i=a-1)}}var r=function(t,e,r){var n;return n=[t[r],t[e]],t[e]=n[0],t[r]=n[1],n},n=function(t,e){return~~((t+e)/2)};void 0!==t&&t.exports?t.exports=e:window.median=e}()},function(t,e,r){"use strict";var n=r(0),i=n.Matrix,o=n.EVD,s=n.SVD,a=r(9),u=a.mean,h=a.standardDeviation,l={isCovarianceMatrix:!1,center:!0,scale:!1};class c{constructor(t,e){if(!0===t){var r=e;return this.center=r.center,this.scale=r.scale,this.means=r.means,this.stdevs=r.stdevs,this.U=i.checkMatrix(r.U),void(this.S=r.S)}if(e=Object.assign({},l,e),this.center=!1,this.scale=!1,this.means=null,this.stdevs=null,e.isCovarianceMatrix)this._computeFromCovarianceMatrix(t);else if("boolean"==typeof e.useCovarianceMatrix?e.useCovarianceMatrix:t.length>t[0].length){var n=(t=this._adjust(t,e)).transposeView().mmul(t).div(t.rows-1);this._computeFromCovarianceMatrix(n)}else{t=this._adjust(t,e);var o=new s(t,{computeLeftSingularVectors:!1,computeRightSingularVectors:!0,autoTranspose:!0});this.U=o.rightSingularVectors;for(var a=o.diagonal,u=new Array(a.length),h=0;h<a.length;h++)u[h]=a[h]*a[h]/(t.length-1);this.S=u}}static load(t){if("PCA"!==t.name)throw new RangeError("Invalid model: "+t.name);return new c(!0,t)}predict(t,e={}){var r=e.nComponents,n=void 0===r?this.U.columns:r;t=new i(t),this.center&&(t.subRowVector(this.means),this.scale&&t.divRowVector(this.stdevs));var o=t.mmul(this.U);return o.subMatrix(0,o.rows-1,0,n-1)}getExplainedVariance(){for(var t=0,e=0;e<this.S.length;e++)t+=this.S[e];return this.S.map(e=>e/t)}getCumulativeVariance(){for(var t=this.getExplainedVariance(),e=1;e<t.length;e++)t[e]+=t[e-1];return t}getEigenvectors(){return this.U}getEigenvalues(){return this.S}getStandardDeviations(){return this.S.map(t=>Math.sqrt(t))}getLoadings(){return this.U.transpose()}toJSON(){return{name:"PCA",center:this.center,scale:this.scale,means:this.means,stdevs:this.stdevs,U:this.U,S:this.S}}_adjust(t,e){if(this.center=!!e.center,this.scale=!!e.scale,t=new i(t),this.center){var r=u(t),n=this.scale?h(t,r,!0):null;if(this.means=r,t.subRowVector(r),this.scale){for(var o=0;o<n.length;o++)if(0===n[o])throw new RangeError("Cannot scale the dataset (standard deviation is zero at index "+o);this.stdevs=n,t.divRowVector(n)}}return t}_computeFromCovarianceMatrix(t){var e=new o(t,{assumeSymmetric:!0});this.U=e.eigenvectorMatrix;for(var r=0;r<this.U.length;r++)this.U[r].reverse();this.S=e.realEigenvalues.reverse()}}t.exports=c},function(t,e,r){"use strict";e.agnes=r(82),e.diana=r(90)},function(t,e,r){"use strict";var n=r(1),i=r(25),o=r(13),s=r(26);function a(t,e,r){for(var n=1e101,i=0;i<t.length;i++)for(var o=0;o<e.length;o++){var s=r[t[i]][e[o]];n=Math.min(s,n)}return n}function u(t,e,r){for(var n=-1,i=0;i<t.length;i++)for(var o=0;o<e.length;o++){var s=r[t[i]][e[o]];n=Math.max(s,n)}return n}function h(t,e,r){for(var n=0,i=0;i<t.length;i++)for(var o=0;o<e.length;o++)n+=r[t[i]][e[o]];return n/(t.length*e.length)}function l(t,e,r){for(var n=new Array(t.length*e.length),i=0;i<t.length;i++)for(var o=0;o<e.length;o++)n[i*e.length+o]=r[t[i]][e[o]];return function(t,e){void 0===e&&(e=!1);e||(t=[].concat(t).sort(f));var r=t.length,n=Math.floor(r/2);return r%2==0?.5*(t[n-1]+t[n]):t[n]}(n)}function c(t,e,r){return l(t,e,r)*t.length*e.length/(t.length+e.length)}function f(t,e){return t-e}var d={disFunc:n,kind:"single",isDistanceMatrix:!1};t.exports=function(t,e){e=Object.assign({},d,e);var r=t.length,n=t;if(e.isDistanceMatrix||(n=s(t,e.disFunc)),"string"==typeof e.kind)switch(e.kind){case"single":e.kind=a;break;case"complete":e.kind=u;break;case"average":e.kind=h;break;case"centroid":e.kind=l;break;case"ward":e.kind=c;break;default:throw new RangeError("Unknown kind of similarity")}else if("function"!=typeof e.kind)throw new TypeError("Undefined kind of similarity");for(var f=new Array(r),m=0;m<n.length;m++)f[m]=new i(m);for(var g=1e6,p={},v=0;f.length>1;){p={},g=1e6;for(var w=0;w<f.length;w++)for(var y=w+1;y<f.length;y++){var x,M;if(f[w]instanceof i)x=[f[w].index];else{x=new Array(f[w].index.length);for(var b=0;b<x.length;b++)x[b]=f[w].index[b].index}if(f[y]instanceof i)M=[f[y].index];else{M=new Array(f[y].index.length);for(var A=0;A<M.length;A++)M[A]=f[y].index[A].index}(v=e.kind(x,M,n).toFixed(4))in p?p[v].push([f[w],f[y]]):p[v]=[[f[w],f[y]]],g=Math.min(v,g)}for(var S,_=p[g.toFixed(4)],R=new Array(_.length),E=0;_.length>0;){S=_.shift();for(var O=0;O<_.length;O++)if(_[O].filter(function(t){return-1!==S.indexOf(t)}).length>0){var k=_[O].filter(function(t){return-1===S.indexOf(t)});S=S.concat(k),_.splice(O--,1)}R[E++]=S}R.length=E;for(var P=0;P<R.length;P++){var C=new o;C.children=R[P].concat(),C.distance=g,C.index=new Array(r);for(var j=0,T=0;T<R[P].length;T++)R[P][T]instanceof i?C.index[j++]=R[P][T]:(j+=R[P][T].index.length,C.index=R[P][T].index.concat(C.index)),f.splice(f.indexOf(R[P][T]),1);C.index.length=j,f.push(C)}}return f[0]}},function(t,e,r){"use strict";t.exports=r(84)},function(t,e,r){"use strict";var n,i,o;(function(){var r,s,a,u,h,l,c,f,d,m,g,p,v,w,y;a=Math.floor,m=Math.min,s=function(t,e){return t<e?-1:t>e?1:0},d=function(t,e,r,n,i){var o;if(null==r&&(r=0),null==i&&(i=s),r<0)throw new Error("lo must be non-negative");for(null==n&&(n=t.length);r<n;)i(e,t[o=a((r+n)/2)])<0?n=o:r=o+1;return[].splice.apply(t,[r,r-r].concat(e)),e},l=function(t,e,r){return null==r&&(r=s),t.push(e),w(t,0,t.length-1,r)},h=function(t,e){var r,n;return null==e&&(e=s),r=t.pop(),t.length?(n=t[0],t[0]=r,y(t,0,e)):n=r,n},f=function(t,e,r){var n;return null==r&&(r=s),n=t[0],t[0]=e,y(t,0,r),n},c=function(t,e,r){var n;return null==r&&(r=s),t.length&&r(t[0],e)<0&&(e=(n=[t[0],e])[0],t[0]=n[1],y(t,0,r)),e},u=function(t,e){var r,n,i,o,u,h;for(null==e&&(e=s),u=[],n=0,i=(o=function(){h=[];for(var e=0,r=a(t.length/2);0<=r?e<r:e>r;0<=r?e++:e--)h.push(e);return h}.apply(this).reverse()).length;n<i;n++)r=o[n],u.push(y(t,r,e));return u},v=function(t,e,r){var n;if(null==r&&(r=s),-1!==(n=t.indexOf(e)))return w(t,0,n,r),y(t,n,r)},g=function(t,e,r){var n,i,o,a,h;if(null==r&&(r=s),!(i=t.slice(0,e)).length)return i;for(u(i,r),o=0,a=(h=t.slice(e)).length;o<a;o++)n=h[o],c(i,n,r);return i.sort(r).reverse()},p=function(t,e,r){var n,i,o,a,l,c,f,g,p;if(null==r&&(r=s),10*e<=t.length){if(!(o=t.slice(0,e).sort(r)).length)return o;for(i=o[o.length-1],a=0,c=(f=t.slice(e)).length;a<c;a++)r(n=f[a],i)<0&&(d(o,n,0,null,r),o.pop(),i=o[o.length-1]);return o}for(u(t,r),p=[],l=0,g=m(e,t.length);0<=g?l<g:l>g;0<=g?++l:--l)p.push(h(t,r));return p},w=function(t,e,r,n){var i,o,a;for(null==n&&(n=s),i=t[r];r>e&&n(i,o=t[a=r-1>>1])<0;)t[r]=o,r=a;return t[r]=i},y=function(t,e,r){var n,i,o,a,u;for(null==r&&(r=s),i=t.length,u=e,o=t[e],n=2*e+1;n<i;)(a=n+1)<i&&!(r(t[n],t[a])<0)&&(n=a),t[e]=t[n],n=2*(e=n)+1;return t[e]=o,w(t,u,e,r)},r=function(){function t(t){this.cmp=null!=t?t:s,this.nodes=[]}return t.push=l,t.pop=h,t.replace=f,t.pushpop=c,t.heapify=u,t.updateItem=v,t.nlargest=g,t.nsmallest=p,t.prototype.push=function(t){return l(this.nodes,t,this.cmp)},t.prototype.pop=function(){return h(this.nodes,this.cmp)},t.prototype.peek=function(){return this.nodes[0]},t.prototype.contains=function(t){return-1!==this.nodes.indexOf(t)},t.prototype.replace=function(t){return f(this.nodes,t,this.cmp)},t.prototype.pushpop=function(t){return c(this.nodes,t,this.cmp)},t.prototype.heapify=function(){return u(this.nodes,this.cmp)},t.prototype.updateItem=function(t){return v(this.nodes,t,this.cmp)},t.prototype.clear=function(){return this.nodes=[]},t.prototype.empty=function(){return 0===this.nodes.length},t.prototype.size=function(){return this.nodes.length},t.prototype.clone=function(){var e;return(e=new t).nodes=this.nodes.slice(0),e},t.prototype.toArray=function(){return this.nodes.slice(0)},t.prototype.insert=t.prototype.push,t.prototype.top=t.prototype.peek,t.prototype.front=t.prototype.peek,t.prototype.has=t.prototype.contains,t.prototype.copy=t.prototype.clone,t}(),function(r,s){i=[],void 0!==(o="function"==typeof(n=s)?n.apply(e,i):n)&&(t.exports=o)}(0,function(){return r})}).call(void 0)},function(t,e,r){"use strict";(function(t,n){var i=/%[sdj%]/g;e.format=function(t){if(!v(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(a(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,o=n.length,s=String(t).replace(i,function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r<o;u=n[++r])g(u)||!x(u)?s+=" "+u:s+=" "+a(u);return s},e.deprecate=function(r,i){if(w(t.process))return function(){return e.deprecate(r,i).apply(this,arguments)};if(!0===n.noDeprecation)return r;var o=!1;return function(){if(!o){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),o=!0}return r.apply(this,arguments)}};var o,s={};function a(t,r){var n={seen:[],stylize:h};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),m(r)?n.showHidden=r:r&&e._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),l(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function h(t,e){return t}function l(t,r,n){if(t.customInspect&&r&&A(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return v(i)||(i=l(t,i,n)),i}var o=function(t,e){if(w(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(p(e))return t.stylize(""+e,"number");if(m(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,r);if(o)return o;var s=Object.keys(r),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),b(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return c(r);if(0===s.length){if(A(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(y(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(M(r))return t.stylize(Date.prototype.toString.call(r),"date");if(b(r))return c(r)}var h,x="",S=!1,_=["{","}"];(d(r)&&(S=!0,_=["[","]"]),A(r))&&(x=" [Function"+(r.name?": "+r.name:"")+"]");return y(r)&&(x=" "+RegExp.prototype.toString.call(r)),M(r)&&(x=" "+Date.prototype.toUTCString.call(r)),b(r)&&(x=" "+c(r)),0!==s.length||S&&0!=r.length?n<0?y(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),h=S?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s<a;++s)E(e,String(s))?o.push(f(t,e,r,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(f(t,e,r,n,i,!0))}),o}(t,r,n,a,s):s.map(function(e){return f(t,r,n,a,e,S)}),t.seen.pop(),function(t,e,r){if(t.reduce(function(t,e){return 0,e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(h,x,_)):_[0]+x+_[1]}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),E(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=g(r)?l(t,u.value,null):l(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function m(t){return"boolean"==typeof t}function g(t){return null===t}function p(t){return"number"==typeof t}function v(t){return"string"==typeof t}function w(t){return void 0===t}function y(t){return x(t)&&"[object RegExp]"===S(t)}function x(t){return"object"==typeof t&&null!==t}function M(t){return x(t)&&"[object Date]"===S(t)}function b(t){return x(t)&&("[object Error]"===S(t)||t instanceof Error)}function A(t){return"function"==typeof t}function S(t){return Object.prototype.toString.call(t)}function _(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(w(o)&&(o=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var r=n.pid;s[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else s[t]=function(){};return s[t]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=m,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=p,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=w,e.isRegExp=y,e.isObject=x,e.isDate=M,e.isError=b,e.isFunction=A,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(88);var R=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[_(t.getHours()),_(t.getMinutes()),_(t.getSeconds())].join(":");return[t.getDate(),R[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(89),e._extend=function(t,e){if(!e||!x(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(e,r(86),r(87))},function(t,e,r){"use strict";var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,r){"use strict";var n,i,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(t){i=a}}();var h,l=[],c=!1,f=-1;function d(){c&&h&&(c=!1,h.length?l=h.concat(l):f=-1,l.length&&m())}function m(){if(!c){var t=u(d);c=!0;for(var e=l.length;e;){for(h=l,l=[];++f<e;)h&&h[f].run();f=-1,e=l.length}h=null,c=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function g(t,e){this.fun=t,this.array=e}function p(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];l.push(new g(t,e)),1!==l.length||c||u(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,r){"use strict";t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){"use strict";"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";var n=r(1),i=r(25),o=r(13);function s(t,e,r){for(var n=1e101,i=0;i<t.length;i++)for(var o=i;o<e.length;o++){var s=r(t[i],e[o]);n=Math.min(s,n)}return n}function a(t,e,r){for(var n=-1,i=0;i<t.length;i++)for(var o=i;o<e.length;o++){var s=r(t[i],e[o]);n=Math.max(s,n)}return n}function u(t,e,r){for(var n=0,i=0;i<t.length;i++)for(var o=0;o<e.length;o++)n+=r(t[i],e[o]);return n/(t.length*e.length)}function h(t,e,r){for(var n=0,i=0,o=0,s=0,a=0;a<t.length;a++)n+=t[a][0],i+=t[a][1];for(var u=0;u<e.length;u++)o+=e[u][0],s+=e[u][1];return r([n/=t.length,i/=t.length],[o/=e.length,s/=e.length])}function l(t,e,r){for(var n=0,i=0,o=0,s=0,a=0;a<t.length;a++)n+=t[a][0],i+=t[a][1];for(var u=0;u<e.length;u++)o+=e[u][0],s+=e[u][1];return r([n/=t.length,i/=t.length],[o/=e.length,s/=e.length])*t.length*e.length/(t.length+e.length)}function c(t,e,r){for(var n={d:0,p:0},i=new Array(t[0].length),o=0;o<t[0].length;o++)i[o]=e[t[0][o]];for(var s,a,u=new Array(t[1].length),h=0;h<t[1].length;h++)u[h]=e[t[1][h]];for(var l=0;l<i.length;l++){s=0;for(var c=0;c<i.length;c++)l!==c&&(s+=r(i[l],i[c]));s/=i.length-1,a=0;for(var f=0;f<u.length;f++)a+=r(i[l],u[f]);s-(a/=u.length)>n.d&&(n.d=s-a,n.p=l)}return n}var f={dist:n,kind:"single"};function d(t,e,r){for(var n=0,i=0,o=0;o<t.length;o++)for(var s=o;s<t.length;s++)n+=r(e[t[o].index],e[t[s].index]),i++;return n/i}t.exports=function(t,e){if("string"==typeof(e=Object.assign({},f,e)).kind)switch(e.kind){case"single":e.kind=s;break;case"complete":e.kind=a;break;case"average":e.kind=u;break;case"centroid":e.kind=h;break;case"ward":e.kind=l;break;default:throw new RangeError("Unknown kind of similarity")}else if("function"!=typeof e.kind)throw new TypeError("Undefined kind of similarity");var r,n,m,g,p,v=new o;v.children=new Array(t.length),v.index=new Array(t.length);for(var w=0;w<t.length;w++)v.children[w]=new i(w),v.index[w]=new i(w);v.distance=d(v.index,t,e.dist);for(var y=[v];y.length>0;){n=0,m=0;for(var x=0;x<y.length;x++){r=0;for(var M=0;M<y[x].length;M++)for(var b=M+1;b<y[x].length;b++)r=Math.max(e.dist(t[y[x].index[M].index],t[y[x].index[b].index]),r);r>n&&(n=r,m=x)}if(n=0,2===y[m].index.length)y[m].children=[y[m].index[0],y[m].index[1]],y[m].distance=e.dist(t[y[m].index[0].index],t[y[m].index[1].index]);else if(3===y[m].index.length){y[m].children=[y[m].index[0],y[m].index[1],y[m].index[2]];var A=[e.dist(t[y[m].index[0].index],t[y[m].index[1].index]),e.dist(t[y[m].index[1].index],t[y[m].index[2].index])];y[m].distance=(A[0]+A[1])/2}else{for(var S=new o,_=new o,R=[new Array(y[m].index.length),[]],E=0;E<R[0].length;E++)R[0][E]=E;for(var O=0;O<R[0].length;O++){g=0;for(var k=0;k<R[0].length;k++)O!==k&&(g+=e.dist(t[y[m].index[R[0][k]].index],t[y[m].index[R[0][O]].index]));(g/=R[0].length-1)>n&&(n=g,p=O)}for(R[1]=[p],R[0].splice(p,1),g=c(R,t,e.dist);g.d>0;)R[1].push(R[0][g.p]),R[0].splice(g.p,1),g=c(R,t,e.dist);var P=new Array(R[0].length);S.index=new Array(R[0].length);for(var C=0;C<P.length;C++)P[C]=t[y[m].index[R[0][C]].index],S.index[C]=y[m].index[R[0][C]],S.children[C]=y[m].index[R[0][C]];var j=new Array(R[1].length);_.index=new Array(R[1].length);for(var T=0;T<j.length;T++)j[T]=t[y[m].index[R[1][T]].index],_.index[T]=y[m].index[R[1][T]],_.children[T]=y[m].index[R[1][T]];S.distance=d(S.index,t,e.dist),_.distance=d(_.index,t,e.dist),y.push(S),y.push(_),y[m].children=[S,_]}y.splice(m,1)}return v}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r){if(r=Object.assign({},u,r),e<=0||e>t.length||!Number.isInteger(e))throw new Error("K should be a positive integer smaller than the number of points");var n;if(Array.isArray(r.initialization)){if(r.initialization.length!==e)throw new Error("The initial centers should have the same length as K");n=r.initialization}else switch(r.initialization){case"kmeans++":n=(0,o.kmeanspp)(t,e,r);break;case"random":n=(0,o.random)(t,e,r.seed);break;case"mostDistant":n=(0,o.mostDistant)(t,e,(0,i.calculateDistanceMatrix)(t,r.distanceFunction),r.seed);break;default:throw new Error(`Unknown initialization method: "${r.initialization}"`)}0===r.maxIterations&&(r.maxIterations=Number.MAX_VALUE);var s=new Array(t.length);if(r.withIterations)return function*(t,e,r,n,i){var o,s=!1,a=0;for(;!s&&a<i.maxIterations;)yield(o=h(t,e,r,n,i,++a)).computeInformation(e),s=o.converged,t=o.centroids}(n,t,s,e,r);for(var a,l=!1,c=0;!l&&c<r.maxIterations;)a=h(n,t,s,e,r,++c),l=a.converged,n=a.centroids;return a.computeInformation(t)};var n=a(r(1)),i=r(27),o=r(93),s=a(r(95));function a(t){return t&&t.__esModule?t:{default:t}}var u={maxIterations:100,tolerance:1e-6,withIterations:!1,initialization:"kmeans++",distanceFunction:n.default.squared};function h(t,e,r,n,o,a){r=(0,i.updateClusterID)(e,t,r,o.distanceFunction);var u=(0,i.updateCenters)(t,e,r,n),h=(0,i.hasConverged)(u,t,o.distanceFunction,o.tolerance);return new s.default(r,u,h,a,o.distanceFunction)}},function(t,e,r){"use strict";var n={distanceFunction:r(1).squared,similarityFunction:!1,returnVector:!1};t.exports=function(t,e,r){var i=(r=r||n).distanceFunction||n.distanceFunction,o=r.similarityFunction||n.similarityFunction,s=r.returnVector||n.returnVector,a=-1;if("function"==typeof o)for(var u=Number.MIN_VALUE,h=0;h<t.length;h++){var l=o(e,t[h]);l>u&&(u=l,a=h)}else{if("function"!=typeof i)throw new Error("A similarity or distance function it's required");for(var c=Number.MAX_VALUE,f=0;f<t.length;f++){var d=i(e,t[f]);d<c&&(c=d,a=f)}}return s?t[a]:a}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.random=function(t,e,r){return new n.default(r).choice(t,{size:e})},e.mostDistant=function(t,e,r,i){var o=new n.default(i),s=new Array(e);if(s[0]=Math.floor(o.random()*t.length),e>1){for(var a={dist:-1,index:-1},u=0;u<t.length;++u)r[s[0]][u]>a.dist&&(a.dist=r[s[0]][u],a.index=u);if(s[1]=a.index,e>2)for(var h=2;h<e;++h){for(var l={dist:-1,index:-1},c=0;c<t.length;++c){for(var f={dist:Number.MAX_VALUE,index:-1},d=0;d<h;++d)r[d][c]<f.dist&&-1===s.indexOf(c)&&(f={dist:r[d][c],index:c});f.dist!==Number.MAX_VALUE&&f.dist>l.dist&&(l=Object.assign({},f))}s[h]=l.index}}return s.map(e=>t[e])},e.kmeanspp=function(t,e,r={}){var h=(t=new o.Matrix(t)).length,l=new n.default(r.seed),c=[],f=r.localTrials||2+Math.floor(Math.log(e)),d=l.randInt(h);c.push(t[d].slice());for(var m=[t.map(t=>(0,i.squared)(t,c[0]))],g=[u(m[0])],p=1/g[0][h-1],v=o.Matrix.mul(m,p),w=1;w<e;w++){for(var y=l.choice(h,{replace:!0,size:f,probabilities:v[0]}),x=t.selection(y,a(t[0].length)),M=s(x,t),b=void 0,A=void 0,S=void 0,_=0;_<f;_++){var R=o.Matrix.min(m,[M[_]]),E=R.sum();(void 0===b||E<A)&&(b=y[_],A=E,S=R)}c[w]=t[b].slice(),g=[u((m=S)[0])],v=o.Matrix.mul(m,1/g[0][h-1])}return c};var n=function(t){return t&&t.__esModule?t:{default:t}}(r(28)),i=r(1),o=r(0);function s(t,e){for(var r=new o.Matrix(t.length,e.length),n=0;n<t.length;n++)for(var s=0;s<e.length;s++)r.set(n,s,(0,i.squared)(t.getRow(n),e.getRow(s)));return r}function a(t){for(var e=[],r=0;r<t;r++)e.push(r);return e}function u(t){for(var e=[t[0]],r=1;r<t.length;r++)e[r]=e[r-1]+t[r];return e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=1e-8;function i(t,e,r){var n=e();if(r){for(var i=0;n>r[i];)i++;return i}return Math.floor(n*t)}e.default=function(t,e={},r=Math.random){var o=e.size,s=void 0===o?1:o,a=e.replace,u=void 0!==a&&a,h=e.probabilities,l=void 0,c=void 0;if(l="number"==typeof t?function(t){for(var e=[],r=0;r<t;r++)e.push(r);return e}(t):t.slice(),h){if(!u)throw new Error("choice with probabilities and no replacement is not implemented");if(h.length!==l.length)throw new Error("the length of probabilities option should be equal to the number of choices");c=[h[0]];for(var f=1;f<h.length;f++)c[f]=c[f-1]+h[f];if(Math.abs(1-c[c.length-1])>n)throw new Error(`probabilities should sum to 1, but instead sums to ${c[c.length-1]}`)}if(!1===u&&s>l.length)throw new Error("size option is too large");for(var d=[],m=0;m<s;m++){var g=i(l.length,r,c);d.push(l[g]),u||l.splice(g,1)}return d}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(27),i=Symbol("distance");class o{constructor(t,e,r,n,o){this.clusters=t,this.centroids=e,this.converged=r,this.iterations=n,this[i]=o}nearest(t){var e=new Array(t.length),r=this.centroids.map(function(t){return t.centroid});return(0,n.updateClusterID)(t,r,e,this[i])}computeInformation(t){for(var e=this.centroids.map(function(t){return{centroid:t,error:0,size:0}}),r=0;r<t.length;r++)e[this.clusters[r]].error+=this[i](t[r],this.centroids[this.clusters[r]]),e[this.clusters[r]].size++;for(var n=0;n<this.centroids.length;n++)e[n].size?e[n].error/=e[n].size:e[n].error=null;return new o(this.clusters,e,this.converged,this.iterations,this[i])}}e.default=o},function(t,e,r){"use strict";var n=r(14),i=r(4).array,o={C:1,tol:1e-4,maxPasses:10,maxIterations:1e4,kernel:"linear",alphaTol:1e-6,random:Math.random,whitening:!0};function s(t){this.options=Object.assign({},o,t),this.kernel=new n(this.options.kernel,this.options.kernelOptions),this.b=0}s.prototype.train=function(t,e){if(t.length!==e.length)throw new Error("Features and labels should have the same length");if(t.length<2)throw new Error("Cannot train with less than 2 observations");if(this._trained=!1,this._loaded=!1,this.N=e.length,this.D=t[0].length,this.options.whitening){this.X=new Array(this.N);for(var r=0;r<this.N;r++)this.X[r]=new Array(this.D);this.minMax=new Array(this.D);for(var n=0;n<this.D;n++){var o=new Array(this.N);for(r=0;r<this.N;r++)o[r]=t[r][n];for(this.minMax[n]=i.minMax(o),r=0;r<this.N;r++)this.X[r][n]=(t[r][n]-this.minMax[n].min)/(this.minMax[n].max-this.minMax[n].min)}}else this.X=t;this.Y=e,this.b=0,this.W=void 0;var s=this.kernel.compute(this.X),a=e.length,u=new Array(a).fill(0);this.alphas=u;for(var h=0;h<a;h++)u[h]=0;for(var l=0,c=0,f=0,d=0,m=0,g=0,p=0,v=0,w=0,y=0,x=0;d<this.options.maxPasses&&f<this.options.maxIterations;){var M=0;for(r=0;r<a;r++)if(m=this._marginOnePrecomputed(r,s)-e[r],e[r]*m<-this.options.tol&&u[r]<this.options.C||e[r]*m>this.options.tol&&u[r]>0){for(n=r;n===r;)n=Math.floor(this.options.random()*a);if(g=this._marginOnePrecomputed(n,s)-e[n],p=u[r],v=u[n],e[r]===e[n]?(w=Math.max(0,p+v-this.options.C),y=Math.min(this.options.C,p+v)):(w=Math.max(0,v-p),y=Math.min(this.options.C,this.options.C+v+p)),Math.abs(w-y)<1e-4)continue;if((x=2*s[r][n]-s[r][r]-s[n][n])>=0)continue;var b=u[n]-e[n]*(m-g)/x;if(b>y?b=y:b<w&&(b=w),Math.abs(v-b)<.001)continue;u[n]=b,u[r]=u[r]+e[r]*e[n]*(v-b),l=this.b-m-e[r]*(u[r]-p)*s[r][r]-e[n]*(u[n]-v)*s[r][n],c=this.b-g-e[r]*(u[r]-p)*s[r][n]-e[n]*(u[n]-v)*s[n][n],this.b=(l+c)/2,u[r]<this.options.C&&u[r]>0&&(this.b=l),u[n]<this.options.C&&u[n]>0&&(this.b=c),M+=1}f++,0===M?d+=1:d=0}if(f===this.options.maxIterations)throw new Error("max iterations reached");if(this.iterations=f,"linear"===this.options.kernel){this.W=new Array(this.D);for(var A=0;A<this.D;A++){this.W[A]=0;for(var S=0;S<a;S++)this.W[A]+=e[S]*u[S]*this.X[S][A]}}var _=[],R=[],E=[];for(this._supportVectorIdx=[],r=0;r<this.N;r++)this.alphas[r]>this.options.alphaTol&&(_.push(this.X[r]),R.push(e[r]),E.push(this.alphas[r]),this._supportVectorIdx.push(r));this.X=_,this.Y=R,this.N=_.length,this.alphas=E,this._trained=!0},s.prototype.predictOne=function(t){return this.marginOne(t)>0?1:-1},s.prototype.predict=function(t){if(!this._trained&&!this._loaded)throw new Error("Cannot predict, you need to train the SVM first");return Array.isArray(t)&&Array.isArray(t[0])?t.map(this.predictOne.bind(this)):this.predictOne(t)},s.prototype.marginOne=function(t,e){this.options.whitening&&!e&&(t=this._applyWhitening(t));var r,n=this.b;if("linear"===this.options.kernel&&this.W)for(r=0;r<this.W.length;r++)n+=this.W[r]*t[r];else for(r=0;r<this.N;r++)n+=this.alphas[r]*this.Y[r]*this.kernel.compute([t],[this.X[r]])[0][0];return n},s.prototype._marginOnePrecomputed=function(t,e){var r,n=this.b;for(r=0;r<this.N;r++)n+=this.alphas[r]*this.Y[r]*e[t][r];return n},s.prototype.margin=function(t){return Array.isArray(t)?t.map(this.marginOne.bind(this)):this.marginOne(t)},s.prototype.supportVectors=function(){if(!this._trained&&!this._loaded)throw new Error("Cannot get support vectors, you need to train the SVM first");if(this._loaded&&"linear"===this.options.kernel)throw new Error("Cannot get support vectors from saved linear model, you need to train the SVM to have them");return this._supportVectorIdx},s.load=function(t){this._loaded=!0,this._trained=!1;var e=new s(t.options);return"linear"===t.options.kernel?(e.W=t.W.slice(),e.D=e.W.length):(e.X=t.X.slice(),e.Y=t.Y.slice(),e.alphas=t.alphas.slice(),e.N=e.X.length,e.D=e.X[0].length),e.minMax=t.minMax,e.b=t.b,e._loaded=!0,e._trained=!1,e},s.prototype.toJSON=function(){if(!this._trained&&!this._loaded)throw new Error("Cannot export, you need to train the SVM first");var t={};return t.options=Object.assign({},this.options),t.b=this.b,t.minMax=this.minMax,"linear"===t.options.kernel?t.W=this.W.slice():(t.X=this.X.slice(),t.Y=this.Y.slice(),t.alphas=this.alphas.slice()),t},s.prototype._applyWhitening=function(t){if(!this.minMax)throw new Error("Could not apply whitening");for(var e=new Array(t.length),r=0;r<t.length;r++)e[r]=(t[r]-this.minMax[r].min)/(this.minMax[r].max-this.minMax[r].min);return e},t.exports=s},function(t,e,r){"use strict";var n=r(1).squared,i={sigma:1};t.exports=class{constructor(t){t=Object.assign({},i,t),this.sigma=t.sigma,this.divisor=2*t.sigma*t.sigma}compute(t,e){var r=n(t,e);return Math.exp(-r/this.divisor)}}},function(t,e,r){"use strict";var n={degree:1,constant:1,scale:1};t.exports=class{constructor(t){t=Object.assign({},n,t),this.degree=t.degree,this.constant=t.constant,this.scale=t.scale}compute(t,e){for(var r=0,n=0;n<t.length;n++)r+=t[n]*e[n];return Math.pow(this.scale*r+this.constant,this.degree)}}},function(t,e,r){"use strict";var n={sigma:1,degree:1};t.exports=class{constructor(t){t=Object.assign({},n,t),this.sigma=t.sigma,this.degree=t.degree}compute(t,e){for(var r=0,n=Math.min(t.length,e.length),i=1;i<=n;++i)r+=Math.pow(Math.exp(-this.sigma*Math.pow(Math.pow(t[i-1],i)-Math.pow(e[i-1],i),2)),this.degree);return r}}},function(t,e,r){"use strict";var n=r(1).squared,i={sigma:1};t.exports=class{constructor(t){t=Object.assign({},i,t),this.sigma=t.sigma}compute(t,e){return 1/(1+n(t,e)/(this.sigma*this.sigma))}}},function(t,e,r){"use strict";var n=r(1),i={sigma:1};t.exports=class{constructor(t){t=Object.assign({},i,t),this.sigma=t.sigma,this.divisor=2*t.sigma*t.sigma}compute(t,e){var r=n(t,e);return Math.exp(-r/this.divisor)}}},function(t,e,r){"use strict";t.exports=class{compute(t,e){for(var r=Math.min(t.length,e.length),n=0,i=0;i<r;++i)n+=Math.min(t[i],e[i]);return n}}},function(t,e,r){"use strict";var n=r(1),i={sigma:1};t.exports=class{constructor(t){t=Object.assign({},i,t),this.sigma=t.sigma}compute(t,e){var r=n(t,e);return Math.exp(-r/this.sigma)}}},function(t,e,r){"use strict";var n=r(1).squared,i={constant:1};t.exports=class{constructor(t){t=Object.assign({},i,t),this.constant=t.constant}compute(t,e){return Math.sqrt(n(t,e)+this.constant*this.constant)}}},function(t,e,r){"use strict";var n=r(1).squared,i={constant:1};t.exports=class{constructor(t){t=Object.assign({},i,t),this.constant=t.constant}compute(t,e){var r=n(t,e);return 1-r/(r+this.constant)}}},function(t,e,r){"use strict";var n={alpha:.01,constant:-Math.E};t.exports=class{constructor(t){t=Object.assign({},n,t),this.alpha=t.alpha,this.constant=t.constant}compute(t,e){for(var r=0,n=0;n<t.length;n++)r+=t[n]*e[n];return Math.tanh(this.alpha*r+this.constant)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(108);Object.defineProperty(e,"GaussianNB",{enumerable:!0,get:function(){return n.GaussianNB}});var i=r(109);Object.defineProperty(e,"MultinomialNB",{enumerable:!0,get:function(){return i.MultinomialNB}})},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GaussianNB=void 0;var n=s(r(0)),i=s(r(4)),o=r(30);function s(t){return t&&t.__esModule?t:{default:t}}class a{constructor(t,e){t&&(this.means=e.means,this.calculateProbabilities=e.calculateProbabilities)}train(t,e){var r=Math.sqrt(2*Math.PI);if((t=n.default.checkMatrix(t)).rows!==e.length)throw new RangeError("the size of the training set and the training labels must be the same.");var s=(0,o.separateClasses)(t,e),a=new Array(s.length);this.means=new Array(s.length);for(var u=0;u<s.length;++u){var h=i.default.matrix.mean(s[u]),l=i.default.matrix.standardDeviation(s[u],h),c=Math.log(s[u].rows/t.rows);a[u]=new Array(h.length+1),a[u][0]=c;for(var f=1;f<h.length+1;++f){var d=l[f-1];a[u][f]=[1/(r*d),-2*d*d]}this.means[u]=h}this.calculateProbabilities=a}predict(t){if(t[0].length===this.calculateProbabilities[0].length)throw new RangeError("the dataset must have the same features as the training set");for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=u(t[r],this.means,this.calculateProbabilities);return e}toJSON(){return{modelName:"NaiveBayes",means:this.means,calculateProbabilities:this.calculateProbabilities}}static load(t){if("NaiveBayes"!==t.modelName)throw new RangeError("The current model is not a Multinomial Naive Bayes, current model:",t.name);return new a(!0,t)}}function u(t,e,r){for(var n=0,i=-1,o=0;o<r.length;++o){for(var s=r[o][0],a=1;a<r[0][1].length+1;++a)s+=h(t[a-1],e[o][a-1],r[o][a][0],r[o][a][1]);(s=Math.exp(s))>n&&(n=s,i=o)}return i}function h(t,e,r,n){return t-=e,Math.log(r*Math.exp(t*t/n))}e.GaussianNB=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MultinomialNB=void 0;var n=function(t){return t&&t.__esModule?t:{default:t}}(r(0)),i=r(30);class o{constructor(t){t&&(this.conditionalProbability=n.default.checkMatrix(t.conditionalProbability),this.priorProbability=n.default.checkMatrix(t.priorProbability))}train(t,e){if((t=n.default.checkMatrix(t)).rows!==e.length)throw new RangeError("the size of the training set and the training labels must be the same.");var r=(0,i.separateClasses)(t,e);this.priorProbability=new n.default(r.length,1);for(var o=0;o<r.length;++o)this.priorProbability[o][0]=Math.log(r[o].length/t.rows);var a=t.columns;for(this.conditionalProbability=new n.default(r.length,a),o=0;o<r.length;++o){var u=n.default.checkMatrix(r[o]),h=u.sum()+a;this.conditionalProbability.setRow(o,u.sum("column").add(1).div(h).apply(s))}}predict(t){t=n.default.checkMatrix(t);for(var e=new Array(t.rows),r=0;r<t.rows;++r){var i=t.getRowVector(r);e[r]=this.conditionalProbability.clone().mulRowVector(i).sum("row").add(this.priorProbability).maxIndex()[0]}return e}toJSON(){return{name:"MultinomialNB",priorProbability:this.priorProbability,conditionalProbability:this.conditionalProbability}}static load(t){if("MultinomialNB"!==t.name)throw new RangeError(`${t.name} is not a Multinomial Naive Bayes`);return new o(t)}}function s(t,e){this[t][e]=Math.log(this[t][e])}e.MultinomialNB=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(r(111)),i=o(r(1));function o(t){return t&&t.__esModule?t:{default:t}}class s{constructor(t,e,r={}){if(!0===t){var o=e;return this.kdTree=new n.default(o.kdTree,r),this.k=o.k,this.classes=new Set(o.classes),void(this.isEuclidean=o.isEuclidean)}for(var s=new Set(e),a=r.distance,u=void 0===a?i.default:a,h=r.k,l=void 0===h?s.size+1:h,c=new Array(t.length),f=0;f<c.length;++f)c[f]=t[f].slice();for(f=0;f<e.length;++f)c[f].push(e[f]);this.kdTree=new n.default(c,u),this.k=l,this.classes=s,this.isEuclidean=u===i.default}static load(t,e=i.default){if("KNN"!==t.name)throw new Error("invalid model: "+t.name);if(!t.isEuclidean&&e===i.default)throw new Error("a custom distance function was used to create the model. Please provide it again");if(t.isEuclidean&&e!==i.default)throw new Error("the model was created with the default distance function. Do not load it with another one");return new s(!0,t,e)}toJSON(){return{name:"KNN",kdTree:this.kdTree,k:this.k,classes:Array.from(this.classes),isEuclidean:this.isEuclidean}}predict(t){if(Array.isArray(t)){if("number"==typeof t[0])return a(this,t);if(Array.isArray(t[0])&&"number"==typeof t[0][0]){for(var e=new Array(t.length),r=0;r<t.length;r++)e[r]=a(this,t[r]);return e}}throw new TypeError("dataset to predict must be an array or a matrix")}}function a(t,e){var r=t.kdTree.nearest(e,t.k),n={},i=-1,o=-1,s=r[0][0].length-1;for(var a of t.classes)n[a]=0;for(var u=0;u<r.length;++u){var h=r[u][0][s],l=++n[h];l>o&&(i=h,o=l)}return i}e.default=s},function(t,e,r){"use strict";
/*
* Original code from:
*
* k-d Tree JavaScript - V 1.01
*
* https://github.com/ubilabs/kd-tree-javascript
*
* @author Mircea Pricop <[email protected]>, 2012
* @author Martin Kleppe <[email protected]>, 2012
* @author Ubilabs http://ubilabs.net, 2012
* @license MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
function n(t,e,r){this.obj=t,this.left=null,this.right=null,this.parent=r,this.dimension=e}Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t,e){if(Array.isArray(t)){this.dimensions=new Array(t[0].length);for(var r=0;r<this.dimensions.length;r++)this.dimensions[r]=r;this.root=function t(e,r,i,o){var s=r%o.length;if(0===e.length)return null;if(1===e.length)return new n(e[0],s,i);e.sort((t,e)=>t[o[s]]-e[o[s]]);var a=Math.floor(e.length/2),u=new n(e[a],s,i);return u.left=t(e.slice(0,a),r+1,u,o),u.right=t(e.slice(a+1),r+1,u,o),u}(t,0,null,this.dimensions)}else this.dimensions=t.dimensions,this.root=t,function t(e){e.left&&(e.left.parent=e,t(e.left)),e.right&&(e.right.parent=e,t(e.right))}(this.root);this.metric=e}toJSON(){var t=function t(e){var r=new n(e.obj,e.dimension,null);return e.left&&(r.left=t(e.left)),e.right&&(r.right=t(e.right)),r}(this.root);return t.dimensions=this.dimensions,t}nearest(t,e,r){var n,o=this.metric,s=this.dimensions,a=new i(function(t){return-t[1]});if(r)for(n=0;n<e;n+=1)a.push([null,r]);this.root&&function r(n){var i,u,h,l,c=s[n.dimension],f=o(t,n.obj),d={};function m(t,r){a.push([t,r]),a.size()>e&&a.pop()}for(l=0;l<s.length;l+=1)l===n.dimension?d[s[l]]=t[s[l]]:d[s[l]]=n.obj[s[l]];u=o(d,n.obj),null!==n.right||null!==n.left?(r(i=null===n.right?n.left:null===n.left?n.right:t[c]<n.obj[c]?n.left:n.right),(a.size()<e||f<a.peek()[1])&&m(n,f),(a.size()<e||Math.abs(u)<a.peek()[1])&&null!==(h=i===n.left?n.right:n.left)&&r(h)):(a.size()<e||f<a.peek()[1])&&m(n,f)}(this.root);var u=[];for(n=0;n<Math.min(e,a.content.length);n+=1)a.content[n][0]&&u.push([a.content[n][0].obj,a.content[n][1]]);return u}};class i{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}pop(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t}peek(){return this.content[0]}size(){return this.content.length}bubbleUp(t){for(var e=this.content[t];t>0;){var r=Math.floor((t+1)/2)-1,n=this.content[r];if(!(this.scoreFunction(e)<this.scoreFunction(n)))break;this.content[r]=e,this.content[t]=n,t=r}}sinkDown(t){for(var e=this.content.length,r=this.content[t],n=this.scoreFunction(r);;){var i=2*(t+1),o=i-1,s=null;if(o<e){var a=this.content[o],u=this.scoreFunction(a);u<n&&(s=o)}if(i<e){var h=this.content[i];this.scoreFunction(h)<(null===s?n:u)&&(s=i)}if(null===s)break;this.content[t]=this.content[s],this.content[s]=r,t=s}}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(113);Object.defineProperty(e,"PLS",{enumerable:!0,get:function(){return n.PLS}});var i=r(114);Object.defineProperty(e,"KOPLS",{enumerable:!0,get:function(){return i.KOPLS}})},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PLS=void 0;var n=s(r(0)),i=s(r(9)),o=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(r(31));function s(t){return t&&t.__esModule?t:{default:t}}class a{constructor(t,e){if(!0===t)this.meanX=e.meanX,this.stdDevX=e.stdDevX,this.meanY=e.meanY,this.stdDevY=e.stdDevY,this.PBQ=n.default.checkMatrix(e.PBQ),this.R2X=e.R2X,this.scale=e.scale,this.scaleMethod=e.scaleMethod,this.tolerance=e.tolerance;else{var r=t.tolerance,i=void 0===r?1e-5:r,o=t.scale,s=void 0===o||o;this.tolerance=i,this.scale=s,this.latentVectors=t.latentVectors}}train(t,e){if(t=n.default.checkMatrix(t),e=n.default.checkMatrix(e),t.length!==e.length)throw new RangeError("The number of X rows must be equal to the number of Y rows");this.meanX=i.default.mean(t),this.stdDevX=i.default.standardDeviation(t,this.meanX,!0),this.meanY=i.default.mean(e),this.stdDevY=i.default.standardDeviation(e,this.meanY,!0),this.scale&&(t=t.clone().subRowVector(this.meanX).divRowVector(this.stdDevX),e=e.clone().subRowVector(this.meanY).divRowVector(this.stdDevY)),void 0===this.latentVectors&&(this.latentVectors=Math.min(t.length-1,t[0].length));for(var r=t.rows,s=t.columns,a=e.rows,h=e.columns,l=t.clone().mul(t).sum(),c=e.clone().mul(e).sum(),f=this.tolerance,d=this.latentVectors,m=n.default.zeros(r,d),g=n.default.zeros(s,d),p=n.default.zeros(a,d),v=n.default.zeros(h,d),w=n.default.zeros(d,d),y=g.clone(),x=0;o.norm(e)>f&&x<d;){for(var M=t.transpose(),b=e.transpose(),A=u(t.clone().mulM(t)),S=u(e.clone().mulM(e)),_=t.getColumnVector(A),R=e.getColumnVector(S),E=n.default.zeros(r,1);o.norm(_.clone().sub(E))>f;){var O=M.mmul(R);O.div(o.norm(O)),E=_,_=t.mmul(O);var k=b.mmul(_);k.div(o.norm(k)),R=e.mmul(k)}E=_;var P=M.mmul(E),C=E.transpose().mmul(E)[0][0],j=P.div(C),T=o.norm(j);j.div(T),E.mul(T),O.mul(T),P=R.transpose().mmul(E),C=E.transpose().mmul(E)[0][0];var N=P.div(C)[0][0];t.sub(E.mmul(j.transpose())),e.sub(E.clone().mul(N).mmul(k.transpose())),m.setColumn(x,E),g.setColumn(x,j),p.setColumn(x,R),v.setColumn(x,k),y.setColumn(x,O),w[x][x]=N,x++}x--,m=m.subMatrix(0,m.rows-1,0,x),g=g.subMatrix(0,g.rows-1,0,x),p=p.subMatrix(0,p.rows-1,0,x),v=v.subMatrix(0,v.rows-1,0,x),y=y.subMatrix(0,y.rows-1,0,x),w=w.subMatrix(0,x,0,x),this.ssqYcal=c,this.E=t,this.F=e,this.T=m,this.P=g,this.U=p,this.Q=v,this.W=y,this.B=w,this.PBQ=g.mmul(w).mmul(v.transpose()),this.R2X=E.transpose().mmul(E).mmul(j.transpose().mmul(j)).div(l)[0][0]}predict(t){var e=n.default.checkMatrix(t);this.scale&&(e=e.subRowVector(this.meanX).divRowVector(this.stdDevX));var r=e.mmul(this.PBQ);return r=r.mulRowVector(this.stdDevY).addRowVector(this.meanY)}getExplainedVariance(){return this.R2X}toJSON(){return{name:"PLS",R2X:this.R2X,meanX:this.meanX,stdDevX:this.stdDevX,meanY:this.meanY,stdDevY:this.stdDevY,PBQ:this.PBQ,tolerance:this.tolerance,scale:this.scale}}static load(t){if("PLS"!==t.name)throw new RangeError("Invalid model: "+t.name);return new a(!0,t)}}function u(t){return t.sum("column").maxIndex()[0]}e.PLS=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.KOPLS=void 0;var n=r(0),i=r(31);class o{constructor(t,e){if(!0===t)this.trainingSet=new n.Matrix(e.trainingSet),this.YLoadingMat=new n.Matrix(e.YLoadingMat),this.SigmaPow=new n.Matrix(e.SigmaPow),this.YScoreMat=new n.Matrix(e.YScoreMat),this.predScoreMat=(0,i.initializeMatrices)(e.predScoreMat,!1),this.YOrthLoadingVec=(0,i.initializeMatrices)(e.YOrthLoadingVec,!1),this.YOrthEigen=e.YOrthEigen,this.YOrthScoreMat=(0,i.initializeMatrices)(e.YOrthScoreMat,!1),this.toNorm=(0,i.initializeMatrices)(e.toNorm,!1),this.TURegressionCoeff=(0,i.initializeMatrices)(e.TURegressionCoeff,!1),this.kernelX=(0,i.initializeMatrices)(e.kernelX,!0),this.kernel=e.kernel,this.orthogonalComp=e.orthogonalComp,this.predictiveComp=e.predictiveComp;else{if(void 0===t.predictiveComponents)throw new RangeError("no predictive components found!");if(void 0===t.orthogonalComponents)throw new RangeError("no orthogonal components found!");if(void 0===t.kernel)throw new RangeError("no kernel found!");this.orthogonalComp=t.orthogonalComponents,this.predictiveComp=t.predictiveComponents,this.kernel=t.kernel}}train(t,e){t=n.Matrix.checkMatrix(t),e=n.Matrix.checkMatrix(e),this.trainingSet=t.clone();var r=this.kernel.compute(t),i=n.Matrix.eye(r.rows,r.rows,1),o=r;(r=new n.Matrix(this.orthogonalComp+1,this.orthogonalComp+1))[0][0]=o;var s=new n.SingularValueDecomposition(e.transpose().mmul(r[0][0]).mmul(e),{computeLeftSingularVectors:!0,computeRightSingularVectors:!1}),a=s.leftSingularVectors,u=s.diagonalMatrix;a=a.subMatrix(0,a.rows-1,0,this.predictiveComp-1),u=u.subMatrix(0,this.predictiveComp-1,0,this.predictiveComp-1);var h=e.mmul(a),l=new Array(this.orthogonalComp+1),c=new Array(this.orthogonalComp+1),f=new Array(this.orthogonalComp),d=new Array(this.orthogonalComp),m=new Array(this.orthogonalComp),g=new Array(this.orthogonalComp),p=n.Matrix.pow(u,-.5);p.apply(function(t,e){this[t][e]===1/0&&(this[t][e]=0)});for(var v=0;v<this.orthogonalComp;++v){l[v]=r[0][v].transpose().mmul(h).mmul(p);var w=l[v].transpose();c[v]=(0,n.inverse)(w.mmul(l[v])).mmul(w).mmul(h);var y=(s=new n.SingularValueDecomposition(w.mmul(n.Matrix.sub(r[v][v],l[v].mmul(w))).mmul(l[v]),{computeLeftSingularVectors:!0,computeRightSingularVectors:!1})).leftSingularVectors,x=s.diagonalMatrix;d[v]=y.subMatrix(0,y.rows-1,0,0),m[v]=x[0][0],f[v]=n.Matrix.sub(r[v][v],l[v].mmul(w)).mmul(l[v]).mmul(d[v]).mul(Math.pow(m[v],-.5));var M=f[v].transpose();g[v]=n.Matrix.sqrt(M.mmul(f[v])),f[v]=f[v].divRowVector(g[v]);var b=n.Matrix.sub(i,f[v].mmul(f[v].transpose()));r[0][v+1]=r[0][v].mmul(b),r[v+1][v+1]=b.mmul(r[v][v]).mmul(b)}var A=l[this.orthogonalComp]=r[0][this.orthogonalComp].transpose().mmul(h).mmul(p),S=A.transpose();c[this.orthogonalComp]=(0,n.inverse)(S.mmul(A)).mmul(S).mmul(h),this.YLoadingMat=a,this.SigmaPow=p,this.YScoreMat=h,this.predScoreMat=l,this.YOrthLoadingVec=d,this.YOrthEigen=m,this.YOrthScoreMat=f,this.toNorm=g,this.TURegressionCoeff=c,this.kernelX=r}predict(t){var e=this.kernel.compute(t,this.trainingSet),r=e;(e=new n.Matrix(this.orthogonalComp+1,this.orthogonalComp+1))[0][0]=r;var i,o=new Array(this.orthogonalComp),s=new Array(this.orthogonalComp);for(i=0;i<this.orthogonalComp;++i){s[i]=e[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow),o[i]=n.Matrix.sub(e[i][i],s[i].mmul(this.predScoreMat[i].transpose())).mmul(this.predScoreMat[i]).mmul(this.YOrthLoadingVec[i]).mul(Math.pow(this.YOrthEigen[i],-.5)),o[i]=o[i].divRowVector(this.toNorm[i]);var a=this.YOrthScoreMat[i].transpose();e[i+1][0]=n.Matrix.sub(e[i][0],o[i].mmul(a).mmul(this.kernelX[0][i].transpose()));var u=n.Matrix.sub(e[i][0],e[i][i].mmul(this.YOrthScoreMat[i]).mmul(a)),h=o[i].mmul(a).mmul(this.kernelX[i][i]),l=h.mmul(this.YOrthScoreMat[i]).mmul(a);e[i+1][i+1]=u.sub(h).add(l)}return s[i]=e[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow),{prediction:s[i].mmul(this.TURegressionCoeff[i]).mmul(this.YLoadingMat.transpose()),predScoreMat:s,predYOrthVectors:o}}toJSON(){return{name:"K-OPLS",YLoadingMat:this.YLoadingMat,SigmaPow:this.SigmaPow,YScoreMat:this.YScoreMat,predScoreMat:this.predScoreMat,YOrthLoadingVec:this.YOrthLoadingVec,YOrthEigen:this.YOrthEigen,YOrthScoreMat:this.YOrthScoreMat,toNorm:this.toNorm,TURegressionCoeff:this.TURegressionCoeff,kernelX:this.kernelX,trainingSet:this.trainingSet,orthogonalComp:this.orthogonalComp,predictiveComp:this.predictiveComp}}static load(t,e){if("K-OPLS"!==t.name)throw new RangeError("Invalid model: "+t.name);if(!e)throw new RangeError("You must provide a kernel for the model!");return t.kernel=e,new o(!0,t)}}e.KOPLS=o},function(t,e,r){"use strict";var n=r(32),i={},o=r(116);function s(t,e){if(t.length!==e.length)throw new Error("features and labels should have the same length")}function a(t,e){return new Array(t).fill(0).map(()=>new Array(e).fill(0))}function u(t){for(var e=new Set,r=0;r<t.length;r++)e.add(t[r]);return Array.from(e)}function h(t,e,r,n,i,o,s,a){var u,h=f(e,r,i,o),l=h.testFeatures,d=h.trainFeatures,m=h.testLabels,g=h.trainLabels;t.prototype.train?(u=new t(n)).train(d,g):u=new t(d,g,n),c(s,m,u.predict(l),a)}function l(t,e,r,n,i,o,s){var a=f(t,e,r,n),u=a.testFeatures,h=a.trainFeatures;c(i,a.testLabels,s(h,a.trainLabels,u),o)}function c(t,e,r,n){for(var i=0;i<r.length;i++){var o=n.indexOf(e[i]),s=n.indexOf(r[i]);(o<0||s<0)&&console.warn(`ignore unknown predicted label ${r[i]}`),t[o][s]++}}function f(t,e,r,n){return{testFeatures:r.map(function(e){return t[e]}),trainFeatures:n.map(function(e){return t[e]}),testLabels:r.map(function(t){return e[t]}),trainLabels:n.map(function(t){return e[t]})}}i.leaveOneOut=function(t,e,r,n){if("function"==typeof r){var o=r;return r=e,e=t,i.leavePOut(e,r,1,o)}return i.leavePOut(t,e,r,n,1)},i.leavePOut=function(t,e,r,i,c){if("function"==typeof i){var f=i;c=r,r=e,e=t}s(e,r);for(var d=u(r),m=a(d.length,d.length),g=e.length,p=o(c,g),v=new Array(g),w=0;w<g;w++)v[w]=w;for(var y of p){for(var x=v.slice(),M=y.length-1;M>=0;M--)x.splice(y[M],1);f?l(e,r,y,x,m,d,f):h(t,e,r,i,y,x,m,d)}return new n(m,d)},i.kFold=function(t,e,r,i,o){if("function"==typeof i){var c=i;o=r,r=e,e=t}s(e,r);for(var f=u(r),d=a(f.length,f.length),m=e.length,g=new Array(m),p=0;p<m;p++)g[p]=p;for(var v=Math.floor(m/o),w=[],y=[];g.length;){var x=Math.floor(Math.random()*g.length);w.push(g[x]),g.splice(x,1),w.length===v&&(y.push(w),w=[])}for(w.length&&y.push(w),y=y.slice(0,o),p=0;p<y.length;p++){for(var M=y[p],b=[],A=0;A<y.length;A++)A!==p&&(b=b.concat(y[A]));c?l(e,r,M,b,d,f,c):h(t,e,r,i,M,b,d,f)}return new n(d,f)},t.exports=i},function(t,e,r){"use strict";!function(t,e){e()}(0,function(){var e=function(t,e){return t(e={exports:{}},e.exports),e.exports}(function(t){!function(e){var r,n=Object.prototype,i=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag",h=e.regeneratorRuntime;if(h)t.exports=h;else{(h=e.regeneratorRuntime=t.exports).wrap=y;var l="suspendedStart",c="suspendedYield",f="executing",d="completed",m={},g={};g[s]=function(){return this};var p=Object.getPrototypeOf,v=p&&p(p(P([])));v&&v!==n&&i.call(v,s)&&(g=v);var w=A.prototype=M.prototype=Object.create(g);b.prototype=w.constructor=A,A.constructor=b,A[u]=b.displayName="GeneratorFunction",h.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},h.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,A):(t.__proto__=A,u in t||(t[u]="GeneratorFunction")),t.prototype=Object.create(w),t},h.awrap=function(t){return{__await:t}},S(_.prototype),_.prototype[a]=function(){return this},h.AsyncIterator=_,h.async=function(t,e,r,n){var i=new _(y(t,e,r,n));return h.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},S(w),w[u]="Generator",w[s]=function(){return this},w.toString=function(){return"[object Generator]"},h.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},h.values=P,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return a.type="throw",a.arg=t,e.next=n,i&&(e.method="next",e.arg=r),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var u=i.call(s,"catchLoc"),h=i.call(s,"finallyLoc");if(u&&h){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:P(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),m}}}function y(t,e,r,n){var i=e&&e.prototype instanceof M?e:M,o=Object.create(i.prototype),s=new k(n||[]);return o._invoke=function(t,e,r){var n=l;return function(i,o){if(n===f)throw new Error("Generator is already running");if(n===d){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=R(s,r);if(a){if(a===m)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var u=x(t,e,r);if("normal"===u.type){if(n=r.done?d:c,u.arg===m)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=d,r.method="throw",r.arg=u.arg)}}}(t,r,s),o}function x(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function M(){}function b(){}function A(){}function S(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function _(t){var e;this._invoke=function(r,n){function o(){return new Promise(function(e,o){!function e(r,n,o,s){var a=x(t[r],t,n);if("throw"!==a.type){var u=a.arg,h=u.value;return h&&"object"==typeof h&&i.call(h,"__await")?Promise.resolve(h.__await).then(function(t){e("next",t,o,s)},function(t){e("throw",t,o,s)}):Promise.resolve(h).then(function(t){u.value=t,o(u)},s)}s(a.arg)}(r,n,e,o)})}return e=e?e.then(o,o):o()}}function R(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,R(t,e),"throw"===e.method))return m;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var i=x(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,m):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function P(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(i.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=r,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:r,done:!0}}}(function(){return this}()||Function("return this")())}),r=function(){return this}()||Function("return this")(),n=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,i=n&&r.regeneratorRuntime;r.regeneratorRuntime=void 0;var o=e;if(n)r.regeneratorRuntime=i;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}var s=o,a={mode:"index"};t.exports=s.mark(function t(e,r,n){var i,o,u,h,l,c,f,d,m;return s.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(m=function(){var t,e,r;for(e=1;h[e]<=0;)e++;if(0===h[e-1]){for(t=e-1;1!==t;t--)h[t]=-1;h[e]=0,l=f=0,h[1]=1,c=e-1}else{e>1&&(h[e-1]=0);do{e++}while(h[e]>0);for(r=e-1,t=e;0===h[t];)h[t++]=-1;if(-1===h[t])h[t]=h[r],f=h[r]-1,l=t-1,c=r-1,h[r]=-1;else{if(t===h[0])return 0;h[e]=h[t],f=h[t]-1,h[t]=0,l=e-1,c=t-1}}return 1},n=Object.assign({},a,n),i=new Array(r),o=new Array(e),u=new Array(r),h=new Array(r+2),d=0;d<r;d++)i[d]=d,u[d]=d<r-e?0:1;for(d=0;d<e;d++)o[d]=r-e+d;for(d=0;d<h.length;d++)h[d]=0===d?r+1:d<=r-e?0:d<=r?d-r+e:-2;if("index"!==n.mode){t.next=20;break}return t.next=12,o.slice();case 12:if(!m()){t.next=18;break}return o[f]=i[l],t.next=16,o.slice();case 16:t.next=12;break;case 18:t.next=33;break;case 20:if("mask"!==n.mode){t.next=32;break}return t.next=23,u.slice();case 23:if(!m()){t.next=30;break}return u[l]=1,u[c]=0,t.next=28,u.slice();case 28:t.next=23;break;case 30:t.next=33;break;case 32:throw new Error("Invalid mode");case 33:case"end":return t.stop()}},t,this)})})},function(t,e,r){"use strict";var n=r(0).Matrix,i=r(33),o=r(118),s=r(34),a=r(35);class u{constructor(t){if((t=t||{}).model){this.hiddenLayers=t.hiddenLayers,this.iterations=t.iterations,this.learningRate=t.learningRate,this.regularization=t.regularization,this.dicts=t.dicts,this.activation=t.activation,this.activationParam=t.activationParam,this.model=new Array(t.layers.length);for(var e=0;e<this.model.length-1;++e)this.model[e]=i.load(t.layers[e]);this.model[this.model.length-1]=o.load(t.layers[this.model.length-1])}else this.hiddenLayers=t.hiddenLayers||[10],this.iterations=t.iterations||50,this.learningRate=t.learningRate||.01,this.regularization=t.regularization||.01,this.activation=t.activation||"tanh",this.activationParam=t.activationParam||1,this.activation in Object.keys(a)||(this.activation="tanh")}buildNetwork(t,e){var r=this.hiddenLayers.length-1+2;this.model=new Array(r),this.model[0]=new i({inputSize:t,outputSize:this.hiddenLayers[0],activation:this.activation,activationParam:this.activationParam,regularization:this.regularization,epsilon:this.learningRate});for(var n=1;n<this.hiddenLayers.length;++n)this.model[n]=new i({inputSize:this.hiddenLayers[n-1],outputSize:this.hiddenLayers[n],activation:this.activation,activationParam:this.activationParam,regularization:this.regularization,epsilon:this.learningRate});this.model[r-1]=new o({inputSize:this.hiddenLayers[this.hiddenLayers.length-1],outputSize:e,activation:this.activation,activationParam:this.activationParam,regularization:this.regularization,epsilon:this.learningRate})}train(t,e){t=n.checkMatrix(t),this.dicts=s.dictOutputs(e);var r=t.columns,i=Object.keys(this.dicts.inputs).length;this.buildNetwork(r,i);for(var o=0;o<this.iterations;++o){var a=this.propagate(t);this.backpropagation(t,e,a)}}propagate(t){for(var e=t,r=0;r<this.model.length;++r)e=this.model[r].forward(e);return e.divColumnVector(s.sumRow(e))}backpropagation(t,e,r){for(var n=0;n<r.length;++n)r[n][this.dicts.inputs[e[n]]]-=1;var i=r;for(n=this.model.length-1;n>=0;--n){var o=n>0?this.model[n-1].a:t;i=this.model[n].backpropagation(i,o)}for(n=0;n<this.model.length;++n)this.model[n].update()}predict(t){t=n.checkMatrix(t);for(var e=new Array(t.rows),r=this.propagate(t),i=0;i<t.rows;++i)e[i]=this.dicts.outputs[r.maxRowIndex(i)[1]];return e}toJSON(){for(var t={model:"FNN",hiddenLayers:this.hiddenLayers,iterations:this.iterations,learningRate:this.learningRate,regularization:this.regularization,activation:this.activation,activationParam:this.activationParam,dicts:this.dicts,layers:new Array(this.model.length)},e=0;e<this.model.length;++e)t.layers[e]=this.model[e].toJSON();return t}static load(t){if("FNN"!==t.model)throw new RangeError("the current model is not a feed forward network");return new u(t)}}t.exports=u},function(t,e,r){"use strict";var n=r(33);class i extends n{constructor(t){super(t),this.activationFunction=function(t,e){this[t][e]=Math.exp(this[t][e])}}static load(t){if("Layer"!==t.model)throw new RangeError("the current model is not a Layer model");return new i(t)}}t.exports=i},function(module,exports,__webpack_require__){"use strict";var NodeSquare=__webpack_require__(36),NodeHexagonal=__webpack_require__(120),defaultOptions={fields:3,randomizer:Math.random,distance:squareEuclidean,iterations:10,learningRate:.1,gridType:"rect",torus:!0,method:"random"};function SOM(t,e,r,n){for(var i in this.x=t,this.y=e,r=r||{},this.options={},defaultOptions)r.hasOwnProperty(i)?this.options[i]=r[i]:this.options[i]=defaultOptions[i];if("number"==typeof this.options.fields)this.numWeights=this.options.fields;else{if(!Array.isArray(this.options.fields))throw new Error("Invalid fields definition");this.numWeights=this.options.fields.length;var o=getConverters(this.options.fields);this.extractor=o.extractor,this.creator=o.creator}if("rect"===this.options.gridType)this.nodeType=NodeSquare,this.gridDim={x:t,y:e};else{this.nodeType=NodeHexagonal;var s=this.x-Math.floor(this.y/2);this.gridDim={x:s,y:this.y,z:-(0-s-this.y)}}if(this.torus=this.options.torus,this.distanceMethod=this.torus?"getDistanceTorus":"getDistance",this.distance=this.options.distance,this.maxDistance=getMaxDistance(this.distance,this.numWeights),!0!==n){if(!(t>0&&e>0))throw new Error("x and y must be positive");this.times={findBMU:0,adjust:0},this.randomizer=this.options.randomizer,this.iterationCount=0,this.iterations=this.options.iterations,this.startLearningRate=this.learningRate=this.options.learningRate,this.mapRadius=Math.floor(Math.max(t,e)/2),this.algorithmMethod=this.options.method,this._initNodes(),this.done=!1}else this.done=!0}function getConverters(t){for(var e=t.length,r=new Array(e),n=new Array(e),i=0;i<e;i++)r[i]=getNormalizer(t[i].range),n[i]=getDenormalizer(t[i].range);return{extractor:function(n){for(var i=new Array(e),o=0;o<e;o++)i[o]=r[o](n[t[o].name]);return i},creator:function(r){for(var i={},o=0;o<e;o++)i[t[o].name]=n[o](r[o]);return i}}}function getNormalizer(t){return function(e){return(e-t[0])/(t[1]-t[0])}}function getDenormalizer(t){return function(e){return t[0]+e*(t[1]-t[0])}}function squareEuclidean(t,e){for(var r=0,n=0,i=t.length;n<i;n++)r+=(t[n]-e[n])*(t[n]-e[n]);return r}function getRandomValue(t,e){return t[Math.floor(e()*t.length)]}function getMaxDistance(t,e){for(var r=new Array(e),n=new Array(e),i=0;i<e;i++)r[i]=0,n[i]=1;return t(r,n)}SOM.load=function loadModel(model,distance){if("SOM"===model.name){var x=model.data.length,y=model.data[0].length;distance?model.options.distance=distance:model.options.distance&&(model.options.distance=eval("("+model.options.distance+")"));var som=new SOM(x,y,model.options,!0);som.nodes=new Array(x);for(var i=0;i<x;i++){som.nodes[i]=new Array(y);for(var j=0;j<y;j++)som.nodes[i][j]=new som.nodeType(i,j,model.data[i][j],som)}return som}throw new Error("expecting a SOM model")},SOM.prototype.export=function(t){if(!this.done)throw new Error("model is not ready yet");var e={name:"SOM"};e.options={fields:this.options.fields,gridType:this.options.gridType,torus:this.options.torus},e.data=new Array(this.x);for(var r=0;r<this.x;r++){e.data[r]=new Array(this.y);for(var n=0;n<this.y;n++)e.data[r][n]=this.nodes[r][n].weights}return t&&(e.options.distance=this.distance.toString()),e},SOM.prototype._initNodes=function(){var t,e,r,n=Date.now();for(this.nodes=new Array(this.x),t=0;t<this.x;t++)for(this.nodes[t]=new Array(this.y),e=0;e<this.y;e++){var i=new Array(this.numWeights);for(r=0;r<this.numWeights;r++)i[r]=this.randomizer();this.nodes[t][e]=new this.nodeType(t,e,i,this)}this.times.initNodes=Date.now()-n},SOM.prototype.setTraining=function(t){if(this.trainingSet)throw new Error("training set has already been set");var e,r=Date.now(),n=t,i=t.length;if(this.extractor)for(n=new Array(i),e=0;e<i;e++)n[e]=this.extractor(t[e]);this.numIterations=this.iterations*i,"random"===this.algorithmMethod?this.timeConstant=this.numIterations/Math.log(this.mapRadius):this.timeConstant=i/Math.log(this.mapRadius),this.trainingSet=n,this.times.setTraining=Date.now()-r},SOM.prototype.trainOne=function(){return!this.done&&(this.numIterations-- >0?("random"===this.algorithmMethod?(t=this.mapRadius*Math.exp(-this.iterationCount/this.timeConstant),e=getRandomValue(this.trainingSet,this.randomizer),this._adjust(e,t),this.learningRate=this.startLearningRate*Math.exp(-this.iterationCount/this.numIterations)):(r=-Math.floor(this.iterationCount/this.trainingSet.length),t=this.mapRadius*Math.exp(r/this.timeConstant),e=this.trainingSet[this.iterationCount%this.trainingSet.length],this._adjust(e,t),(this.iterationCount+1)%this.trainingSet.length==0&&(this.learningRate=this.startLearningRate*Math.exp(r/Math.floor(this.numIterations/this.trainingSet.length)))),this.iterationCount++,!0):(this.done=!0,!1));var t,e,r},SOM.prototype._adjust=function(t,e){var r,n,i,o,s=Date.now(),a=this._findBestMatchingUnit(t),u=Date.now();this.times.findBMU+=u-s;var h=Math.floor(e),l=a.x-h,c=a.x+h,f=a.y-h,d=a.y+h;for(r=l;r<=c;r++){var m=r;for(r<0?m+=this.x:r>=this.x&&(m-=this.x),n=f;n<=d;n++){var g=n;n<0?g+=this.y:n>=this.y&&(g-=this.y),(i=a[this.distanceMethod](this.nodes[m][g]))<e&&(o=Math.exp(-i/(2*e)),this.nodes[m][g].adjustWeights(t,this.learningRate,o))}}this.times.adjust+=Date.now()-u},SOM.prototype.train=function(t){if(!this.done)for(this.setTraining(t);this.trainOne(););},SOM.prototype.getConvertedNodes=function(){for(var t=new Array(this.x),e=0;e<this.x;e++){t[e]=new Array(this.y);for(var r=0;r<this.y;r++){var n=this.nodes[e][r];t[e][r]=this.creator?this.creator(n.weights):n.weights}}return t},SOM.prototype._findBestMatchingUnit=function(t){for(var e,r,n=1/0,i=0;i<this.x;i++)for(var o=0;o<this.y;o++)(r=this.distance(this.nodes[i][o].weights,t))<n&&(n=r,e=this.nodes[i][o]);return e},SOM.prototype.predict=function(t,e){if("boolean"==typeof t&&(e=t,t=null),t||(t=this.trainingSet),Array.isArray(t)&&(Array.isArray(t[0])||"object"==typeof t[0])){var r=this;return t.map(function(t){return r._predict(t,e)})}return this._predict(t,e)},SOM.prototype._predict=function(t,e){Array.isArray(t)||(t=this.extractor(t));var r=this._findBestMatchingUnit(t),n=[r.x,r.y];return e&&(n[2]=r.getPosition(t)),n},SOM.prototype.getQuantizationError=function(){for(var t=this.getFit(),e=t.length,r=0,n=0;n<e;n++)r+=t[n];return r/e},SOM.prototype.getFit=function(t){t||(t=this.trainingSet);for(var e,r=t.length,n=new Array(r),i=0;i<r;i++)e=this._findBestMatchingUnit(t[i]),n[i]=Math.sqrt(this.distance(t[i],e.weights));return n},module.exports=SOM},function(t,e,r){"use strict";var n=r(36);function i(t,e,r,i){n.call(this,t,e,r,i),this.hX=t-Math.floor(e/2),this.z=0-this.hX-e}i.prototype=new n,i.prototype.constructor=i,i.prototype.getDistance=function(t){return Math.max(Math.abs(this.hX-t.hX),Math.abs(this.y-t.y),Math.abs(this.z-t.z))},i.prototype.getDistanceTorus=function(t){var e=Math.abs(this.hX-t.hX),r=Math.abs(this.y-t.y),n=Math.abs(this.z-t.z);return Math.max(Math.min(e,this.som.gridDim.x-e),Math.min(r,this.som.gridDim.y-r),Math.min(n,this.som.gridDim.z-n))},i.prototype.getPosition=function(){throw new Error("Unimplemented : cannot get position of the points for hexagonal grid")},t.exports=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){return t<0?(t=0-t,"number"==typeof e?"- "+t.toPrecision(e):"- "+t.toString()):"number"==typeof e?t.toPrecision(e):t.toString()}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(!Array.isArray(t)||!Array.isArray(e))throw new TypeError("x and y must be arrays");if(t.length!==e.length)throw new RangeError("x and y arrays must have the same length")}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=s(n),o=s(r(15));function s(t){return t&&t.__esModule?t:{default:t}}class a extends i.default{constructor(t,e){super(),!0===t?(this.A=e.A,this.B=e.B):((0,n.checkArrayLength)(t,e),function(t,e,r){for(var n=e.length,i=new Array(n),s=0;s<n;s++)i[s]=Math.log(r[s]);var a=new o.default(e,i);t.A=a.slope,t.B=Math.exp(a.intercept)}(this,t,e))}_predict(t){return this.B*Math.exp(t*this.A)}toJSON(){return{name:"exponentialRegression",A:this.A,B:this.B}}toString(t){return"f(x) = "+(0,n.maybeToPrecision)(this.B,t)+" * e^("+(0,n.maybeToPrecision)(this.A,t)+" * x)"}toLaTeX(t){return this.A>=0?"f(x) = "+(0,n.maybeToPrecision)(this.B,t)+"e^{"+(0,n.maybeToPrecision)(this.A,t)+"x}":"f(x) = \\frac{"+(0,n.maybeToPrecision)(this.B,t)+"}{e^{"+(0,n.maybeToPrecision)(-this.A,t)+"x}}"}static load(t){if("exponentialRegression"!==t.name)throw new TypeError("not a exponential regression model");return new a(!0,t)}}e.default=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=s(n),o=s(r(15));function s(t){return t&&t.__esModule?t:{default:t}}class a extends i.default{constructor(t,e){super(),!0===t?(this.A=e.A,this.B=e.B):((0,n.checkArrayLength)(t,e),function(t,e,r){for(var n=e.length,i=new Array(n),s=new Array(n),a=0;a<n;a++)i[a]=Math.log(e[a]),s[a]=Math.log(r[a]);var u=new o.default(i,s);t.A=Math.exp(u.intercept),t.B=u.slope}(this,t,e))}_predict(t){return this.A*Math.pow(t,this.B)}toJSON(){return{name:"powerRegression",A:this.A,B:this.B}}toString(t){return"f(x) = "+(0,n.maybeToPrecision)(this.A,t)+" * x^"+(0,n.maybeToPrecision)(this.B,t)}toLaTeX(t){return this.B>=0?"f(x) = "+(0,n.maybeToPrecision)(this.A,t)+"x^{"+(0,n.maybeToPrecision)(this.B,t)+"}":"f(x) = \\frac{"+(0,n.maybeToPrecision)(this.A,t)+"}{x^{"+(0,n.maybeToPrecision)(-this.B,t)+"}}"}static load(t){if("powerRegression"!==t.name)throw new TypeError("not a power regression model");return new a(!0,t)}}e.default=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=s(n),o=s(r(2));function s(t){return t&&t.__esModule?t:{default:t}}class a extends o.default{constructor(t,e,r={}){var o=r.intercept,s=void 0===o||o,a=r.statistics,u=void 0===a||a;if(super(),this.statistics=u,!0===t)this.weights=e.weights,this.inputs=e.inputs,this.outputs=e.outputs,this.intercept=e.intercept;else{t=new i.default(t),s&&t.addColumn(new Array(t.length).fill(1));var h=new n.SVD(t,{autoTranspose:!0}).solve(e);if(this.weights=h.to2DArray(),this.inputs=t[0].length,this.outputs=e[0].length,s&&this.inputs--,this.intercept=s,u){var l=t.mmul(h),c=new i.default(e).addM(l.neg()).to2DArray().map(t=>Math.pow(t[0],2)).reduce((t,e)=>t+e)/(e.length-t.columns);this.stdError=Math.sqrt(c),this.stdErrorMatrix=t.transposeView().mmul(t).pseudoInverse().mul(c),this.stdErrors=this.stdErrorMatrix.diagonal().map(t=>Math.sqrt(t)),this.tStats=this.weights.map((t,e)=>0===this.stdErrors[e]?0:t[0]/this.stdErrors[e])}}}predict(t){if(Array.isArray(t)){if("number"==typeof t[0])return this._predict(t);if(Array.isArray(t[0])){for(var e=new Array(t.length),r=0;r<t.length;r++)e[r]=this._predict(t[r]);return e}}throw new TypeError("x must be a matrix or array of numbers")}_predict(t){var e=new Array(this.outputs);if(this.intercept)for(var r=0;r<this.outputs;r++)e[r]=this.weights[this.inputs][r];else e.fill(0);for(var n=0;n<this.inputs;n++)for(var i=0;i<this.outputs;i++)e[i]+=this.weights[n][i]*t[n];return e}score(){throw new Error("score method is not implemented yet")}toJSON(){return{name:"multivariateLinearRegression",weights:this.weights,inputs:this.inputs,outputs:this.outputs,intercept:this.intercept,summary:this.statistics?{regressionStatistics:{standardError:this.stdError,observations:this.outputs},variables:this.weights.map((t,e)=>({label:e===this.weights.length-1?"Intercept":`X Variable ${e+1}`,coefficients:t,standardError:this.stdErrors[e],tStat:this.tStats[e]}))}:void 0}}static load(t){if("multivariateLinearRegression"!==t.name)throw new Error("not a MLR model");return new a(!0,t)}}e.default=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=s(r(14)),o=s(r(2));function s(t){return t&&t.__esModule?t:{default:t}}var a={lambda:.1,kernelType:"gaussian",kernelOptions:{},computeCoefficient:!1};class u extends o.default{constructor(t,e,r){if(super(),!0===t)this.alpha=e.alpha,this.inputs=e.inputs,this.kernelType=e.kernelType,this.kernelOptions=e.kernelOptions,this.kernel=new i.default(e.kernelType,e.kernelOptions);else{r=Object.assign({},a,r);var o=new i.default(r.kernelType,r.kernelOptions),s=o.compute(t),u=t.length;s.add(n.Matrix.eye(u,u).mul(r.lambda)),this.alpha=(0,n.solve)(s,e),this.inputs=t,this.kernelType=r.kernelType,this.kernelOptions=r.kernelOptions,this.kernel=o}}_predict(t){return this.kernel.compute([t],this.inputs).mmul(this.alpha)[0]}toJSON(){return{name:"kernelRidgeRegression",alpha:this.alpha,inputs:this.inputs,kernelType:this.kernelType,kernelOptions:this.kernelOptions}}static load(t){if("kernelRidgeRegression"!==t.name)throw new TypeError("not a KRR model");return new u(!0,t)}}e.default=u},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=function(t){return t&&t.__esModule?t:{default:t}}(r(2));var o={order:2};class s extends i.default{constructor(t,e,r){super(),!0===t?(this.coefficients=n.Matrix.columnVector(e.coefficients),this.order=e.order,e.r&&(this.r=e.r,this.r2=e.r2),e.chi2&&(this.chi2=e.chi2)):(r=Object.assign({},o,r),this.order=r.order,this.coefficients=[],this.X=t,this.y=e,this.train(this.X,this.y,r))}train(t,e){if(n.Matrix.isMatrix(t)||(t=new n.Matrix(t)),n.Matrix.isMatrix(e)||(e=n.Matrix.columnVector(e)),e.rows!==t.rows&&(e=e.transpose()),2!==t.columns)throw new RangeError("You give X with "+t.columns+" columns and it must be 2");if(t.rows!==e.rows)throw new RangeError("X and y must have the same rows");var r=t.rows,i=(this.order+2)*(this.order+1)/2;this.coefficients=new Array(i);var o=t.getColumnVector(0),s=t.getColumnVector(1),h=1/o.clone().apply(u).max(),l=1/s.clone().apply(u).max(),c=1/e.clone().apply(u).max();o.mulColumn(0,h),s.mulColumn(0,l),e.mulColumn(0,c);for(var f=new n.Matrix(r,i),d=0,m=0;m<=this.order;++m)for(var g=this.order-m,p=0;p<=g;++p){var v=a(o,m).mulColumnVector(a(s,p));f.setColumn(d,v),d++}var w=new n.SVD(f.transpose(),{computeLeftSingularVectors:!0,computeRightSingularVectors:!0,autoTranspose:!1}),y=n.Matrix.rowVector(w.diagonal);y=y.apply(function(t,e){this[t][e]>=1e-15?this[t][e]=1/this[t][e]:this[t][e]=0});var x=n.Matrix.zeros(r,i);for(m=0;m<i;++m)x[m][m]=y[0][m];y=x;var M=w.rightSingularVectors,b=w.leftSingularVectors;for(this.coefficients=b.mmul(y.transpose()).mmul(M.transpose()).mmul(e),d=0,m=0;m<=i;++m)for(g=this.order-m,p=0;p<=g;++p)this.coefficients[d][0]=this.coefficients[d][0]*Math.pow(h,m)*Math.pow(l,p)/c,d++}_predict(t){for(var e=t[0],r=t[1],n=0,i=0,o=0;o<=this.order;o++)for(var s=0;s<=this.order-o;s++)n+=Math.pow(e,o)*Math.pow(r,s)*this.coefficients[i][0],i++;return n}toJSON(){return{name:"polyfit2D",order:this.order,coefficients:this.coefficients}}static load(t){if("polyfit2D"!==t.name)throw new TypeError("not a polyfit2D model");return new s(!0,t)}}function a(t,e){for(var r=t.clone(),n=0;n<t.rows;++n)r[n][0]=Math.pow(r[n][0],e);return r}function u(t,e){this[t][e]=Math.abs(this[t][e])}e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=function(t){return t&&t.__esModule?t:{default:t}}(n);var o=r(4).array.median;class s extends i.default{constructor(t,e){super(),!0===t?(this.slope=e.slope,this.intercept=e.intercept,this.coefficients=e.coefficients):((0,n.checkArrayLength)(t,e),function(t,e,r){for(var n=e.length,i=new Array(n*n),s=0,a=0;a<n;++a)for(var u=a+1;u<n;++u)e[a]!==e[u]&&(i[s++]=(r[u]-r[a])/(e[u]-e[a]));i.length=s;for(var h=o(i),l=new Array(n),c=0;c<n;++c)l[c]=r[c]-h*e[c];t.slope=h,t.intercept=o(l),t.coefficients=[t.intercept,t.slope]}(this,t,e))}toJSON(){return{name:"TheilSenRegression",slope:this.slope,intercept:this.intercept}}_predict(t){return this.slope*t+this.intercept}computeX(t){return(t-this.intercept)/this.slope}toString(t){var e="f(x) = ";if(this.slope){var r=(0,n.maybeToPrecision)(this.slope,t);if(e+=(Math.abs(r-1)<1e-5?"":r+" * ")+"x",this.intercept){var i=Math.abs(this.intercept);e+=" "+(i===this.intercept?"+":"-")+" "+(0,n.maybeToPrecision)(i,t)}}else e+=(0,n.maybeToPrecision)(this.intercept,t);return e}toLaTeX(t){return this.toString(t)}static load(t){if("TheilSenRegression"!==t.name)throw new TypeError("not a Theil-Sen model");return new s(!0,t)}}e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=function(t){return t&&t.__esModule?t:{default:t}}(n),o=r(0);class s extends i.default{constructor(t,e,r){super(),!0===t?(this.degree=e.degree,this.powers=e.powers,this.coefficients=e.coefficients):((0,n.checkArrayLength)(t,e),function(t,e,r,n){for(var i=new Array(n),o=0;o<n;o++)i[o]=o;for(var s,l=function(t,e,r){for(var n=Math.floor(t.length/r),i=new Array(n),o=0;o<t.length;o++){for(var s=Math.floor(Math.random()*n),a=0;a<t.length;){if(!i[s]){i[s]=[{x:t[o],y:e[o]}];break}if(i[s].length<r){i[s].push({x:t[o],y:e[o]});break}a++,s=(s+1)%n}if(a===t.length)return i}return i}(e,r,n),c=0;c<l.length;c++){for(var f=l[c],d=a(f,i),m=e.slice(),g=0;g<e.length;g++)m[g]=r[g]-u(e[g],i,d),m[g]={residual:m[g]*m[g],coefficients:d};var p=h(m);(!s||p.residual<s.residual)&&(s=p)}t.degree=n,t.powers=i,t.coefficients=s.coefficients}(this,t,e,r))}toJSON(){return{name:"robustPolynomialRegression",degree:this.degree,powers:this.powers,coefficients:this.coefficients}}_predict(t){return u(t,this.powers,this.coefficients)}toString(t){return this._toFormula(t,!1)}toLaTeX(t){return this._toFormula(t,!0)}_toFormula(t,e){var r="^",i="",o=" * ";e&&(r="^{",i="}",o="");for(var s="",a="",u=0;u<this.coefficients.length;u++)a="",0!==this.coefficients[u]&&(a=0===this.powers[u]?(0,n.maybeToPrecision)(this.coefficients[u],t):1===this.powers[u]?(0,n.maybeToPrecision)(this.coefficients[u],t)+o+"x":(0,n.maybeToPrecision)(this.coefficients[u],t)+o+"x"+r+this.powers[u]+i,this.coefficients[u]>0&&u!==this.coefficients.length-1?a=" + "+a:u!==this.coefficients.length-1&&(a=" "+a)),s=a+s;return"+"===s.charAt(0)&&(s=s.slice(1)),"f(x) = "+s}static load(t){if("robustPolynomialRegression"!==t.name)throw new TypeError("not a RobustPolynomialRegression model");return new s(!0,t)}}function a(t,e){for(var r=t.slice(),n=t.slice(),i=0;i<r.length;i++){n[i]=[t[i].y],r[i]=new Array(e.length);for(var s=0;s<e.length;s++)r[i][s]=Math.pow(t[i].x,e[s])}return(0,o.solve)(r,n).to1DArray()}function u(t,e,r){for(var n=0,i=0;i<e.length;i++)n+=r[i]*Math.pow(t,e[i]);return n}function h(t){t.sort((t,e)=>t.residual-e.residual);var e=t.length,r=Math.floor(e/2);return e%2==0?t[r-1]:t[r]}e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=s(n),o=s(r(38));function s(t){return t&&t.__esModule?t:{default:t}}class a extends i.default{constructor(t,e,r){if(super(),!0===t)this.A=e.A,this.M=e.M;else{if(t.length!==e.length)throw new RangeError("input and output array have a different length");var n=new o.default(t,e,[r]);this.A=n.coefficients[0],this.M=r}}_predict(t){return this.A*Math.pow(t,this.M)}toJSON(){return{name:"potentialRegression",A:this.A,M:this.M}}toString(t){return"f(x) = "+(0,n.maybeToPrecision)(this.A,t)+" * x^"+this.M}toLaTeX(t){return this.M>=0?"f(x) = "+(0,n.maybeToPrecision)(this.A,t)+"x^{"+this.M+"}":"f(x) = \\frac{"+(0,n.maybeToPrecision)(this.A,t)+"}{x^{"+-this.M+"}}"}static load(t){if("potentialRegression"!==t.name)throw new TypeError("not a potential regression model");return new a(!0,t)}}e.default=a},function(t,e,r){"use strict";var n=r(0);function i(t,e,r){for(var n=0,i=r(e),o=0;o<t.x.length;o++)n+=Math.abs(t.y[o]-i(t.x[o]));return n}function o(t,e,r,i,o){for(var s=n.Matrix.eye(e.length).mul(r*i*i),a=t.x.length,u=new Array(a),h=o(e),l=0;l<a;l++)u[l]=h(t.x[l]);var c=function(t,e,r,i,o){for(var s=r.length,a=t.x.length,u=new Array(s),h=0;h<s;h++){u[h]=new Array(a);var l=r.concat();l[h]+=i;for(var c=o(l),f=0;f<a;f++)u[h][f]=e[f]-c(t.x[f])}return new n.Matrix(u)}(t,u,e,i,o),f=function(t,e){for(var r=t.x.length,i=new Array(r),o=0;o<r;o++)i[o]=t.y[o]-e[o];return new n.Matrix([i])}(t,u).transposeView(),d=n.inverse(s.add(c.mmul(c.transposeView())));return(e=(e=new n.Matrix([e])).sub(d.mmul(c).mmul(f).mul(i).transposeView())).to1DArray()}t.exports=function(t,e,r={}){var n=r.maxIterations,s=void 0===n?100:n,a=r.gradientDifference,u=void 0===a?.1:a,h=r.damping,l=void 0===h?0:h,c=r.errorTolerance,f=void 0===c?.01:c,d=r.initialValues;if(l<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!Array.isArray(t.x)||t.x.length<2||!Array.isArray(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");var m=d||new Array(e.length).fill(1);if(!Array.isArray(m))throw new Error("initialValues must be an array");for(var g=i(t,m,e),p=g<=f,v=0;v<s&&!p;v++)p=(g=i(t,m=o(t,m,l,u,e),e))<=f;return{parameterValues:m,parameterError:g,iterations:v}}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SparseMatrix=void 0;var _mlHashTable=__webpack_require__(39),_mlHashTable2=_interopRequireDefault(_mlHashTable);function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}class SparseMatrix{constructor(t,e,r={}){if(t instanceof SparseMatrix){var n=t;this._init(n.rows,n.columns,n.elements.clone(),n.threshold)}else if(Array.isArray(t)){var i=t;t=i.length,r=e||{},e=i[0].length,this._init(t,e,new _mlHashTable2.default(r),r.threshold);for(var o=0;o<t;o++)for(var s=0;s<e;s++){var a=i[o][s];this.threshold&&Math.abs(a)<this.threshold&&(a=0),0!==a&&this.elements.set(o*e+s,i[o][s])}}else this._init(t,e,new _mlHashTable2.default(r),r.threshold)}_init(t,e,r,n){this.rows=t,this.columns=e,this.elements=r,this.threshold=n||0}static eye(t=1,e=t){for(var r=Math.min(t,e),n=new SparseMatrix(t,e,{initialCapacity:r}),i=0;i<r;i++)n.set(i,i,1);return n}clone(){return new SparseMatrix(this)}to2DArray(){for(var t=new Array(this.rows),e=0;e<this.rows;e++){t[e]=new Array(this.columns);for(var r=0;r<this.columns;r++)t[e][r]=this.get(e,r)}return t}isSquare(){return this.rows===this.columns}isSymmetric(){if(!this.isSquare())return!1;var t=!0;return this.forEachNonZero((e,r,n)=>this.get(r,e)!==n?(t=!1,!1):n),t}bandWidth(){var t=this.columns,e=-1;return this.forEachNonZero((r,n,i)=>{var o=r-n;return t=Math.min(t,o),e=Math.max(e,o),i}),e-t}isBanded(t){return this.bandWidth()<=t}get cardinality(){return this.elements.size}get size(){return this.rows*this.columns}get(t,e){return this.elements.get(t*this.columns+e)}set(t,e,r){return this.threshold&&Math.abs(r)<this.threshold&&(r=0),0===r?this.elements.remove(t*this.columns+e):this.elements.set(t*this.columns+e,r),this}mmul(t){this.columns!==t.rows&&console.warn("Number of columns of left matrix are not equal to number of rows of right matrix.");var e=this.rows,r=t.columns,n=new SparseMatrix(e,r);return this.forEachNonZero((e,r,i)=>(t.forEachNonZero((t,o,s)=>(r===t&&n.set(e,o,n.get(e,o)+i*s),s)),i)),n}kroneckerProduct(t){var e=this.rows,r=this.columns,n=t.rows,i=t.columns,o=new SparseMatrix(e*n,r*i,{initialCapacity:this.cardinality*t.cardinality});return this.forEachNonZero((e,r,s)=>(t.forEachNonZero((t,a,u)=>(o.set(n*e+t,i*r+a,s*u),u)),s)),o}forEachNonZero(t){return this.elements.forEachPair((e,r)=>{var n=e/this.columns|0,i=e%this.columns,o=t(n,i,r);return!1!==o&&(this.threshold&&Math.abs(o)<this.threshold&&(o=0),o!==r&&(0===o?this.elements.remove(e,!0):this.elements.set(e,o)),!0)}),this.elements.maybeShrinkCapacity(),this}getNonZeros(){var t=this.cardinality,e=new Array(t),r=new Array(t),n=new Array(t),i=0;return this.forEachNonZero((t,o,s)=>(e[i]=t,r[i]=o,n[i]=s,i++,s)),{rows:e,columns:r,values:n}}setThreshold(t){return 0!==t&&t!==this.threshold&&(this.threshold=t,this.forEachNonZero((t,e,r)=>r)),this}transpose(){var t=new SparseMatrix(this.columns,this.rows,{initialCapacity:this.cardinality});return this.forEachNonZero((e,r,n)=>(t.set(r,e,n),n)),t}}exports.SparseMatrix=SparseMatrix,SparseMatrix.prototype.klass="Matrix",SparseMatrix.identity=SparseMatrix.eye,SparseMatrix.prototype.tensorProduct=SparseMatrix.prototype.kroneckerProduct;var inplaceOperator="\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n",inplaceOperatorScalar="\n(function %name%S(value) {\n this.forEachNonZero((i, j, v) => v %op% value);\n return this;\n})\n",inplaceOperatorMatrix="\n(function %name%M(matrix) {\n matrix.forEachNonZero((i, j, v) => {\n this.set(i, j, this.get(i, j) %op% v);\n return v;\n });\n return this;\n})\n",staticOperator="\n(function %name%(matrix, value) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%(value);\n})\n",inplaceMethod="\n(function %name%() {\n this.forEachNonZero((i, j, v) => %method%(v));\n return this;\n})\n",staticMethod="\n(function %name%(matrix) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%();\n})\n",operators=[["+","add"],["-","sub","subtract"],["*","mul","multiply"],["/","div","divide"],["%","mod","modulus"],["&","and"],["|","or"],["^","xor"],["<<","leftShift"],[">>","signPropagatingRightShift"],[">>>","rightShift","zeroFillRightShift"]];for(var operator of operators)for(var i=1;i<operator.length;i++)SparseMatrix.prototype[operator[i]]=eval(fillTemplateFunction(inplaceOperator,{name:operator[i],op:operator[0]})),SparseMatrix.prototype[operator[i]+"S"]=eval(fillTemplateFunction(inplaceOperatorScalar,{name:operator[i]+"S",op:operator[0]})),SparseMatrix.prototype[operator[i]+"M"]=eval(fillTemplateFunction(inplaceOperatorMatrix,{name:operator[i]+"M",op:operator[0]})),SparseMatrix[operator[i]]=eval(fillTemplateFunction(staticOperator,{name:operator[i]}));var methods=[["~","not"]];for(var method of(["abs","acos","acosh","asin","asinh","atan","atanh","cbrt","ceil","clz32","cos","cosh","exp","expm1","floor","fround","log","log1p","log10","log2","round","sign","sin","sinh","sqrt","tan","tanh","trunc"].forEach(function(t){methods.push(["Math."+t,t])}),methods))for(var _i=1;_i<method.length;_i++)SparseMatrix.prototype[method[_i]]=eval(fillTemplateFunction(inplaceMethod,{name:method[_i],method:method[0]})),SparseMatrix[method[_i]]=eval(fillTemplateFunction(staticMethod,{name:method[_i]}));function fillTemplateFunction(t,e){for(var r in e)t=t.replace(new RegExp("%"+r+"%","g"),e[r]);return t}},function(t,e,r){"use strict";t.exports=function(t,e){t=t||0;for(var r=new Array(t),n=0;n<t;n++)r[n]=e;return r}},function(t,e,r){"use strict";var n=r(40),i=r(41).asc,o=[2147483647,5,11,23,47,97,197,397,797,1597,3203,6421,12853,25717,51437,102877,205759,411527,823117,1646237,3292489,6584983,13169977,26339969,52679969,105359939,210719881,421439783,842879579,1685759167,433,877,1759,3527,7057,14143,28289,56591,113189,226379,452759,905551,1811107,3622219,7244441,14488931,28977863,57955739,115911563,231823147,463646329,927292699,1854585413,953,1907,3821,7643,15287,30577,61169,122347,244703,489407,978821,1957651,3915341,7830701,15661423,31322867,62645741,125291483,250582987,501165979,1002331963,2004663929,1039,2081,4177,8363,16729,33461,66923,133853,267713,535481,1070981,2141977,4283963,8567929,17135863,34271747,68543509,137087021,274174111,548348231,1096696463,31,67,137,277,557,1117,2237,4481,8963,17929,35863,71741,143483,286973,573953,1147921,2295859,4591721,9183457,18366923,36733847,73467739,146935499,293871013,587742049,1175484103,599,1201,2411,4831,9677,19373,38747,77509,155027,310081,620171,1240361,2480729,4961459,9922933,19845871,39691759,79383533,158767069,317534141,635068283,1270136683,311,631,1277,2557,5119,10243,20507,41017,82037,164089,328213,656429,1312867,2625761,5251529,10503061,21006137,42012281,84024581,168049163,336098327,672196673,1344393353,3,7,17,37,79,163,331,673,1361,2729,5471,10949,21911,43853,87719,175447,350899,701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,359339171,718678369,1437356741,43,89,179,359,719,1439,2879,5779,11579,23159,46327,92657,185323,370661,741337,1482707,2965421,5930887,11861791,23723597,47447201,94894427,189788857,379577741,759155483,1518310967,379,761,1523,3049,6101,12203,24407,48817,97649,195311,390647,781301,1562611,3125257,6250537,12501169,25002389,50004791,100009607,200019221,400038451,800076929,1600153859,13,29,59,127,257,521,1049,2099,4201,8419,16843,33703,67409,134837,269683,539389,1078787,2157587,4315183,8630387,17260781,34521589,69043189,138086407,276172823,552345671,1104691373,19,41,83,167,337,677,1361,2729,5471,10949,21911,43853,87719,175447,350899,701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,359339171,718678369,1437356741,53,107,223,449,907,1823,3659,7321,14653,29311,58631,117269,234539,469099,938207,1876417,3752839,7505681,15011389,30022781,60045577,120091177,240182359,480364727,960729461,1921458943];o.sort(i),e.nextPrime=function(t){var e=n(o,t,i);return e<0&&(e=~e),o[e]},e.largestPrime=2147483647},function(t,e,r){"use strict";t.exports=Number.isNaN||function(t){return t!=t}},function(t,e,r){"use strict";e.additiveSymmetric=r(137),e.avg=r(138),e.bhattacharyya=r(139),e.canberra=r(140),e.chebyshev=r(141),e.clark=r(142),e.czekanowski=r(143),e.dice=r(44),e.divergence=r(144),e.euclidean=r(1),e.fidelity=r(145),e.gower=r(146),e.harmonicMean=r(147),e.hellinger=r(148),e.innerProduct=r(149),e.intersection=r(45),e.jaccard=r(46),e.jeffreys=r(150),e.jensenDifference=r(151),e.jensenShannon=r(152),e.kdivergence=r(153),e.kulczynski=r(47),e.kullbackLeibler=r(154),e.kumarHassebrook=r(155),e.kumarJohnson=r(156),e.lorentzian=r(157),e.manhattan=r(158),e.matusita=r(159),e.minkowski=r(160),e.motyka=r(48),e.neyman=r(161),e.pearson=r(162),e.probabilisticSymmetric=r(163),e.ruzicka=r(164),e.soergel=r(165),e.sorensen=r(166),e.squared=r(167),e.squaredChord=r(49),e.squaredEuclidean=r(1).squared,e.taneja=r(168),e.tanimoto=r(169),e.topsoe=r(170),e.tree=r(171),e.waveHedges=r(172)},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=(t[r]-e[r])*(t[r]-e[r])*(t[r]+e[r])/(t[r]*e[r]);return 2*i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0,s=0;s<r;s++)i+=o=Math.abs(t[s]-e[s]),n<o&&(n=o);return(n+i)/2}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.sqrt(t[i]*e[i]);return-Math.log(n)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.abs(t[i]-e[i])/(t[i]+e[i]);return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0;o<r;o++)n<(i=Math.abs(t[o]-e[o]))&&(n=i);return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=Math.sqrt((t[r]-e[r])*(t[r]-e[r])/((t[r]+e[r])*(t[r]+e[r])));return 2*i}},function(t,e,r){"use strict";var n=r(43);t.exports=function(t,e){return 1-n(t,e)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=(t[r]-e[r])*(t[r]-e[r])/((t[r]+e[r])*(t[r]+e[r]));return 2*i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.sqrt(t[i]*e[i]);return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.abs(t[i]-e[i]);return n/r}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=t[i]*e[i]/(t[i]+e[i]);return 2*n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.sqrt(t[i]*e[i]);return 2*Math.sqrt(1-n)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=t[i]*e[i];return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=(t[i]-e[i])*Math.log(t[i]/e[i]);return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=(t[i]*Math.log(t[i])+e[i]*Math.log(e[i]))/2-(t[i]+e[i])/2*Math.log((t[i]+e[i])/2);return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0;o<r;o++)n+=t[o]*Math.log(2*t[o]/(t[o]+e[o])),i+=e[o]*Math.log(2*e[o]/(t[o]+e[o]));return(n+i)/2}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=t[i]*Math.log(2*t[i]/(t[i]+e[i]));return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=t[i]*Math.log(t[i]/e[i]);return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0,s=0;s<r;s++)n+=t[s]*e[s],i+=t[s]*t[s],o+=e[s]*e[s];return n/(i+o-n)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.pow(t[i]*t[i]-e[i]*e[i],2)/(2*Math.pow(t[i]*e[i],1.5));return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.log(Math.abs(t[i]-e[i])+1);return n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=Math.abs(t[r]-e[r]);return i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=Math.sqrt(t[i]*e[i]);return Math.sqrt(2-2*n)}},function(t,e,r){"use strict";t.exports=function(t,e,r){for(var n=0,i=t.length,o=0;n<i;n++)o+=Math.pow(Math.abs(t[n]-e[n]),r);return Math.pow(o,1/r)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=(t[r]-e[r])*(t[r]-e[r])/t[r];return i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=(t[r]-e[r])*(t[r]-e[r])/e[r];return i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=(t[r]-e[r])*(t[r]-e[r])/(t[r]+e[r]);return 2*i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0;o<r;o++)n+=Math.min(t[o],e[o]),i+=Math.max(t[o],e[o]);return n/i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0;o<r;o++)n+=Math.abs(t[o]-e[o]),i+=Math.max(t[o],e[o]);return n/i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0,o=0;o<r;o++)n+=Math.abs(t[o]-e[o]),i+=t[o]+e[o];return n/i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=0,n=t.length,i=0;r<n;r++)i+=(t[r]-e[r])*(t[r]-e[r])/(t[r]+e[r]);return i}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=(t[i]+e[i])/2*Math.log((t[i]+e[i])/(2*Math.sqrt(t[i]*e[i])));return n}},function(t,e,r){"use strict";var n=r(50);t.exports=function(t,e,r){if(r)return 1-n(t,e,r);for(var i=t.length,o=0,s=0,a=0,u=0;u<i;u++)o+=t[u],s+=e[u],a+=Math.min(t[u],e[u]);return(o+s-2*a)/(o+s-a)}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=t[i]*Math.log(2*t[i]/(t[i]+e[i]))+e[i]*Math.log(2*e[i]/(t[i]+e[i]));return n}},function(t,e,r){"use strict";function n(t,e,r,i,o,s){if(o=o||.16,s=s||.01,!(i-r<o)){for(var a=0,u=0;t[u]<i;u++)t[u]>r&&(a+=e[u]);if(!(a<s)){for(var h=0,l=0;t[l]<i;l++)t[u]>r&&(h+=t[l]*e[l]);if(!((h/=a)-r<1e-5||i-h<1e-5))return h-r<o/4?n(t,e,h,i,o,s):i-h<o/4?n(t,e,r,h,o,s):{sum:a,center:h,left:n(t,e,r,h,o,s),right:n(t,e,h,i,o,s)}}}}var i={minWindow:.16,threshold:.01,alpha:.1,beta:.33,gamma:.001};t.exports={calc:function(t,e,r,o,s){for(var a in s=s||{},i)s.hasOwnProperty(a)||(s[a]=i[a]);return function t(e,r,n,i,o){return void 0===e||void 0===r?0:i*(n*Math.min(e.sum,r.sum)/Math.max(e.sum,r.sum)+(1-n)*Math.exp(-o*Math.abs(e.center-r.center)))+(1-i)*(t(e.left,r.left,n,i,o)+t(e.right,r.right,n,i,o))}(t.sum?t:n(t.x,t.y,r,o,s.minWindow,s.threshold),e.sum?e:n(e.x,e.y,r,o,s.minWindow,s.threshold),s.alpha,s.beta,s.gamma)},createTree:n}},function(t,e,r){"use strict";t.exports=function(t,e){for(var r=t.length,n=0,i=0;i<r;i++)n+=1-Math.min(t[i],e[i])/Math.max(t[i],e[i]);return n}},function(t,e,r){"use strict";e.cosine=r(51),e.czekanowski=r(43),e.dice=r(174),e.intersection=r(175),e.jaccard=r(176),e.kulczynski=r(177),e.motyka=r(178),e.pearson=r(179),e.squaredChord=r(180),e.tanimoto=r(50)},function(t,e,r){"use strict";var n=r(44);t.exports=function(t,e){return 1-n(t,e)}},function(t,e,r){"use strict";var n=r(45);t.exports=function(t,e){return 1-n(t,e)}},function(t,e,r){"use strict";var n=r(46);t.exports=function(t,e){return 1-n(t,e)}},function(t,e,r){"use strict";var n=r(47);t.exports=function(t,e){return 1/n(t,e)}},function(t,e,r){"use strict";var n=r(48);t.exports=function(t,e){return 1-n(t,e)}},function(t,e,r){"use strict";var n=r(4).array,i=r(51);t.exports=function(t,e){for(var r=n.mean(t),o=n.mean(e),s=new Array(t.length),a=new Array(e.length),u=0;u<s.length;u++)s[u]=t[u]-r,a[u]=e[u]-o;return i(s,a)}},function(t,e,r){"use strict";var n=r(49);t.exports=function(t,e){return 1-n(t,e)}},function(t,e,r){"use strict";var n=r(182);class i{constructor(t,e,r){if(r=r||{},t.length!==e.length||t[0].length!==e[0].length)throw new Error("dimensions of prediction and target do not match");var n=t.length,i=t[0].length,o=!r.max,s=[];if(r.all)for(var a=0;a<n;a++)for(var u=0;u<i;u++)s.push({pred:t[a][u],targ:e[a][u]});else{if(n<3||n!==i)throw new Error('When "all" option is false, the prediction matrix must be square and have at least 3 columns');for(a=0;a<n-1;a++)for(u=a+1;u<i;u++)s.push({pred:t[a][u],targ:e[a][u]})}o?s.sort((t,e)=>t.pred-e.pred):s.sort((t,e)=>e.pred-t.pred);var h=this.cutoffs=[o?Number.MIN_VALUE:Number.MAX_VALUE],l=this.fp=[0],c=this.tp=[0],f=0,d=0,m=s[0].pred,g=0,p=0;for(a=0;a<s.length;a++)s[a].pred!==m&&(h.push(m),l.push(p),c.push(g),m=s[a].pred),s[a].targ?(f++,g++):(d++,p++);h.push(m),l.push(p),c.push(g);var v=h.length,w=this.fn=new Array(v),y=this.tn=new Array(v),x=this.nPosPred=new Array(v),M=this.nNegPred=new Array(v);for(a=0;a<v;a++)w[a]=f-c[a],y[a]=d-l[a],x[a]=c[a]+l[a],M[a]=y[a]+w[a];this.nPos=f,this.nNeg=d,this.nSamples=f+d}getMeasure(t){if("string"!=typeof t)throw new Error("No measure specified");if(!n[t])throw new Error(`The specified measure (${t}) does not exist`);return n[t](this)}getAURC(){for(var t=this.cutoffs.length,e=new Array(t),r=new Array(t),n=0;n<t;n++)e[n]=this.fp[n]/this.nNeg,r[n]=this.tp[n]/this.nPos;var i=0;for(n=1;n<t;n++)i+=.5*(e[n]-e[n-1])*(r[n]+r[n-1]);return i}getAUDC(){for(var t=this.cutoffs.length,e=new Array(t),r=new Array(t),n=0;n<t;n++)e[n]=this.fn[n]/this.nPos,r[n]=this.fp[n]/this.nNeg;var i=0;for(n=1;n<t;n++)i+=.5*(e[n]+e[n-1])*(r[n]-r[n-1]);return i}getDistribution(t){t=t||{};for(var e=this.cutoffs.length,r=t.xMin||Math.floor(100*this.cutoffs[e-1])/100,n=t.xMax||Math.ceil(100*this.cutoffs[1])/100,i=t.interval||Math.floor((n-r)/20*1e7-1)/1e7,o=[],s=[],a=[],u=[],h=[],l=this.tp[e-1],c=0,f=this.fp[e-1],d=0,m=r,g=e-1;m<=n;m+=i){for(;this.cutoffs[g]<m;)g--;o.push(m);var p=l-c-this.tp[g],v=f-d-this.fp[g];c+=p,d+=v,s.push(v),a.push(p),u.push(100-(f-this.fp[g])/f*100),h.push(100-(l-this.tp[g])/l*100)}return{xLabels:o,interValues:s,intraValues:a,interCumPercent:u,intraCumPercent:h}}}i.names={acc:"Accuracy",err:"Error rate",fpr:"False positive rate",tpr:"True positive rate",fnr:"False negative rate",tnr:"True negative rate",ppv:"Positive predictive value",npv:"Negative predictive value",pcfall:"Prediction-conditioned fallout",pcmiss:"Prediction-conditioned miss",lift:"Lift value",rpp:"Rate of positive predictions",rnp:"Rate of negative predictions",threshold:"Threshold"},t.exports=i},function(t,e,r){"use strict";e.acc=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=(t.tn[n]+t.tp[n])/(e-1);return r}),e.err=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.fn[n]+t.fp[n]/(e-1);return r}),e.fpr=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.fp[n]/t.nNeg;return r}),e.tpr=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.tp[n]/t.nPos;return r}),e.fnr=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.fn[n]/t.nPos;return r}),e.tnr=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.tn[n]/t.nNeg;return r}),e.ppv=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.fp[n]+t.tp[n]!==0?t.tp[n]/(t.fp[n]+t.tp[n]):0;return r}),e.npv=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.fn[n]+t.tn[n]!==0?t.tn[n]/(t.fn[n]+t.tn[n]):0;return r}),e.pcfall=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.fp[n]+t.tp[n]!==0?1-t.tp[n]/(t.fp[n]+t.tp[n]):1;return r}),e.pcmiss=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.fn[n]+t.tn[n]!==0?1-t.tn[n]/(t.fn[n]+t.tn[n]):1;return r}),e.lift=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=0!==t.nPosPred[n]?t.tp[n]/t.nPos/(t.nPosPred[n]/t.nSamples):0;return r}),e.rpp=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.nPosPred[n]/t.nSamples;return r}),e.rnp=(t=>{for(var e=t.cutoffs.length,r=new Array(e),n=0;n<e;n++)r[n]=t.nNegPred[n]/t.nSamples;return r}),e.threshold=(t=>{var e=t.cutoffs.slice();return e[0]=e[1],e})},function(t,e,r){"use strict";var n=r(0),i=n.Matrix,o=n.inverse,s=r(52),a=r(16),u={windowSize:5,derivative:1,polynomial:2,pad:"none",padValue:"replicate"};t.exports=function(t,e,r){if((r=a({},u,r)).windowSize%2==0||r.windowSize<5||!Number.isInteger(r.windowSize))throw new RangeError("Invalid window size (should be odd and at least 5 integer number)");if(r.derivative<0||!Number.isInteger(r.derivative))throw new RangeError("Derivative should be a positive integer");if(r.polynomial<1||!Number.isInteger(r.polynomial))throw new RangeError("Polynomial should be a positive integer");var n,h,l=Math.floor(r.windowSize/2);"pre"===r.pad&&(t=s(t,{size:l,value:r.padValue}));var c=new Array(t.length-2*l);if(5!==r.windowSize||2!==r.polynomial||1!==r.derivative&&2!==r.derivative){for(var f=i.ones(r.windowSize,r.polynomial+1),d=-(r.windowSize-1)/2,m=0;m<f.length;m++)for(var g=0;g<f[m].length;g++)d+1===0&&0===g||(f[m][g]=Math.pow(d+m,g));var p=f.transposeView();n=(n=o(p.mmul(f)).mmul(p))[r.derivative],h=1}else 1===r.derivative?(n=[-2,-1,0,1,2],h=10):(n=[2,-1,-2,-1,2],h=7);for(var v=h*Math.pow(e,r.derivative),w=l;w<t.length-l;w++){for(var y=0,x=0;x<n.length;x++)y+=n[x]*t[x+w-l]/v;c[w-l]=y}return"post"===r.pad&&(c=s(c,{size:l,value:r.padValue})),c}},function(t,e,r){"use strict";var n=r(16),i=(r(4),{windowSize:9,derivative:0,polynomial:3});function o(t,e,r,n){for(var i=0,o=0,s=e-r;s<e+r;s++)s>=0&&s<t.length-1&&(i+=t[s+1]-t[s],o++);return Math.pow(i/o,n)}function s(t,e,r,n){return r>0?(4*r-2)/(r*(2*e-r+1))*(t*s(t,e,r-1,n)+n*s(t,e,r-1,n-1))-(r-1)*(2*e+r)/(r*(2*e-r+1))*s(t,e,r-2,n):0==r&&0==n?1:0}function a(t,e){var r=1;if(t>=e)for(var n=t-e+1;n<=t;n++)r*=n;return r}function u(t,e,r,n,i){for(var o=0,u=0;u<=n;u++)o+=(2*u+1)*(a(2*r,u)/a(2*r+u+1,u+1))*s(t,r,u,0)*s(e,r,u,i);return o}t.exports=function(t,e,r){if((r=n({},i,r)).windowSize%2==0||r.windowSize<5||!Number.isInteger(r.windowSize))throw new RangeError("Invalid window size (should be odd and at least 5 integer number)");if(r.windowSize>t.length)throw new RangeError("Window size is higher than the data length "+r.windowSize+">"+t.length);if(r.derivative<0||!Number.isInteger(r.derivative))throw new RangeError("Derivative should be a positive integer");if(r.polynomial<1||!Number.isInteger(r.polynomial))throw new RangeError("Polynomial should be a positive integer");r.polynomial>=6&&console.warn("You should not use polynomial grade higher than 5 if you are not sure that your data arises from such a model. Possible polynomial oscillation problems");var s=r.windowSize,a=Math.floor(s/2),h=t.length,l=new Array(h),c=function(t,e,r){for(var n=new Array(t),i=Math.floor(t/2),o=-i;o<=i;o++){n[o+i]=new Array(t);for(var s=-i;s<=i;s++)n[o+i][s+i]=u(s,o,i,e,r)}return n}(s,r.polynomial,r.derivative),f=0,d=!0;"[object Array]"===Object.prototype.toString.call(e)?d=!1:f=Math.pow(e,r.derivative);for(var m=0;m<a;m++){for(var g=c[a-m-1],p=c[a+m+1],v=0,w=0,y=0;y<s;y++)v+=g[y]*t[y],w+=p[y]*t[h-s+y-1];d?(l[a-m-1]=v/f,l[h-a+m]=w/f):(f=o(e,a-m-1,a,r.derivative),l[a-m-1]=v/f,f=o(e,h-a+m,a,r.derivative),l[h-a+m]=w/f)}var x=c[a];for(m=s;m<h+1;m++){var M=0;for(y=0;y<s;y++)M+=x[y]*t[y+m-s];d||(f=o(e,m-a-1,a,r.derivative)),l[m-a-1]=M/f}return l}},function(t,e,r){"use strict";var n=r(186);function i(t){for(var e="",r=0;r<t.length;r++){var n=(t[r]>>>0).toString(2);e+="00000000000000000000000000000000".substr(n.length)+n}return e}t.exports={count:function(t){for(var e=0,r=0;r<t.length;r++)e+=n[255&t[r]]+n[t[r]>>8&255]+n[t[r]>>16&255]+n[t[r]>>24&255];return e},and:function(t,e){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]=t[n]&e[n];return r},or:function(t,e){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]=t[n]|e[n];return r},xor:function(t,e){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]=t[n]^e[n];return r},not:function(t){for(var e=new Array(t.length),r=0;r<e.length;r++)e[r]=~t[r];return e},getBit:function(t,e){var r=1<<31-e%32;return Boolean(t[e>>5]&r)},setBit:function(t,e,r){var n=e>>5,i=1<<31-e%32;return t[n]=r?i|t[n]:~i&t[n],t},toBinaryString:i,parseBinaryString:function(t){for(var e=t.length/32,r=new Array(e),n=0;n<e;n++)r[n]=0|parseInt(t.substr(32*n,32),2);return r},toHexString:function(t){for(var e="",r=0;r<t.length;r++){var n=(t[r]>>>0).toString(16);e+="00000000".substr(n.length)+n}return e},parseHexString:function(t){for(var e=t.length/8,r=new Array(e),n=0;n<e;n++)r[n]=0|parseInt(t.substr(8*n,8),16);return r},toDebug:function(t){for(var e=i(t),r="",n=0;n<t.length;n++){r+="0000".substr((32*n).toString(16).length)+(32*n).toString(16)+":";for(var o=0;o<32;o+=4)r+=" "+e.substr(32*n+o,4);n<t.length-1&&(r+="\n")}return r}}},function(t,e,r){"use strict";for(var n=new Array(256),i=0;i<256;i++){for(var o=i,s=0;o;)o&=o-1,s++;n[i]=s}t.exports=n},function(t,e,r){"use strict";t.exports=e=r(188),e.getEquallySpacedData=r(189).getEquallySpacedData,e.SNV=r(190).SNV},function(t,e,r){"use strict";var n=r(4).array;function i(t){for(var e=new Array(t[0].length),r=0;r<e.length;++r)e[r]=new Array(t.length);for(r=0;r<t.length;++r)for(var n=0;n<t[0].length;++n)e[n][r]=t[r][n];return e}t.exports={coordArrayToPoints:function(t,e){if(t.length%e!=0)throw new RangeError("Dimensions number must be accordance with the size of the array.");for(var r=t.length/e,n=new Array(r),i=0,o=0;o<t.length;o+=e){for(var s=new Array(e),a=0;a<e;++a)s[a]=t[o+a];n[i]=s,i++}return n},coordArrayToCoordMatrix:function(t,e){if(t.length%e!=0)throw new RangeError("Dimensions number must be accordance with the size of the array.");for(var r=new Array(e),n=t.length/e,i=0;i<r.length;i++)r[i]=new Array(n);for(i=0;i<t.length;i+=e)for(var o=0;o<e;++o){var s=Math.floor(i/e);r[o][s]=t[i+o]}return r},coordMatrixToCoordArray:function(t){for(var e=new Array(t.length*t[0].length),r=0,n=0;n<t[0].length;++n)for(var i=0;i<t.length;++i)e[r]=t[i][n],++r;return e},coordMatrixToPoints:i,pointsToCoordArray:function(t){for(var e=new Array(t.length*t[0].length),r=0,n=0;n<t.length;++n)for(var i=0;i<t[0].length;++i)e[r]=t[n][i],++r;return e},pointsToCoordMatrix:i,applyDotProduct:function(t,e){var r,n;t.length<=e.length?(n=t,r=e):(n=e,r=t);for(var i=r.length-n.length+1,o=new Array(i),s=0;s<i;++s){for(var a=0,u=0;u<n.length;++u)a+=n[u]*r[s+u];o[s]=a}return o},scale:function t(e,r={}){var i=r.min,o=r.max,s=r.inPlace?e:new Array(e.length),a=n.minMax(e);if("number"==typeof o)if("number"==typeof i)for(var u=(o-i)/(a.max-a.min),h=0;h<s.length;h++)s[h]=(e[h]-a.min)*u+i;else if(0!==a.max)for(var l=o/a.max,c=0;c<s.length;c++)s[c]=e[c]*l;else r.min=a.min,s=t(e,r);else if("number"==typeof i)if(0!==a.min)for(var f=i/a.min,d=0;d<s.length;d++)s[d]=e[d]*f;else r.max=a.max,s=t(e,r);return s}}},function(t,e,r){"use strict";function n(t,e,r,n){return.5*r*e*e+n*e-(.5*r*t*t+n*t)}e.getEquallySpacedData=function(t,e,r={}){var i=t.length;t.length>1&&t[0]>t[1]&&(t=t.slice().reverse(),e=e.slice().reverse());var o=r.from,s=void 0===o?t[0]:o,a=r.to,u=void 0===a?t[i-1]:a,h=r.variant,l=void 0===h?"smooth":h,c=r.numberOfPoints,f=void 0===c?100:c;if(i!==e.length)throw new RangeError("the x and y vector doesn't have the same size.");if("number"!=typeof s||isNaN(s))throw new RangeError("'from' option must be a number");if("number"!=typeof u||isNaN(u))throw new RangeError("'to' option must be a number");var d=s>u;if(d){var m=[u,s];s=m[0],u=m[1]}if("number"!=typeof f||isNaN(f))throw new RangeError("'numberOfPoints' option must be a number");if(f<1)throw new RangeError("the number of points must be at least 1");var g="slot"===l?function(t,e,r,n,i){var o=t.length,s=(n-r)/(i-1),a=s/2,u=t[t.length-1]-t[t.length-2],h=r-a,l=new Array(i),c=h,f=h+s,d=-Number.MAX_VALUE,m=0,g=t[0],p=e[0],v=0,w=!0,y=0,x=0,M=1,b=0;t:for(;;){if(d>=g)throw new Error("x must be an increasing serie");for(;d-f>0;){if(w&&(x++,w=!1),l[b]=x<=0?0:y/x,++b===i)break t;c=f,f+=s,y=0,x=0}d>c&&(y+=m,x++),(d===-Number.MAX_VALUE||v>1)&&x--,d=g,m=p,M<o?(g=t[M],p=e[M],M++):(g+=u,p=0,v++)}return l}(t,e,s,u,f):function(t,e,r,i,o){var s=t.length,a=(i-r)/(o-1),u=a/2,h=new Array(o),l=t[1]-t[0],c=t[s-1]-t[s-2],f=r-u,d=r+u,m=Number.MIN_VALUE,g=0,p=t[0]-l,v=0,w=0,y=0,x=0,M=0,b=0,A=0,S=0;function _(t,e,r,n){return(n-e)/(r-t)}t:for(;;){for(m<=f&&f<=p&&(R=n(0,f-m,y,g),M=w+R);p-d>=0;){var R=n(0,d-m,y,g);if(b=w+R,h[S++]=(b-M)/a,S===o)break t;f=d,d+=a,M=b}w+=n(m,p,y,x),m=p,g=v,A<s?(p=t[A],v=e[A],A++):A===s&&(p+=c,v=0),y=_(m,g,p,v),x=-y*m+g}return h}(t,e,s,u,f);return d?g.reverse():g},e.integral=n},function(t,e,r){"use strict";e.SNV=function(t){for(var e=n.mean(t),r=n.standardDeviation(t),i=t.slice(),o=0;o<t.length;o++)i[o]=(i[o]-e)/r;return i};var n=r(4).array}])});
//# sourceMappingURL=ml.min.js.map