@datagrok/eda 1.3.1 → 1.3.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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@datagrok/eda",
3
3
  "friendlyName": "EDA",
4
- "version": "1.3.1",
4
+ "version": "1.3.3",
5
5
  "description": "Exploratory Data Analysis Tools",
6
6
  "dependencies": {
7
7
  "@datagrok-libraries/math": "^1.2.4",
8
- "@datagrok-libraries/ml": "^6.8.0",
8
+ "@datagrok-libraries/ml": "^6.8.1",
9
9
  "@datagrok-libraries/tutorials": "^1.4.2",
10
10
  "@datagrok-libraries/utils": "^4.4.0",
11
11
  "@keckelt/tsne": "^1.0.2",
package/src/package.ts CHANGED
@@ -194,7 +194,7 @@ export async function reduceDimensionality(): Promise<void> {
194
194
  export function GetMCLEditor(call: DG.FuncCall): void {
195
195
  try {
196
196
  const funcEditor = new MCLEditor();
197
- ui.dialog('Markov clustering')
197
+ const dialog = ui.dialog('Markov clustering')
198
198
  .add(funcEditor.getEditor())
199
199
  .onOK(async () => {
200
200
  const params = funcEditor.params;
@@ -205,6 +205,7 @@ export function GetMCLEditor(call: DG.FuncCall): void {
205
205
  useWebGPU: params.useWebGPU, inflate: params.inflateFactor, minClusterSize: params.minClusterSize,
206
206
  }).call(true);
207
207
  }).show();
208
+ dialog.history(() => ({editorSettings: funcEditor.getStringInput()}), (x: any) => funcEditor.applyStringInput(x['editorSettings']));
208
209
  } catch (err: any) {
209
210
  const errMsg = err instanceof Error ? err.message : err.toString();
210
211
  const errStack = err instanceof Error ? err.stack : undefined;
@@ -7,7 +7,7 @@ import * as DG from 'datagrok-api/dg';
7
7
  import {PLS_ANALYSIS, ERROR_MSG, TITLE, HINT, LINK, COMPONENTS, INT, TIMEOUT,
8
8
  RESULT_NAMES, WASM_OUTPUT_IDX, RADIUS, LINE_WIDTH, COLOR, X_COORD, Y_COORD,
9
9
  DEMO_INTRO_MD, DEMO_RESULTS_MD, DEMO_RESULTS} from './pls-constants';
10
- import {checkWasmDimensionReducerInputs, checkColumnType, checkMissingVals} from '../utils';
10
+ import {checkWasmDimensionReducerInputs, checkColumnType, checkMissingVals, describeElements} from '../utils';
11
11
  import {_partialLeastSquareRegressionInWebWorker} from '../../wasm/EDAAPI';
12
12
  import {carsDataframe} from '../data-generators';
13
13
 
@@ -168,8 +168,6 @@ async function performMVA(input: PlsInput, analysisType: PLS_ANALYSIS): Promise<
168
168
  help: LINK.MODEL,
169
169
  }));
170
170
 
171
- console.log(input.names?.name);
172
-
173
171
  if ((input.names !== undefined) && (input.names !== null))
174
172
  predictVsReferScatter.setOptions({labelColumnNames: [input.names?.name]});
175
173
 
@@ -275,18 +273,14 @@ async function performMVA(input: PlsInput, analysisType: PLS_ANALYSIS): Promise<
275
273
  }));
276
274
 
277
275
  // emphasize viewers in the demo case
278
- if (analysisType === PLS_ANALYSIS.DEMO) {
279
- const pages = [predictVsReferScatter, scoresScatter, loadingsScatter, regrCoeffsBar, explVarsBar]
280
- .map((viewer, idx) => {
281
- return {
282
- text: DEMO_RESULTS[idx].text,
283
- showNextTo: viewer.root,
284
- };
285
- });
286
-
287
- const wizard = ui.hints.addTextHint({title: TITLE.EXPLORE, pages: pages});
288
- wizard.helpUrl = LINK.MVA;
276
+ if (analysisType === PLS_ANALYSIS.DEMO) {
289
277
  grok.shell.windows.help.showHelp(ui.markdown(DEMO_RESULTS_MD));
278
+
279
+ describeElements(
280
+ [predictVsReferScatter, scoresScatter, loadingsScatter, regrCoeffsBar, explVarsBar].map((v) => v.root),
281
+ DEMO_RESULTS.map((info) => `<b>${info.caption}</b>\n\n${info.text}`),
282
+ ['left', 'left', 'right', 'right', 'left'],
283
+ );
290
284
  }
291
285
  } // performMVA
292
286
 
@@ -400,8 +394,6 @@ export async function runMVA(analysisType: PLS_ANALYSIS): Promise<void> {
400
394
  .addButton(TITLE.RUN, async () => {
401
395
  dlg.close();
402
396
 
403
- console.log(names);
404
-
405
397
  await performMVA({
406
398
  table: table,
407
399
  features: DG.DataFrame.fromColumns(features).columns,
package/src/utils.ts CHANGED
@@ -27,7 +27,7 @@ const UNSUPPORTED_COLUMN_TYPE_MES = 'unsupported column type: ';
27
27
  const INCORRECT_MIN_DIST_MES = 'min distance must be positive.';
28
28
  const INCORRECT_SPREAD_MES = 'spread must be positive.';
29
29
  const INCORRECT_EPOCH_MES = 'number of epoch must be at least 1.';
30
- const INCORRECT_NEIBORS_MES = 'number of neibors must be at least 2 and not greater than samples count.';
30
+ const INCORRECT_NEIBORS_MES = 'number of neighbors must be at least 2 and not greater than samples count.';
31
31
  const INCORRECT_ITERATIONS_MES = 'number of iterations must be at least 1.';
32
32
  const INCORRECT_LEARNING_RATE_MES = 'learning rate must be positive.';
33
33
  const INCORRECT_PERPLEXITY_MES = 'perplexity must be at least 2 and not greater than samples count.';
@@ -244,7 +244,7 @@ function scaleDf(df: DG.DataFrame): DG.DataFrame {
244
244
  return df;
245
245
  }
246
246
 
247
- /** Return standartized dataframe */
247
+ /** Return standardized dataframe */
248
248
  export function centerScaleDataFrame(df: DG.DataFrame, toCenter: boolean, toScale: boolean): DG.DataFrame {
249
249
  if (toCenter) {
250
250
  if (toScale)
@@ -270,3 +270,49 @@ export function extractNonConstantColsDf(features: DG.ColumnList): DG.DataFrame
270
270
 
271
271
  return DG.DataFrame.fromColumns(cols);
272
272
  }
273
+
274
+ /** Describe viewers and return the Done button */
275
+ export function describeElements(roots: HTMLElement[], description: string[], position: string[]): HTMLButtonElement {
276
+ if (roots.length !== description.length)
277
+ throw new Error('Non-equal size of viewer roots and descriptions');
278
+
279
+ let idx = 0;
280
+ let closeIcn: HTMLElement;
281
+ let msg: HTMLDivElement;
282
+ let popup: HTMLDivElement;
283
+
284
+ const nextBtn = ui.button('next', () => {
285
+ popup.remove();
286
+ ++idx;
287
+ step();
288
+ }, 'Go to the next viewer');
289
+
290
+ const prevBtn = ui.button('prev', () => {
291
+ idx -= 1;
292
+ popup.remove();
293
+ step();
294
+ }, 'Go to the previous viewer');
295
+
296
+ const doneBtn = ui.button('done', () => popup.remove(), 'Go to the next step');
297
+
298
+ const btnsDiv = ui.divH([prevBtn, nextBtn, doneBtn]);
299
+ btnsDiv.style.marginLeft = 'auto';
300
+ btnsDiv.style.marginRight = '0px';
301
+
302
+ const step = () => {
303
+ if (idx < roots.length) {
304
+ msg = ui.divV([ui.markdown(description[idx]), btnsDiv]);
305
+ popup = ui.hints.addHint(roots[idx], msg, position[idx] as ui.hints.POSITION);
306
+ doneBtn.hidden = (idx < roots.length - 1);
307
+ nextBtn.hidden = (idx === roots.length - 1);
308
+ prevBtn.hidden = (idx < 1);
309
+
310
+ closeIcn = popup.querySelector('i') as HTMLElement;
311
+ closeIcn.onclick = () => doneBtn.click();
312
+ }
313
+ };
314
+
315
+ step();
316
+
317
+ return doneBtn;
318
+ }