@datagrok/eda 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/detectors.js +9 -0
- package/dist/111.js +2 -0
- package/dist/146.js +2 -0
- package/dist/155.js +2 -0
- package/dist/355.js +2 -0
- package/dist/584.js +2 -0
- package/dist/604.js +2 -0
- package/dist/632.js +2 -0
- package/dist/645.js +2 -0
- package/dist/93.js +2 -0
- package/dist/d711f70338306e5bddc4.wasm +0 -0
- package/dist/package-test.js +2 -0
- package/dist/package.js +2 -0
- package/package.json +49 -0
- package/package.png +0 -0
- package/scripts/command.txt +1 -0
- package/scripts/exportForTS.py +862 -0
- package/scripts/exportForTSConstants.py +93 -0
- package/scripts/func.json +1 -0
- package/scripts/module.json +11 -0
- package/src/EDAtools.ts +46 -0
- package/src/EDAui.ts +118 -0
- package/src/dataGenerators.ts +74 -0
- package/src/demos.ts +38 -0
- package/src/package-test.ts +12 -0
- package/src/package.ts +248 -0
- package/src/svm.ts +485 -0
- package/src/utils.ts +51 -0
- package/tsconfig.json +71 -0
- package/wasm/EDA.js +443 -0
- package/wasm/EDA.wasm +0 -0
- package/wasm/EDAAPI.js +131 -0
- package/wasm/EDAForWebWorker.js +21 -0
- package/wasm/PCA/PCA.cpp +151 -0
- package/wasm/PCA/PCA.h +48 -0
- package/wasm/PLS/PLS.h +64 -0
- package/wasm/PLS/pls.cpp +393 -0
- package/wasm/callWasm.js +475 -0
- package/wasm/callWasmForWebWorker.js +706 -0
- package/wasm/dataGenerators.h +169 -0
- package/wasm/dataMining.h +116 -0
- package/wasm/pcaExport.cpp +64 -0
- package/wasm/plsExport.cpp +75 -0
- package/wasm/svm.h +608 -0
- package/wasm/svmApi.cpp +323 -0
- package/wasm/workers/errorWorker.js +13 -0
- package/wasm/workers/generateDatasetWorker.js +13 -0
- package/wasm/workers/normalizeDatasetWorker.js +13 -0
- package/wasm/workers/partialLeastSquareRegressionWorker.js +13 -0
- package/wasm/workers/predictByLSSVMWorker.js +13 -0
- package/wasm/workers/principalComponentAnalysisWorker.js +13 -0
- package/wasm/workers/trainAndAnalyzeLSSVMWorker.js +13 -0
- package/wasm/workers/trainLSSVMWorker.js +13 -0
- package/webpack.config.js +37 -0
package/wasm/EDA.js
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
|
|
2
|
+
var exportEDA = (() => {
|
|
3
|
+
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
|
4
|
+
|
|
5
|
+
return (
|
|
6
|
+
function(exportEDA) {
|
|
7
|
+
exportEDA = exportEDA || {};
|
|
8
|
+
|
|
9
|
+
var Module=typeof exportEDA!="undefined"?exportEDA:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||268435456;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}var wasmBinaryFile;wasmBinaryFile="EDA.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["e"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["i"];addOnInit(Module["asm"]["f"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch=="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);readyPromiseReject(e)}}instantiateAsync().catch(readyPromiseReject);return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0};this.init=function(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=prev-1;return prev===1};this.set_adjusted_ptr=function(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr};this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]};this.get_exception_ptr=function(){var isPointer=___cxa_is_pointer_type(this.get_type());if(isPointer){return HEAPU32[this.excPtr>>2]}var adjusted=this.get_adjusted_ptr();if(adjusted!==0)return adjusted;return this.excPtr}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function getHeapMax(){return 2147483648}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}let alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function getCFunc(ident){var func=Module["_"+ident];return func}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret}function cwrap(ident,returnType,argTypes,opts){argTypes=argTypes||[];var numericArgs=argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments,opts)}}var asmLibraryArg={"a":___assert_fail,"b":___cxa_throw,"d":_emscripten_memcpy_big,"c":_emscripten_resize_heap};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["f"]).apply(null,arguments)};var _principalComponentAnalysis=Module["_principalComponentAnalysis"]=function(){return(_principalComponentAnalysis=Module["_principalComponentAnalysis"]=Module["asm"]["g"]).apply(null,arguments)};var _error=Module["_error"]=function(){return(_error=Module["_error"]=Module["asm"]["h"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["j"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["k"]).apply(null,arguments)};var _partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=function(){return(_partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=Module["asm"]["l"]).apply(null,arguments)};var _generateDataset=Module["_generateDataset"]=function(){return(_generateDataset=Module["_generateDataset"]=Module["asm"]["m"]).apply(null,arguments)};var _normalizeDataset=Module["_normalizeDataset"]=function(){return(_normalizeDataset=Module["_normalizeDataset"]=Module["asm"]["n"]).apply(null,arguments)};var _trainLSSVM=Module["_trainLSSVM"]=function(){return(_trainLSSVM=Module["_trainLSSVM"]=Module["asm"]["o"]).apply(null,arguments)};var _predictByLSSVM=Module["_predictByLSSVM"]=function(){return(_predictByLSSVM=Module["_predictByLSSVM"]=Module["asm"]["p"]).apply(null,arguments)};var _trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=function(){return(_trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=Module["asm"]["q"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["r"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["s"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["t"]).apply(null,arguments)};var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=function(){return(___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=Module["asm"]["u"]).apply(null,arguments)};Module["ccall"]=ccall;Module["cwrap"]=cwrap;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
return exportEDA.ready
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
})();
|
|
16
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
17
|
+
module.exports = exportEDA;
|
|
18
|
+
else if (typeof define === 'function' && define['amd'])
|
|
19
|
+
define([], function() { return exportEDA; });
|
|
20
|
+
else if (typeof exports === 'object')
|
|
21
|
+
exports["exportEDA"] = exportEDA;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var principalComponentAnalysis = {
|
|
25
|
+
arguments: {
|
|
26
|
+
columns: {
|
|
27
|
+
type: 'floatColumns'
|
|
28
|
+
},
|
|
29
|
+
componentsCount: {
|
|
30
|
+
type: 'num'
|
|
31
|
+
},
|
|
32
|
+
centerNum: {
|
|
33
|
+
type: 'num'
|
|
34
|
+
},
|
|
35
|
+
scaleNum: {
|
|
36
|
+
type: 'num'
|
|
37
|
+
},
|
|
38
|
+
components: {
|
|
39
|
+
type: 'newFloatColumns',
|
|
40
|
+
numOfRows: {
|
|
41
|
+
ref: 'columns',
|
|
42
|
+
value: 'numOfRows'
|
|
43
|
+
},
|
|
44
|
+
numOfColumns: {
|
|
45
|
+
ref: 'componentsCount',
|
|
46
|
+
value: 'data'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
output: {
|
|
51
|
+
type: 'tableFromColumns',
|
|
52
|
+
source: 'components'
|
|
53
|
+
}
|
|
54
|
+
}; // principalComponentAnalysis
|
|
55
|
+
|
|
56
|
+
var error = {
|
|
57
|
+
arguments: {
|
|
58
|
+
col1: {
|
|
59
|
+
type: 'floatColumn'
|
|
60
|
+
},
|
|
61
|
+
col2: {
|
|
62
|
+
type: 'floatColumn'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
output: {
|
|
66
|
+
type: 'double',
|
|
67
|
+
source: '_callResult'
|
|
68
|
+
}
|
|
69
|
+
}; // error
|
|
70
|
+
|
|
71
|
+
var partialLeastSquareRegression = {
|
|
72
|
+
arguments: {
|
|
73
|
+
features: {
|
|
74
|
+
type: 'floatColumns'
|
|
75
|
+
},
|
|
76
|
+
predict: {
|
|
77
|
+
type: 'floatColumn'
|
|
78
|
+
},
|
|
79
|
+
componentsCount: {
|
|
80
|
+
type: 'num'
|
|
81
|
+
},
|
|
82
|
+
prediction: {
|
|
83
|
+
type: 'newFloatColumn',
|
|
84
|
+
numOfRows: {
|
|
85
|
+
ref: 'predict',
|
|
86
|
+
value: 'numOfRows'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
regressionCoefficients: {
|
|
90
|
+
type: 'newFloatColumn',
|
|
91
|
+
numOfRows: {
|
|
92
|
+
ref: 'features',
|
|
93
|
+
value: 'numOfColumns'
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
tScores: {
|
|
97
|
+
type: 'newFloatColumns',
|
|
98
|
+
numOfRows: {
|
|
99
|
+
ref: 'predict',
|
|
100
|
+
value: 'numOfRows'
|
|
101
|
+
},
|
|
102
|
+
numOfColumns: {
|
|
103
|
+
ref: 'componentsCount',
|
|
104
|
+
value: 'data'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
uScores: {
|
|
108
|
+
type: 'newFloatColumns',
|
|
109
|
+
numOfRows: {
|
|
110
|
+
ref: 'predict',
|
|
111
|
+
value: 'numOfRows'
|
|
112
|
+
},
|
|
113
|
+
numOfColumns: {
|
|
114
|
+
ref: 'componentsCount',
|
|
115
|
+
value: 'data'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
xLoadings: {
|
|
119
|
+
type: 'newFloatColumns',
|
|
120
|
+
numOfRows: {
|
|
121
|
+
ref: 'features',
|
|
122
|
+
value: 'numOfColumns'
|
|
123
|
+
},
|
|
124
|
+
numOfColumns: {
|
|
125
|
+
ref: 'componentsCount',
|
|
126
|
+
value: 'data'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
output: {
|
|
131
|
+
type: 'objects',
|
|
132
|
+
source: ['prediction', 'regressionCoefficients', 'tScores', 'uScores', 'xLoadings']
|
|
133
|
+
}
|
|
134
|
+
}; // partialLeastSquareRegression
|
|
135
|
+
|
|
136
|
+
var generateDataset = {
|
|
137
|
+
arguments: {
|
|
138
|
+
kernel: {
|
|
139
|
+
type: 'num'
|
|
140
|
+
},
|
|
141
|
+
kernelParams: {
|
|
142
|
+
type: 'floatColumn'
|
|
143
|
+
},
|
|
144
|
+
samplesCount: {
|
|
145
|
+
type: 'num'
|
|
146
|
+
},
|
|
147
|
+
featuresCount: {
|
|
148
|
+
type: 'num'
|
|
149
|
+
},
|
|
150
|
+
min: {
|
|
151
|
+
type: 'num'
|
|
152
|
+
},
|
|
153
|
+
max: {
|
|
154
|
+
type: 'num'
|
|
155
|
+
},
|
|
156
|
+
violatorsPercentage: {
|
|
157
|
+
type: 'num'
|
|
158
|
+
},
|
|
159
|
+
dataset: {
|
|
160
|
+
type: 'newFloatColumns',
|
|
161
|
+
numOfRows: {
|
|
162
|
+
ref: 'samplesCount',
|
|
163
|
+
value: 'data'
|
|
164
|
+
},
|
|
165
|
+
numOfColumns: {
|
|
166
|
+
ref: 'featuresCount',
|
|
167
|
+
value: 'data'
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
labels: {
|
|
171
|
+
type: 'newFloatColumn',
|
|
172
|
+
numOfRows: {
|
|
173
|
+
ref: 'samplesCount',
|
|
174
|
+
value: 'data'
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
output: {
|
|
179
|
+
type: 'objects',
|
|
180
|
+
source: ['dataset', 'labels']
|
|
181
|
+
}
|
|
182
|
+
}; // generateDataset
|
|
183
|
+
|
|
184
|
+
var normalizeDataset = {
|
|
185
|
+
arguments: {
|
|
186
|
+
data: {
|
|
187
|
+
type: 'floatColumns'
|
|
188
|
+
},
|
|
189
|
+
normalizedData: {
|
|
190
|
+
type: 'newFloatColumns',
|
|
191
|
+
numOfRows: {
|
|
192
|
+
ref: 'data',
|
|
193
|
+
value: 'numOfColumns'
|
|
194
|
+
},
|
|
195
|
+
numOfColumns: {
|
|
196
|
+
ref: 'data',
|
|
197
|
+
value: 'numOfRows'
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
means: {
|
|
201
|
+
type: 'newFloatColumn',
|
|
202
|
+
numOfRows: {
|
|
203
|
+
ref: 'data',
|
|
204
|
+
value: 'numOfColumns'
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
stdDevs: {
|
|
208
|
+
type: 'newFloatColumn',
|
|
209
|
+
numOfRows: {
|
|
210
|
+
ref: 'data',
|
|
211
|
+
value: 'numOfColumns'
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
output: {
|
|
216
|
+
type: 'objects',
|
|
217
|
+
source: ['normalizedData', 'means', 'stdDevs']
|
|
218
|
+
}
|
|
219
|
+
}; // normalizeDataset
|
|
220
|
+
|
|
221
|
+
var trainLSSVM = {
|
|
222
|
+
arguments: {
|
|
223
|
+
gamma: {
|
|
224
|
+
type: 'num'
|
|
225
|
+
},
|
|
226
|
+
kernel: {
|
|
227
|
+
type: 'num'
|
|
228
|
+
},
|
|
229
|
+
kernelParams: {
|
|
230
|
+
type: 'floatColumn'
|
|
231
|
+
},
|
|
232
|
+
modelParamsCount: {
|
|
233
|
+
type: 'num'
|
|
234
|
+
},
|
|
235
|
+
precomputedWeightsCount: {
|
|
236
|
+
type: 'num'
|
|
237
|
+
},
|
|
238
|
+
dataset: {
|
|
239
|
+
type: 'floatColumns'
|
|
240
|
+
},
|
|
241
|
+
labels: {
|
|
242
|
+
type: 'floatColumn'
|
|
243
|
+
},
|
|
244
|
+
normalizedData: {
|
|
245
|
+
type: 'newFloatColumns',
|
|
246
|
+
numOfRows: {
|
|
247
|
+
ref: 'dataset',
|
|
248
|
+
value: 'numOfColumns'
|
|
249
|
+
},
|
|
250
|
+
numOfColumns: {
|
|
251
|
+
ref: 'dataset',
|
|
252
|
+
value: 'numOfRows'
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
means: {
|
|
256
|
+
type: 'newFloatColumn',
|
|
257
|
+
numOfRows: {
|
|
258
|
+
ref: 'dataset',
|
|
259
|
+
value: 'numOfColumns'
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
stdDevs: {
|
|
263
|
+
type: 'newFloatColumn',
|
|
264
|
+
numOfRows: {
|
|
265
|
+
ref: 'dataset',
|
|
266
|
+
value: 'numOfColumns'
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
modelParams: {
|
|
270
|
+
type: 'newFloatColumn',
|
|
271
|
+
numOfRows: {
|
|
272
|
+
ref: 'modelParamsCount',
|
|
273
|
+
value: 'data'
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
precomputedWeights: {
|
|
277
|
+
type: 'newFloatColumn',
|
|
278
|
+
numOfRows: {
|
|
279
|
+
ref: 'precomputedWeightsCount',
|
|
280
|
+
value: 'data'
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
output: {
|
|
285
|
+
type: 'objects',
|
|
286
|
+
source: ['normalizedData', 'means', 'stdDevs', 'modelParams', 'precomputedWeights']
|
|
287
|
+
}
|
|
288
|
+
}; // trainLSSVM
|
|
289
|
+
|
|
290
|
+
var predictByLSSVM = {
|
|
291
|
+
arguments: {
|
|
292
|
+
kernel: {
|
|
293
|
+
type: 'num'
|
|
294
|
+
},
|
|
295
|
+
kernelParams: {
|
|
296
|
+
type: 'floatColumn'
|
|
297
|
+
},
|
|
298
|
+
normalizedData: {
|
|
299
|
+
type: 'floatColumns'
|
|
300
|
+
},
|
|
301
|
+
labels: {
|
|
302
|
+
type: 'floatColumn'
|
|
303
|
+
},
|
|
304
|
+
means: {
|
|
305
|
+
type: 'floatColumn'
|
|
306
|
+
},
|
|
307
|
+
stdDevs: {
|
|
308
|
+
type: 'floatColumn'
|
|
309
|
+
},
|
|
310
|
+
modelParams: {
|
|
311
|
+
type: 'floatColumn'
|
|
312
|
+
},
|
|
313
|
+
precomputedWeights: {
|
|
314
|
+
type: 'floatColumn'
|
|
315
|
+
},
|
|
316
|
+
targetData: {
|
|
317
|
+
type: 'floatColumns'
|
|
318
|
+
},
|
|
319
|
+
prediction: {
|
|
320
|
+
type: 'newFloatColumn',
|
|
321
|
+
numOfRows: {
|
|
322
|
+
ref: 'targetData',
|
|
323
|
+
value: 'numOfRows'
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
output: {
|
|
328
|
+
type: 'column',
|
|
329
|
+
source: 'prediction'
|
|
330
|
+
}
|
|
331
|
+
}; // predictByLSSVM
|
|
332
|
+
|
|
333
|
+
var trainAndAnalyzeLSSVM = {
|
|
334
|
+
arguments: {
|
|
335
|
+
gamma: {
|
|
336
|
+
type: 'num'
|
|
337
|
+
},
|
|
338
|
+
kernel: {
|
|
339
|
+
type: 'num'
|
|
340
|
+
},
|
|
341
|
+
kernelParams: {
|
|
342
|
+
type: 'floatColumn'
|
|
343
|
+
},
|
|
344
|
+
modelParamsCount: {
|
|
345
|
+
type: 'num'
|
|
346
|
+
},
|
|
347
|
+
precomputedWeightsCount: {
|
|
348
|
+
type: 'num'
|
|
349
|
+
},
|
|
350
|
+
confusionMatrixElementsCount: {
|
|
351
|
+
type: 'num'
|
|
352
|
+
},
|
|
353
|
+
dataset: {
|
|
354
|
+
type: 'floatColumns'
|
|
355
|
+
},
|
|
356
|
+
labels: {
|
|
357
|
+
type: 'floatColumn'
|
|
358
|
+
},
|
|
359
|
+
normalizedData: {
|
|
360
|
+
type: 'newFloatColumns',
|
|
361
|
+
numOfRows: {
|
|
362
|
+
ref: 'dataset',
|
|
363
|
+
value: 'numOfColumns'
|
|
364
|
+
},
|
|
365
|
+
numOfColumns: {
|
|
366
|
+
ref: 'dataset',
|
|
367
|
+
value: 'numOfRows'
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
means: {
|
|
371
|
+
type: 'newFloatColumn',
|
|
372
|
+
numOfRows: {
|
|
373
|
+
ref: 'dataset',
|
|
374
|
+
value: 'numOfColumns'
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
stdDevs: {
|
|
378
|
+
type: 'newFloatColumn',
|
|
379
|
+
numOfRows: {
|
|
380
|
+
ref: 'dataset',
|
|
381
|
+
value: 'numOfColumns'
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
modelParams: {
|
|
385
|
+
type: 'newFloatColumn',
|
|
386
|
+
numOfRows: {
|
|
387
|
+
ref: 'modelParamsCount',
|
|
388
|
+
value: 'data'
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
precomputedWeights: {
|
|
392
|
+
type: 'newFloatColumn',
|
|
393
|
+
numOfRows: {
|
|
394
|
+
ref: 'precomputedWeightsCount',
|
|
395
|
+
value: 'data'
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
predictedLabels: {
|
|
399
|
+
type: 'newFloatColumn',
|
|
400
|
+
numOfRows: {
|
|
401
|
+
ref: 'dataset',
|
|
402
|
+
value: 'numOfRows'
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
correctness: {
|
|
406
|
+
type: 'newFloatColumn',
|
|
407
|
+
numOfRows: {
|
|
408
|
+
ref: 'dataset',
|
|
409
|
+
value: 'numOfRows'
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
consfusionMatrix: {
|
|
413
|
+
type: 'newIntColumn',
|
|
414
|
+
numOfRows: {
|
|
415
|
+
ref: 'confusionMatrixElementsCount',
|
|
416
|
+
value: 'data'
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
output: {
|
|
421
|
+
type: 'objects',
|
|
422
|
+
source: ['normalizedData', 'means', 'stdDevs', 'modelParams', 'precomputedWeights', 'predictedLabels', 'correctness', 'consfusionMatrix']
|
|
423
|
+
}
|
|
424
|
+
}; // trainAndAnalyzeLSSVM
|
|
425
|
+
|
|
426
|
+
var EDA = undefined;
|
|
427
|
+
|
|
428
|
+
async function initEDA() {
|
|
429
|
+
if (EDA === undefined) {
|
|
430
|
+
console.log("Wasm not Loaded, Loading");
|
|
431
|
+
EDA = await exportEDA();
|
|
432
|
+
EDA.principalComponentAnalysis = principalComponentAnalysis;
|
|
433
|
+
EDA.error = error;
|
|
434
|
+
EDA.partialLeastSquareRegression = partialLeastSquareRegression;
|
|
435
|
+
EDA.generateDataset = generateDataset;
|
|
436
|
+
EDA.normalizeDataset = normalizeDataset;
|
|
437
|
+
EDA.trainLSSVM = trainLSSVM;
|
|
438
|
+
EDA.predictByLSSVM = predictByLSSVM;
|
|
439
|
+
EDA.trainAndAnalyzeLSSVM = trainAndAnalyzeLSSVM;
|
|
440
|
+
} else {
|
|
441
|
+
console.log("Wasm Loaded, Passing");
|
|
442
|
+
}
|
|
443
|
+
}
|
package/wasm/EDA.wasm
ADDED
|
Binary file
|
package/wasm/EDAAPI.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// The following code is generated automatically.
|
|
2
|
+
// JavaScript API for call wasm-functions from the module EDA
|
|
3
|
+
|
|
4
|
+
// Imports for call wasm runtime-system: in the main stream and in webworkers
|
|
5
|
+
import {callWasm} from '../wasm/callWasm';
|
|
6
|
+
import {getCppInput, getResult} from '../wasm/callWasmForWebWorker';
|
|
7
|
+
|
|
8
|
+
export async function _initEDAAPI() {
|
|
9
|
+
await initEDA();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function _principalComponentAnalysis(table, columns, componentsCount, centerNum, scaleNum) {
|
|
13
|
+
return callWasm(EDA, 'principalComponentAnalysis', [columns, componentsCount, centerNum, scaleNum]);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function _principalComponentAnalysisInWebWorker(table, columns, componentsCount, centerNum, scaleNum) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const worker = new Worker(new URL('../wasm/workers/principalComponentAnalysisWorker.js', import.meta.url));
|
|
19
|
+
worker.postMessage(getCppInput(EDA['principalComponentAnalysis'].arguments,[columns, componentsCount, centerNum, scaleNum]));
|
|
20
|
+
worker.onmessage = function(e) {
|
|
21
|
+
worker.terminate();
|
|
22
|
+
resolve(getResult(EDA['principalComponentAnalysis'], e.data));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function _error(df, col1, col2) {
|
|
28
|
+
return callWasm(EDA, 'error', [col1, col2]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function _errorInWebWorker(df, col1, col2) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const worker = new Worker(new URL('../wasm/workers/errorWorker.js', import.meta.url));
|
|
34
|
+
worker.postMessage(getCppInput(EDA['error'].arguments,[col1, col2]));
|
|
35
|
+
worker.onmessage = function(e) {
|
|
36
|
+
worker.terminate();
|
|
37
|
+
resolve(getResult(EDA['error'], e.data));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function _partialLeastSquareRegression(table, features, predict, componentsCount) {
|
|
43
|
+
return callWasm(EDA, 'partialLeastSquareRegression', [features, predict, componentsCount]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function _partialLeastSquareRegressionInWebWorker(table, features, predict, componentsCount) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const worker = new Worker(new URL('../wasm/workers/partialLeastSquareRegressionWorker.js', import.meta.url));
|
|
49
|
+
worker.postMessage(getCppInput(EDA['partialLeastSquareRegression'].arguments,[features, predict, componentsCount]));
|
|
50
|
+
worker.onmessage = function(e) {
|
|
51
|
+
worker.terminate();
|
|
52
|
+
resolve(getResult(EDA['partialLeastSquareRegression'], e.data));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function _generateDataset(kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage) {
|
|
58
|
+
return callWasm(EDA, 'generateDataset', [kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function _generateDatasetInWebWorker(kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const worker = new Worker(new URL('../wasm/workers/generateDatasetWorker.js', import.meta.url));
|
|
64
|
+
worker.postMessage(getCppInput(EDA['generateDataset'].arguments,[kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage]));
|
|
65
|
+
worker.onmessage = function(e) {
|
|
66
|
+
worker.terminate();
|
|
67
|
+
resolve(getResult(EDA['generateDataset'], e.data));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function _normalizeDataset(data) {
|
|
73
|
+
return callWasm(EDA, 'normalizeDataset', [data]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function _normalizeDatasetInWebWorker(data) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const worker = new Worker(new URL('../wasm/workers/normalizeDatasetWorker.js', import.meta.url));
|
|
79
|
+
worker.postMessage(getCppInput(EDA['normalizeDataset'].arguments,[data]));
|
|
80
|
+
worker.onmessage = function(e) {
|
|
81
|
+
worker.terminate();
|
|
82
|
+
resolve(getResult(EDA['normalizeDataset'], e.data));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function _trainLSSVM(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels) {
|
|
88
|
+
return callWasm(EDA, 'trainLSSVM', [gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function _trainLSSVMInWebWorker(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels) {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const worker = new Worker(new URL('../wasm/workers/trainLSSVMWorker.js', import.meta.url));
|
|
94
|
+
worker.postMessage(getCppInput(EDA['trainLSSVM'].arguments,[gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels]));
|
|
95
|
+
worker.onmessage = function(e) {
|
|
96
|
+
worker.terminate();
|
|
97
|
+
resolve(getResult(EDA['trainLSSVM'], e.data));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function _predictByLSSVM(kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData) {
|
|
103
|
+
return callWasm(EDA, 'predictByLSSVM', [kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function _predictByLSSVMInWebWorker(kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData) {
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
const worker = new Worker(new URL('../wasm/workers/predictByLSSVMWorker.js', import.meta.url));
|
|
109
|
+
worker.postMessage(getCppInput(EDA['predictByLSSVM'].arguments,[kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData]));
|
|
110
|
+
worker.onmessage = function(e) {
|
|
111
|
+
worker.terminate();
|
|
112
|
+
resolve(getResult(EDA['predictByLSSVM'], e.data));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function _trainAndAnalyzeLSSVM(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels) {
|
|
118
|
+
return callWasm(EDA, 'trainAndAnalyzeLSSVM', [gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function _trainAndAnalyzeLSSVMInWebWorker(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels) {
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
const worker = new Worker(new URL('../wasm/workers/trainAndAnalyzeLSSVMWorker.js', import.meta.url));
|
|
124
|
+
worker.postMessage(getCppInput(EDA['trainAndAnalyzeLSSVM'].arguments,[gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels]));
|
|
125
|
+
worker.onmessage = function(e) {
|
|
126
|
+
worker.terminate();
|
|
127
|
+
resolve(getResult(EDA['trainAndAnalyzeLSSVM'], e.data));
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
export var exportEDA = (() => {
|
|
3
|
+
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
|
4
|
+
|
|
5
|
+
return (
|
|
6
|
+
function(exportEDA) {
|
|
7
|
+
exportEDA = exportEDA || {};
|
|
8
|
+
|
|
9
|
+
var Module=typeof exportEDA!="undefined"?exportEDA:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||268435456;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}var wasmBinaryFile;wasmBinaryFile="EDA.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"){return fetch(new URL('../wasm/EDA.wasm', import.meta.url)).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["e"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["i"];addOnInit(Module["asm"]["f"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch=="function"){return fetch(new URL('../wasm/EDA.wasm', import.meta.url)).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);readyPromiseReject(e)}}instantiateAsync().catch(readyPromiseReject);return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0};this.init=function(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=prev-1;return prev===1};this.set_adjusted_ptr=function(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr};this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]};this.get_exception_ptr=function(){var isPointer=___cxa_is_pointer_type(this.get_type());if(isPointer){return HEAPU32[this.excPtr>>2]}var adjusted=this.get_adjusted_ptr();if(adjusted!==0)return adjusted;return this.excPtr}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function getHeapMax(){return 2147483648}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}let alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function getCFunc(ident){var func=Module["_"+ident];return func}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret}function cwrap(ident,returnType,argTypes,opts){argTypes=argTypes||[];var numericArgs=argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments,opts)}}var asmLibraryArg={"a":___assert_fail,"b":___cxa_throw,"d":_emscripten_memcpy_big,"c":_emscripten_resize_heap};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["f"]).apply(null,arguments)};var _principalComponentAnalysis=Module["_principalComponentAnalysis"]=function(){return(_principalComponentAnalysis=Module["_principalComponentAnalysis"]=Module["asm"]["g"]).apply(null,arguments)};var _error=Module["_error"]=function(){return(_error=Module["_error"]=Module["asm"]["h"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["j"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["k"]).apply(null,arguments)};var _partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=function(){return(_partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=Module["asm"]["l"]).apply(null,arguments)};var _generateDataset=Module["_generateDataset"]=function(){return(_generateDataset=Module["_generateDataset"]=Module["asm"]["m"]).apply(null,arguments)};var _normalizeDataset=Module["_normalizeDataset"]=function(){return(_normalizeDataset=Module["_normalizeDataset"]=Module["asm"]["n"]).apply(null,arguments)};var _trainLSSVM=Module["_trainLSSVM"]=function(){return(_trainLSSVM=Module["_trainLSSVM"]=Module["asm"]["o"]).apply(null,arguments)};var _predictByLSSVM=Module["_predictByLSSVM"]=function(){return(_predictByLSSVM=Module["_predictByLSSVM"]=Module["asm"]["p"]).apply(null,arguments)};var _trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=function(){return(_trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=Module["asm"]["q"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["r"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["s"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["t"]).apply(null,arguments)};var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=function(){return(___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=Module["asm"]["u"]).apply(null,arguments)};Module["ccall"]=ccall;Module["cwrap"]=cwrap;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
return exportEDA.ready
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
})();
|
|
16
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
17
|
+
module.exports = exportEDA;
|
|
18
|
+
else if (typeof define === 'function' && define['amd'])
|
|
19
|
+
define([], function() { return exportEDA; });
|
|
20
|
+
else if (typeof exports === 'object')
|
|
21
|
+
exports["exportEDA"] = exportEDA;
|