@datagrok/eda 1.2.3 → 1.2.4

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/src/eda-tools.ts CHANGED
@@ -4,32 +4,67 @@ import * as grok from 'datagrok-api/grok';
4
4
  import * as ui from 'datagrok-api/ui';
5
5
  import * as DG from 'datagrok-api/dg';
6
6
 
7
- import {_principalComponentAnalysisInWebWorker,
8
- _partialLeastSquareRegressionInWebWorker} from '../wasm/EDAAPI';
7
+ import {_principalComponentAnalysisInWebWorker, _principalComponentAnalysis,
8
+ _partialLeastSquareRegressionInWebWorker,
9
+ _principalComponentAnalysisNipals, _principalComponentAnalysisNipalsInWebWorker,
10
+ } from '../wasm/EDAAPI';
9
11
 
10
- import {checkWasmDimensionReducerInputs, checkUMAPinputs, checkTSNEinputs,
11
- getRowsOfNumericalColumnns} from './utils';
12
+ import {checkWasmDimensionReducerInputs, checkUMAPinputs, checkTSNEinputs, NIPALS_PREFER_COLS_COUNT,
13
+ getRowsOfNumericalColumnns, centerScaleDataFrame, extractNonConstantColsDf} from './utils';
12
14
 
13
15
  // Principal components analysis (PCA)
14
16
  export async function computePCA(table: DG.DataFrame, features: DG.ColumnList, components: number,
15
- center: boolean, scale: boolean): Promise<DG.DataFrame> {
17
+ toCenter: boolean, toScale: boolean): Promise<DG.DataFrame> {
16
18
  checkWasmDimensionReducerInputs(features, components);
17
19
 
18
- const centerNum = center ? 1 : 0;
19
- const scaleNum = scale ? 1 : 0;
20
+ const rowCount = table.rowCount;
20
21
 
21
- return await _principalComponentAnalysisInWebWorker(table, features, components, centerNum, scaleNum);
22
- }
22
+ // Extract non-const cols dataframe
23
+ const nonConstData = extractNonConstantColsDf(features);
24
+ const nonConstColsCount = nonConstData.columns.length;
23
25
 
24
- // Partial least square regression (PLS): TO REMOVE
25
- export async function computePLS(
26
- table: DG.DataFrame, features: DG.ColumnList, predict: DG.Column, components: number,
27
- ): Promise<any> {
28
- // Inputs are checked in the same manner as in PCA, since the same computations are applied.
29
- checkWasmDimensionReducerInputs(features, components);
26
+ // Return zero columns if data is constant
27
+ if (nonConstColsCount === 0) {
28
+ const cols: DG.Column[] = [];
29
+
30
+ for (let i = 0; i < components; ++i)
31
+ cols.push(DG.Column.fromFloat32Array(`${i + 1}`, new Float32Array(rowCount).fill(0)));
32
+
33
+ return DG.DataFrame.fromColumns(cols);
34
+ }
35
+
36
+ const zeroColsToAdd = (nonConstColsCount < components) ? (components - nonConstColsCount) : 0;
37
+ const componentsToCompute = Math.min(components, nonConstColsCount);
38
+
39
+ let output: DG.DataFrame | undefined = undefined;
40
+
41
+ // PCA
42
+ if (nonConstColsCount > NIPALS_PREFER_COLS_COUNT)
43
+ output = await _principalComponentAnalysisNipalsInWebWorker(table, features, componentsToCompute);
44
+ else {
45
+ //try to apply the classic algorithm
46
+ const res = await _principalComponentAnalysisInWebWorker(table, features, componentsToCompute);
47
+
48
+ if (res !== -1) // the classic succeed
49
+ output = centerScaleDataFrame(res, toCenter, toScale);
50
+ else // the classic failed
51
+ output = await _principalComponentAnalysisNipalsInWebWorker(table, features, componentsToCompute);
52
+ }
53
+
54
+ if (output === undefined)
55
+ throw new Error('Failed to compute PCA');
56
+
57
+ output = centerScaleDataFrame(output, toCenter, toScale);
58
+
59
+ const cols = output.columns;
60
+ const count = cols.length;
61
+
62
+ // Add zero columns (with respect to the const cols count)
63
+ for (let i = 0; i < zeroColsToAdd; ++i)
64
+ cols.add(DG.Column.fromFloat32Array(`${count + i + 1}`, new Float32Array(rowCount).fill(0)));
30
65
 
31
- return await _partialLeastSquareRegressionInWebWorker(table, features, predict, components);
32
- }
66
+ return output;
67
+ } // computePCA
33
68
 
34
69
  // Uniform Manifold Approximation and Projection (UMAP)
35
70
  export async function computeUMAP(features: DG.ColumnList, components: number, epochs: number,
package/src/eda-ui.ts CHANGED
@@ -17,117 +17,3 @@ export function addPrefixToEachColumnName(prefix: string, columns: DG.ColumnList
17
17
  for (const col of columns.toList())
18
18
  col.name = prefix + col.name;
19
19
  }
20
-
21
- // Predicted vs Reference scatter plot
22
- export function predictedVersusReferenceScatterPlot(
23
- samplesNames: DG.Column, reference: DG.Column, prediction: DG.Column,
24
- ): DG.Viewer {
25
- prediction.name = reference.name + '(predicted)';
26
-
27
- const dfReferencePrediction = DG.DataFrame.fromColumns([samplesNames, reference, prediction]);
28
- dfReferencePrediction.name = 'Reference vs. Predicted';
29
-
30
- return DG.Viewer.scatterPlot(dfReferencePrediction,
31
- {title: dfReferencePrediction.name,
32
- x: reference.name,
33
- y: prediction.name,
34
- showRegressionLine: true,
35
- markerType: 'circle',
36
- labels: samplesNames.name,
37
- });
38
- }
39
-
40
- // Regression Coefficients Bar Chart
41
- export function regressionCoefficientsBarChart(features: DG.ColumnList, regressionCoeffs: DG.Column): DG.Viewer {
42
- regressionCoeffs.name = 'regression coefficient';
43
-
44
- const namesOfPredictors = [];
45
- for (const col of features)
46
- namesOfPredictors.push(col.name);
47
-
48
- const predictorNamesColumn = DG.Column.fromStrings('feature', namesOfPredictors);
49
-
50
- const dfRegrCoefs = DG.DataFrame.fromColumns([predictorNamesColumn, regressionCoeffs]);
51
- dfRegrCoefs.name = 'Regression Coefficients';
52
-
53
- return DG.Viewer.barChart(dfRegrCoefs,
54
- {title: dfRegrCoefs.name, split: 'feature',
55
- value: 'regression coefficient', valueAggrType: 'avg'});
56
- }
57
-
58
- // Scores Scatter Plot
59
- export function scoresScatterPlot(
60
- samplesNames: DG.Column, xScores: Array<DG.Column>, yScores: Array<DG.Column>,
61
- ): DG.Viewer {
62
- const scoresColumns = [samplesNames];
63
-
64
- for (let i = 0; i < xScores.length; i++) {
65
- xScores[i].name = `x.score.t${i+1}`;
66
- scoresColumns.push(xScores[i]);
67
- }
68
-
69
- for (let i = 0; i < yScores.length; i++) {
70
- yScores[i].name = `y.score.u${i+1}`;
71
- scoresColumns.push(yScores[i]);
72
- }
73
-
74
- const scores = DG.DataFrame.fromColumns(scoresColumns);
75
- scores.name = 'Scores';
76
- //grok.shell.addTableView(scores);
77
-
78
- const index = xScores.length > 1 ? 1 : 0;
79
-
80
- return DG.Viewer.scatterPlot(scores,
81
- {title: scores.name,
82
- x: xScores[0].name,
83
- y: xScores[index].name,
84
- markerType: 'circle',
85
- labels: samplesNames.name,
86
- });
87
- }
88
-
89
- // Loading Scatter Plot
90
- export function loadingScatterPlot(features: DG.ColumnList, xLoadings: Array<DG.Column>): DG.Viewer {
91
- const loadingCols = [];
92
-
93
- const loadingLabels = [];
94
- for (const col of features)
95
- loadingLabels.push(col.name);
96
-
97
- loadingCols.push(DG.Column.fromStrings('labels', loadingLabels));
98
-
99
- for (let i = 0; i < xLoadings.length; i++) {
100
- xLoadings[i].name = `x.loading.p${i+1}`;
101
- loadingCols.push(xLoadings[i]);
102
- }
103
-
104
- const dfLoadings = DG.DataFrame.fromColumns(loadingCols);
105
- dfLoadings.name = 'Loadings';
106
-
107
- return DG.Viewer.scatterPlot(dfLoadings,
108
- {title: dfLoadings.name,
109
- x: xLoadings[0].name,
110
- y: xLoadings[xLoadings.length - 1].name,
111
- markerType: 'circle',
112
- labels: 'labels',
113
- });
114
- }
115
-
116
- // Add PLS visualization
117
- export function addPLSvisualization(
118
- table: DG.DataFrame, samplesNames: DG.Column, features: DG.ColumnList, predict: DG.Column, plsOutput: any,
119
- ): void {
120
- const view = (table.id !== null) ? grok.shell.getTableView(table.name) : grok.shell.addTableView(table);
121
-
122
- // 1. Predicted vs Reference scatter plot
123
- view.addViewer(predictedVersusReferenceScatterPlot(samplesNames, predict, plsOutput[0]));
124
-
125
- // 2. Regression Coefficients Bar Chart
126
- view.addViewer(regressionCoefficientsBarChart(features, plsOutput[1]));
127
-
128
- // 3. Loading Scatter Plot
129
- view.addViewer(loadingScatterPlot(features, plsOutput[4]));
130
-
131
- // 4. Scores Scatter Plot
132
- view.addViewer(scoresScatterPlot(samplesNames, plsOutput[2], plsOutput[3]));
133
- }
@@ -26,7 +26,7 @@ export const COPY_SUFFIX = 'copy';
26
26
 
27
27
  /** UI titles */
28
28
  export enum TITLE {
29
- KNN_IMPUTER = 'Impute',
29
+ KNN_IMPUTER = 'KNN Imputation',
30
30
  TABLE = 'Table',
31
31
  IN_PLACE = 'In-place',
32
32
  COLUMNS = 'Impute',
package/src/package.ts CHANGED
@@ -73,23 +73,27 @@ export async function dbScan(df: DG.DataFrame, xCol: DG.Column, yCol: DG.Column,
73
73
  //name: PCA
74
74
  //description: Principal component analysis (PCA)
75
75
  //input: dataframe table
76
- //input: column_list features {type: numerical}
77
- //input: int components = 2 {caption: Components} [Number of components.]
76
+ //input: column_list features {type: numerical; allowNulls: false}
77
+ //input: int components = 2 {caption: Components; nullable: false; min: 1} [Number of components.]
78
78
  //input: bool center = false [Indicating whether the variables should be shifted to be zero centered.]
79
79
  //input: bool scale = false [Indicating whether the variables should be scaled to have unit variance.]
80
80
  export async function PCA(table: DG.DataFrame, features: DG.ColumnList, components: number, center: boolean, scale: boolean): Promise<void> {
81
- const pcaTable = await computePCA(table, features, components, center, scale);
82
- addPrefixToEachColumnName('PC', pcaTable.columns);
83
-
84
- if (table.id === null) // table is loaded from a local file
85
- grok.shell.addTableView(pcaTable);
86
- else {
87
- const cols = table.columns;
88
-
89
- for (const col of pcaTable.columns) {
90
- col.name = cols.getUnusedName(col.name);
91
- cols.add(col);
81
+ try {
82
+ const pcaTable = await computePCA(table, features, components, center, scale);
83
+ addPrefixToEachColumnName('PC', pcaTable.columns);
84
+
85
+ if (table.id === null) // table is loaded from a local file
86
+ grok.shell.addTableView(pcaTable);
87
+ else {
88
+ const cols = table.columns;
89
+
90
+ for (const col of pcaTable.columns) {
91
+ col.name = cols.getUnusedName(col.name);
92
+ cols.add(col);
93
+ }
92
94
  }
95
+ } catch (error) {
96
+ grok.shell.warning(`Failed to compute PCA: ${error instanceof Error ? error.message : 'platform issue'}`);
93
97
  }
94
98
  }
95
99
 
@@ -552,15 +556,15 @@ export function anova(): void {
552
556
  runOneWayAnova();
553
557
  }
554
558
 
555
- //top-menu: ML | Missing Values Imputation ...
559
+ //top-menu: ML | Impute Missing Values...
556
560
  //name: KNN impute
557
- //desription: Missing values imputation using the k-nearest neighbors method
561
+ //description: Missing values imputation using the k-nearest neighbors method (KNN)
558
562
  export function kNNImputation() {
559
563
  runKNNImputer();
560
564
  }
561
565
 
562
566
  //name: KNN imputation for a table
563
- //desription: Missing values imputation using the k-nearest neighbors method for a given table
567
+ //description: Missing values imputation using the k-nearest neighbors method
564
568
  //input: dataframe table
565
569
  export async function kNNImputationForTable(table: DG.DataFrame) {
566
570
  await runKNNImputer(table);
@@ -50,13 +50,13 @@ export enum HINT {
50
50
 
51
51
  /** Links to help */
52
52
  export enum LINK {
53
- PLS = 'https://datagrok.ai/help/explore/multivariate-analysis/pls#pls-components',
54
- MVA = 'https://datagrok.ai/help/explore/multivariate-analysis/pls',
55
- MODEL = 'https://datagrok.ai/help/explore/multivariate-analysis/plots/predicted-vs-reference',
56
- COEFFS = 'https://datagrok.ai/help/explore/multivariate-analysis/plots/regression-coefficients',
57
- LOADINGS = 'https://datagrok.ai/help/explore/multivariate-analysis/plots/loadings',
58
- EXPL_VARS = 'https://datagrok.ai/help/explore/multivariate-analysis/plots/explained-variance',
59
- SCORES = 'https://datagrok.ai/help/explore/multivariate-analysis/plots/scores',
53
+ PLS = '/help/explore/multivariate-analysis/pls#pls-components',
54
+ MVA = '/help/explore/multivariate-analysis/pls',
55
+ MODEL = '/help/explore/multivariate-analysis/plots/predicted-vs-reference',
56
+ COEFFS = '/help/explore/multivariate-analysis/plots/regression-coefficients',
57
+ LOADINGS = '/help/explore/multivariate-analysis/plots/loadings',
58
+ EXPL_VARS = '/help/explore/multivariate-analysis/plots/explained-variance',
59
+ SCORES = '/help/explore/multivariate-analysis/plots/scores',
60
60
  }
61
61
 
62
62
  /** Components consts */
package/src/pls/pls-ml.ts CHANGED
@@ -276,7 +276,8 @@ export class PlsModel {
276
276
  xColumnName: columns.byIndex(shift).name,
277
277
  yColumnName: columns.byIndex(shift + (components > 1 ? 1 : 0)).name,
278
278
  markerType: DG.MARKER_TYPE.CIRCLE,
279
- labels: TITLE.FEATURES,
279
+ //@ts-ignore
280
+ labelFormColumnNames: [TITLE.FEATURES],
280
281
  help: LINK.LOADINGS,
281
282
  }));
282
283
 
@@ -161,10 +161,13 @@ async function performMVA(input: PlsInput, analysisType: PLS_ANALYSIS): Promise<
161
161
  yColumnName: pred.name,
162
162
  showRegressionLine: true,
163
163
  markerType: DG.MARKER_TYPE.CIRCLE,
164
- labels: input.names?.name,
164
+ showLabels: 'Always',
165
165
  help: LINK.MODEL,
166
166
  }));
167
167
 
168
+ if ((input.names !== undefined) && (input.names !== null))
169
+ predictVsReferScatter.setOptions({labelFormColumnNames: [input.names?.name]});
170
+
168
171
  // 2. Regression Coefficients Bar Chart
169
172
  result.regressionCoefficients.name = TITLE.REGR_COEFS;
170
173
  const regrCoeffsBar = view.addViewer(DG.Viewer.barChart(buffer, {
@@ -184,7 +187,7 @@ async function performMVA(input: PlsInput, analysisType: PLS_ANALYSIS): Promise<
184
187
  xColumnName: `${TITLE.XLOADING}1`,
185
188
  yColumnName: `${TITLE.XLOADING}${result.xLoadings.length > 1 ? '2' : '1'}`,
186
189
  markerType: DG.MARKER_TYPE.CIRCLE,
187
- labels: TITLE.FEATURE,
190
+ labelFormColumnNames: [TITLE.FEATURE],
188
191
  help: LINK.LOADINGS,
189
192
  }));
190
193
 
@@ -204,11 +207,13 @@ async function performMVA(input: PlsInput, analysisType: PLS_ANALYSIS): Promise<
204
207
  xColumnName: plsCols[0].name,
205
208
  yColumnName: (plsCols.length > 1) ? plsCols[1].name : result.uScores[0].name,
206
209
  markerType: DG.MARKER_TYPE.CIRCLE,
207
- labels: input.names?.name,
208
210
  help: LINK.SCORES,
209
211
  showViewerFormulaLines: true,
210
212
  });
211
213
 
214
+ if ((input.names !== undefined) && (input.names !== null))
215
+ predictVsReferScatter.setOptions({labelFormColumnNames: [input.names?.name]});
216
+
212
217
  // 4.3) create lines & circles
213
218
  scoresScatter.meta.formulaLines.addAll(getLines(scoreNames));
214
219
  view.addViewer(scoresScatter);
@@ -83,5 +83,5 @@ category('ANOVA', () => {
83
83
 
84
84
  // check F-critical
85
85
  expect(eq(analysis.fCritical, EXPECTED.F_CRIT), true, 'Incorrect F-critical');
86
- }, {timeout: TIMEOUT, benchmark: true});
86
+ }, {timeout: TIMEOUT});
87
87
  });
@@ -16,7 +16,7 @@ const ROWS = 100;
16
16
  const ROWS_K = 100;
17
17
  const COLS = 100;
18
18
  const COMPONENTS = 3;
19
- const TIMEOUT = 8000;
19
+ const TIMEOUT = 9000;
20
20
  const INDEP_COLS = 2;
21
21
  const DEP_COLS = 5;
22
22
  const ERROR = 0.1;
@@ -27,6 +27,11 @@ category('Principal component analysis', () => {
27
27
  await computePCA(df, df.columns, COMPONENTS, false, false);
28
28
  }, {timeout: TIMEOUT, benchmark: true});
29
29
 
30
+ test(`Performance: 1K rows, 5K cols, ${COMPONENTS} components`, async () => {
31
+ const df = grok.data.demo.randomWalk(1000, 5000);
32
+ await computePCA(df, df.columns, COMPONENTS, false, false);
33
+ }, {timeout: TIMEOUT, benchmark: true});
34
+
30
35
  test('Correctness', async () => {
31
36
  // Data
32
37
  const df = regressionDataset(ROWS, COMPONENTS, DEP_COLS);
package/src/utils.ts CHANGED
@@ -11,6 +11,9 @@ const FEATURES_COUNT_MIN = 1;
11
11
  const PERCENTAGE_MIN = 0;
12
12
  const PERCENTAGE_MAX = 100;
13
13
  const MAX_ELEMENTS_COUNT = 100000000;
14
+ export const NIPALS_PREFER_COLS_COUNT = 900;
15
+
16
+ const TINY = 0.000001;
14
17
 
15
18
  // Error messages
16
19
  const COMP_POSITVE_MES = 'components must be positive.';
@@ -180,3 +183,90 @@ export function getRowsOfNumericalColumnns(columnList: DG.ColumnList): any[][] {
180
183
 
181
184
  return output;
182
185
  }
186
+
187
+ /** Return centered data */
188
+ function centerDf(df: DG.DataFrame): DG.DataFrame {
189
+ const rowCount = df.rowCount;
190
+
191
+ for (const col of df.columns) {
192
+ if (col.isNumerical) {
193
+ const avg = col.stats.avg;
194
+
195
+ if (Math.abs(avg) > TINY) {
196
+ const raw = col.getRawData();
197
+
198
+ for (let i = 0; i < rowCount; ++i)
199
+ raw[i] -= avg;
200
+ }
201
+ }
202
+ }
203
+ return df;
204
+ }
205
+
206
+ /** Return scaled & centered data */
207
+ function centerScaleDf(df: DG.DataFrame): DG.DataFrame {
208
+ const rowCount = df.rowCount;
209
+
210
+ for (const col of df.columns) {
211
+ if (col.isNumerical) {
212
+ const stdev = col.stats.stdev;
213
+ const avg = col.stats.avg;
214
+ const raw = col.getRawData();
215
+
216
+ if (stdev > 0) {
217
+ for (let i = 0; i < rowCount; ++i)
218
+ raw[i] = (raw[i] - avg) / stdev;
219
+ } else {
220
+ for (let i = 0; i < rowCount; ++i)
221
+ raw[i] -= avg;
222
+ }
223
+ }
224
+ }
225
+ return df;
226
+ }
227
+
228
+ /** Return scaled data */
229
+ function scaleDf(df: DG.DataFrame): DG.DataFrame {
230
+ const rowCount = df.rowCount;
231
+
232
+ for (const col of df.columns) {
233
+ if (col.isNumerical) {
234
+ const stdev = col.stats.stdev;
235
+
236
+ if (Math.abs(stdev - 1) > TINY && (stdev > 0)) {
237
+ const raw = col.getRawData();
238
+
239
+ for (let i = 0; i < rowCount; ++i)
240
+ raw[i] /= stdev;
241
+ }
242
+ }
243
+ }
244
+ return df;
245
+ }
246
+
247
+ /** Return standartized dataframe */
248
+ export function centerScaleDataFrame(df: DG.DataFrame, toCenter: boolean, toScale: boolean): DG.DataFrame {
249
+ if (toCenter) {
250
+ if (toScale)
251
+ return centerScaleDf(df);
252
+ else
253
+ return centerDf(df);
254
+ }
255
+
256
+ if (toScale)
257
+ return scaleDf(df);
258
+
259
+ return df;
260
+ }
261
+
262
+ /** Return table of columns with non-zero variance */
263
+ export function extractNonConstantColsDf(features: DG.ColumnList): DG.DataFrame {
264
+ const cols: DG.Column[]= [];
265
+
266
+ for (const col of features) {
267
+ if ((col.stats.stdev > 0) && (col.stats.missingValueCount < 1))
268
+ cols.push(col);
269
+ }
270
+
271
+ return DG.DataFrame.fromColumns(cols);
272
+ }
package/wasm/EDA.js CHANGED
@@ -6,7 +6,7 @@ var exportEDA = (() => {
6
6
  function(exportEDA) {
7
7
  exportEDA = exportEDA || {};
8
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"]["f"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["j"];addOnInit(Module["asm"]["g"]);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 _abort(){abort("")}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,"c":_abort,"e":_emscripten_memcpy_big,"d":_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"]["g"]).apply(null,arguments)};var _principalComponentAnalysis=Module["_principalComponentAnalysis"]=function(){return(_principalComponentAnalysis=Module["_principalComponentAnalysis"]=Module["asm"]["h"]).apply(null,arguments)};var _error=Module["_error"]=function(){return(_error=Module["_error"]=Module["asm"]["i"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["k"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["l"]).apply(null,arguments)};var _partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=function(){return(_partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=Module["asm"]["m"]).apply(null,arguments)};var _generateDataset=Module["_generateDataset"]=function(){return(_generateDataset=Module["_generateDataset"]=Module["asm"]["n"]).apply(null,arguments)};var _normalizeDataset=Module["_normalizeDataset"]=function(){return(_normalizeDataset=Module["_normalizeDataset"]=Module["asm"]["o"]).apply(null,arguments)};var _trainLSSVM=Module["_trainLSSVM"]=function(){return(_trainLSSVM=Module["_trainLSSVM"]=Module["asm"]["p"]).apply(null,arguments)};var _predictByLSSVM=Module["_predictByLSSVM"]=function(){return(_predictByLSSVM=Module["_predictByLSSVM"]=Module["asm"]["q"]).apply(null,arguments)};var _trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=function(){return(_trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=Module["asm"]["r"]).apply(null,arguments)};var _fitLinearRegressionParamsWithDataNormalizing=Module["_fitLinearRegressionParamsWithDataNormalizing"]=function(){return(_fitLinearRegressionParamsWithDataNormalizing=Module["_fitLinearRegressionParamsWithDataNormalizing"]=Module["asm"]["s"]).apply(null,arguments)};var _fitLinearRegressionParams=Module["_fitLinearRegressionParams"]=function(){return(_fitLinearRegressionParams=Module["_fitLinearRegressionParams"]=Module["asm"]["t"]).apply(null,arguments)};var _fitSoftmax=Module["_fitSoftmax"]=function(){return(_fitSoftmax=Module["_fitSoftmax"]=Module["asm"]["u"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["v"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["w"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["x"]).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"]["y"]).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();
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"]["f"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["k"];addOnInit(Module["asm"]["g"]);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 _abort(){abort("")}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,"c":_abort,"e":_emscripten_memcpy_big,"d":_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"]["g"]).apply(null,arguments)};var _principalComponentAnalysis=Module["_principalComponentAnalysis"]=function(){return(_principalComponentAnalysis=Module["_principalComponentAnalysis"]=Module["asm"]["h"]).apply(null,arguments)};var _error=Module["_error"]=function(){return(_error=Module["_error"]=Module["asm"]["i"]).apply(null,arguments)};var _principalComponentAnalysisNipals=Module["_principalComponentAnalysisNipals"]=function(){return(_principalComponentAnalysisNipals=Module["_principalComponentAnalysisNipals"]=Module["asm"]["j"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["l"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["m"]).apply(null,arguments)};var _partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=function(){return(_partialLeastSquareRegression=Module["_partialLeastSquareRegression"]=Module["asm"]["n"]).apply(null,arguments)};var _generateDataset=Module["_generateDataset"]=function(){return(_generateDataset=Module["_generateDataset"]=Module["asm"]["o"]).apply(null,arguments)};var _normalizeDataset=Module["_normalizeDataset"]=function(){return(_normalizeDataset=Module["_normalizeDataset"]=Module["asm"]["p"]).apply(null,arguments)};var _trainLSSVM=Module["_trainLSSVM"]=function(){return(_trainLSSVM=Module["_trainLSSVM"]=Module["asm"]["q"]).apply(null,arguments)};var _predictByLSSVM=Module["_predictByLSSVM"]=function(){return(_predictByLSSVM=Module["_predictByLSSVM"]=Module["asm"]["r"]).apply(null,arguments)};var _trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=function(){return(_trainAndAnalyzeLSSVM=Module["_trainAndAnalyzeLSSVM"]=Module["asm"]["s"]).apply(null,arguments)};var _fitLinearRegressionParamsWithDataNormalizing=Module["_fitLinearRegressionParamsWithDataNormalizing"]=function(){return(_fitLinearRegressionParamsWithDataNormalizing=Module["_fitLinearRegressionParamsWithDataNormalizing"]=Module["asm"]["t"]).apply(null,arguments)};var _fitLinearRegressionParams=Module["_fitLinearRegressionParams"]=function(){return(_fitLinearRegressionParams=Module["_fitLinearRegressionParams"]=Module["asm"]["u"]).apply(null,arguments)};var _fitSoftmax=Module["_fitSoftmax"]=function(){return(_fitSoftmax=Module["_fitSoftmax"]=Module["asm"]["v"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["w"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["x"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["y"]).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"]["z"]).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
10
 
11
11
 
12
12
  return exportEDA.ready
@@ -68,6 +68,32 @@ var error = {
68
68
  }
69
69
  }; // error
70
70
 
71
+ var principalComponentAnalysisNipals = {
72
+ arguments: {
73
+ columns: {
74
+ type: 'floatColumns'
75
+ },
76
+ componentsCount: {
77
+ type: 'num'
78
+ },
79
+ components: {
80
+ type: 'newFloatColumns',
81
+ numOfRows: {
82
+ ref: 'columns',
83
+ value: 'numOfRows'
84
+ },
85
+ numOfColumns: {
86
+ ref: 'componentsCount',
87
+ value: 'data'
88
+ }
89
+ }
90
+ },
91
+ output: {
92
+ type: 'tableFromColumns',
93
+ source: 'components'
94
+ }
95
+ }; // principalComponentAnalysisNipals
96
+
71
97
  var partialLeastSquareRegression = {
72
98
  arguments: {
73
99
  features: {
@@ -553,6 +579,7 @@ async function initEDA() {
553
579
  EDA = await exportEDA();
554
580
  EDA.principalComponentAnalysis = principalComponentAnalysis;
555
581
  EDA.error = error;
582
+ EDA.principalComponentAnalysisNipals = principalComponentAnalysisNipals;
556
583
  EDA.partialLeastSquareRegression = partialLeastSquareRegression;
557
584
  EDA.generateDataset = generateDataset;
558
585
  EDA.normalizeDataset = normalizeDataset;
package/wasm/EDA.wasm CHANGED
Binary file
package/wasm/EDAAPI.js CHANGED
@@ -13,13 +13,16 @@ export function _principalComponentAnalysis(table, columns, componentsCount, cen
13
13
  return callWasm(EDA, 'principalComponentAnalysis', [columns, componentsCount, centerNum, scaleNum]);
14
14
  }
15
15
 
16
- export async function _principalComponentAnalysisInWebWorker(table, columns, componentsCount, centerNum, scaleNum) {
16
+ export async function _principalComponentAnalysisInWebWorker(table, columns, componentsCount) {
17
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]));
18
+ const worker = new Worker(new URL('../wasm/workers/principalComponentAnalysisWorkerUpd.js', import.meta.url));
19
+ worker.postMessage(getCppInput(EDA['principalComponentAnalysis'].arguments, [columns, componentsCount, 1, 0]));
20
20
  worker.onmessage = function(e) {
21
21
  worker.terminate();
22
- resolve(getResult(EDA['principalComponentAnalysis'], e.data));
22
+ if (e.data.callResult === 0)
23
+ resolve(getResult(EDA['principalComponentAnalysis'], e.data));
24
+ else
25
+ resolve(-1);
23
26
  }
24
27
  });
25
28
  }
@@ -39,6 +42,21 @@ export async function _errorInWebWorker(df, col1, col2) {
39
42
  });
40
43
  }
41
44
 
45
+ export function _principalComponentAnalysisNipals(table, columns, componentsCount) {
46
+ return callWasm(EDA, 'principalComponentAnalysisNipals', [columns, componentsCount]);
47
+ }
48
+
49
+ export async function _principalComponentAnalysisNipalsInWebWorker(table, columns, componentsCount) {
50
+ return new Promise((resolve, reject) => {
51
+ const worker = new Worker(new URL('../wasm/workers/principalComponentAnalysisNipalsWorker.js', import.meta.url));
52
+ worker.postMessage(getCppInput(EDA['principalComponentAnalysisNipals'].arguments,[columns, componentsCount]));
53
+ worker.onmessage = function(e) {
54
+ worker.terminate();
55
+ resolve(getResult(EDA['principalComponentAnalysisNipals'], e.data));
56
+ }
57
+ });
58
+ }
59
+
42
60
  export function _partialLeastSquareRegression(table, features, predict, componentsCount) {
43
61
  return callWasm(EDA, 'partialLeastSquareRegression', [features, predict, componentsCount]);
44
62
  }