@datagrok/eda 1.4.9 → 1.4.11
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/CHANGELOG.md +15 -0
- package/README.md +2 -0
- package/css/pareto.css +5 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/icons/pareto-front-viewer.svg +15 -0
- package/package.json +2 -2
- package/src/package-api.ts +14 -0
- package/src/package.g.ts +16 -0
- package/src/package.ts +221 -244
- package/src/pareto-optimization/defs.ts +45 -0
- package/src/pareto-optimization/pareto-computations.ts +65 -0
- package/src/pareto-optimization/pareto-front-viewer.ts +490 -0
- package/src/pareto-optimization/pareto-optimizer.ts +272 -0
- package/src/pareto-optimization/utils.ts +39 -0
- package/test-console-output-1.log +49 -49
- package/test-record-1.mp4 +0 -0
package/src/package.ts
CHANGED
|
@@ -36,23 +36,23 @@ import {SoftmaxClassifier} from './softmax-classifier';
|
|
|
36
36
|
|
|
37
37
|
import {initXgboost} from '../wasm/xgbooster';
|
|
38
38
|
import {XGBooster} from './xgbooster';
|
|
39
|
+
import {ParetoOptimizer} from './pareto-optimization/pareto-optimizer';
|
|
40
|
+
import {ParetoFrontViewer} from './pareto-optimization/pareto-front-viewer';
|
|
39
41
|
|
|
40
42
|
export const _package = new DG.Package();
|
|
41
43
|
export * from './package.g';
|
|
42
44
|
|
|
43
45
|
export class PackageFunctions {
|
|
44
46
|
@grok.decorators.func({
|
|
45
|
-
'name': 'info'
|
|
47
|
+
'name': 'info',
|
|
46
48
|
})
|
|
47
49
|
static info() {
|
|
48
|
-
|
|
49
50
|
grok.shell.info(_package.webRoot);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
@grok.decorators.init({})
|
|
54
55
|
static async init(): Promise<void> {
|
|
55
|
-
|
|
56
56
|
await _initEDAAPI();
|
|
57
57
|
await initXgboost();
|
|
58
58
|
}
|
|
@@ -61,15 +61,14 @@ export class PackageFunctions {
|
|
|
61
61
|
@grok.decorators.func({
|
|
62
62
|
'top-menu': 'ML | Cluster | DBSCAN...',
|
|
63
63
|
'name': 'DBSCAN',
|
|
64
|
-
'description': 'Density-based spatial clustering of applications with noise (DBSCAN)'
|
|
64
|
+
'description': 'Density-based spatial clustering of applications with noise (DBSCAN)',
|
|
65
65
|
})
|
|
66
66
|
static async dbScan(
|
|
67
67
|
df: DG.DataFrame,
|
|
68
|
-
@grok.decorators.param({type: 'column', 'options':{'type':'numerical'}})
|
|
69
|
-
@grok.decorators.param({type: 'column', 'options':{'type':'numerical'}})
|
|
70
|
-
@grok.decorators.param({'options':{'caption':'Epsilon','initialValue':'0.02', description: 'The maximum distance between two samples for them to be considered as in the same neighborhood.'}})
|
|
71
|
-
@grok.decorators.param({'type':'int','options':{'caption':'Minimum points','initialValue':'4', description: 'The number of samples (or total weight) in a neighborhood for a point to be considered as a core point.'}})
|
|
72
|
-
|
|
68
|
+
@grok.decorators.param({'type': 'column', 'options': {'type': 'numerical'}}) xCol: DG.Column,
|
|
69
|
+
@grok.decorators.param({'type': 'column', 'options': {'type': 'numerical'}}) yCol: DG.Column,
|
|
70
|
+
@grok.decorators.param({'options': {'caption': 'Epsilon', 'initialValue': '0.02', 'description': 'The maximum distance between two samples for them to be considered as in the same neighborhood.'}}) epsilon: number,
|
|
71
|
+
@grok.decorators.param({'type': 'int', 'options': {'caption': 'Minimum points', 'initialValue': '4', 'description': 'The number of samples (or total weight) in a neighborhood for a point to be considered as a core point.'}}) minPts: number) : Promise<DG.Column> {
|
|
73
72
|
const x = xCol.getRawData() as Float32Array;
|
|
74
73
|
const y = yCol.getRawData() as Float32Array;
|
|
75
74
|
const res = await getDbscanWorker(x, y, epsilon, minPts);
|
|
@@ -82,16 +81,15 @@ export class PackageFunctions {
|
|
|
82
81
|
@grok.decorators.func({
|
|
83
82
|
'top-menu': 'ML | Analyze | PCA...',
|
|
84
83
|
'description': 'Principal component analysis (PCA)',
|
|
85
|
-
helpUrl: '/help/explore/dim-reduction#pca',
|
|
84
|
+
'helpUrl': '/help/explore/dim-reduction#pca',
|
|
86
85
|
})
|
|
87
86
|
static async PCA(
|
|
88
|
-
@grok.decorators.param({'type':'dataframe','options':{'caption':'Table'}})
|
|
89
|
-
@grok.decorators.param({'type':'column_list','options':{'type':'numerical', 'nullable': false}})
|
|
87
|
+
@grok.decorators.param({'type': 'dataframe', 'options': {'caption': 'Table'}}) table: DG.DataFrame,
|
|
88
|
+
@grok.decorators.param({'type': 'column_list', 'options': {'type': 'numerical', 'nullable': false}}) features: DG.ColumnList,
|
|
90
89
|
//@ts-ignore
|
|
91
|
-
@grok.decorators.param({'type':'int','options':{'showPlusMinus': true, 'caption':'Components', 'nullable':false, 'min':'1', 'initialValue':'2', description: 'Number of components.'}})
|
|
92
|
-
@grok.decorators.param({'type':'bool', 'options':{'caption':'Center', 'initialValue':'false', description: 'Indicating whether the variables should be shifted to be zero centered.'}})
|
|
93
|
-
@grok.decorators.param({'type':'bool','options':{'caption':'Scale', 'initialValue':'false', description: 'Indicating whether the variables should be scaled to have unit variance.'}})
|
|
94
|
-
|
|
90
|
+
@grok.decorators.param({'type': 'int', 'options': {'showPlusMinus': true, 'caption': 'Components', 'nullable': false, 'min': '1', 'initialValue': '2', 'description': 'Number of components.'}}) components: number,
|
|
91
|
+
@grok.decorators.param({'type': 'bool', 'options': {'caption': 'Center', 'initialValue': 'false', 'description': 'Indicating whether the variables should be shifted to be zero centered.'}}) center: boolean,
|
|
92
|
+
@grok.decorators.param({'type': 'bool', 'options': {'caption': 'Scale', 'initialValue': 'false', 'description': 'Indicating whether the variables should be scaled to have unit variance.'}}) scale: boolean): Promise<void> {
|
|
95
93
|
try {
|
|
96
94
|
const pcaTable = await computePCA(table, features, components, center, scale);
|
|
97
95
|
addPrefixToEachColumnName('PC', pcaTable.columns);
|
|
@@ -116,19 +114,18 @@ export class PackageFunctions {
|
|
|
116
114
|
|
|
117
115
|
@grok.decorators.func({
|
|
118
116
|
'meta': {
|
|
119
|
-
'defaultPostProcessingFunction': 'true'
|
|
117
|
+
'defaultPostProcessingFunction': 'true',
|
|
120
118
|
},
|
|
121
119
|
'tags': [
|
|
122
|
-
'dim-red-postprocessing-function'
|
|
120
|
+
'dim-red-postprocessing-function',
|
|
123
121
|
],
|
|
124
|
-
'name': 'DBSCAN clustering'
|
|
122
|
+
'name': 'DBSCAN clustering',
|
|
125
123
|
})
|
|
126
124
|
static async dbscanPostProcessingFunction(
|
|
127
125
|
col1: DG.Column,
|
|
128
126
|
col2: DG.Column,
|
|
129
|
-
@grok.decorators.param({options: {initialValue: '0.01', description: 'Minimum distance between two points to be considered as in the same neighborhood.'}})
|
|
130
|
-
@grok.decorators.param({type: 'int', options: {initialValue: '5', description: 'Minimum number of points to form a dense region.'}})
|
|
131
|
-
|
|
127
|
+
@grok.decorators.param({options: {initialValue: '0.01', description: 'Minimum distance between two points to be considered as in the same neighborhood.'}}) epsilon: number,
|
|
128
|
+
@grok.decorators.param({type: 'int', options: {initialValue: '5', description: 'Minimum number of points to form a dense region.'}}) minimumPoints: number) {
|
|
132
129
|
const df = col1.dataFrame;
|
|
133
130
|
if (df === null)
|
|
134
131
|
return;
|
|
@@ -150,16 +147,15 @@ export class PackageFunctions {
|
|
|
150
147
|
@grok.decorators.func({
|
|
151
148
|
'meta': {
|
|
152
149
|
'supportedTypes': 'int,float,double,qnum',
|
|
153
|
-
'supportedDistanceFunctions': 'Difference'
|
|
150
|
+
'supportedDistanceFunctions': 'Difference',
|
|
154
151
|
},
|
|
155
152
|
'tags': ['dim-red-preprocessing-function'],
|
|
156
153
|
'name': 'None (number)',
|
|
157
|
-
'outputs': [{name: 'result', type:'object'}]
|
|
154
|
+
'outputs': [{name: 'result', type: 'object'}],
|
|
158
155
|
})
|
|
159
156
|
static numberPreprocessingFunction(
|
|
160
157
|
col: DG.Column,
|
|
161
|
-
@grok.decorators.param({'options':{'optional':true}})
|
|
162
|
-
|
|
158
|
+
@grok.decorators.param({'options': {'optional': true}}) _metric: string) {
|
|
163
159
|
const range = col.stats.max - col.stats.min;
|
|
164
160
|
const entries = col.toList();
|
|
165
161
|
return {entries, options: {range}};
|
|
@@ -169,16 +165,15 @@ export class PackageFunctions {
|
|
|
169
165
|
@grok.decorators.func({
|
|
170
166
|
'meta': {
|
|
171
167
|
'supportedTypes': 'string',
|
|
172
|
-
'supportedDistanceFunctions': 'One-Hot,Levenshtein,Hamming'
|
|
168
|
+
'supportedDistanceFunctions': 'One-Hot,Levenshtein,Hamming',
|
|
173
169
|
},
|
|
174
170
|
'tags': ['dim-red-preprocessing-function'],
|
|
175
171
|
'name': 'None (string)',
|
|
176
|
-
'outputs': [{name: 'result', type:'object'}]
|
|
172
|
+
'outputs': [{name: 'result', type: 'object'}],
|
|
177
173
|
})
|
|
178
174
|
static stringPreprocessingFunction(
|
|
179
175
|
col: DG.Column,
|
|
180
|
-
@grok.decorators.param({'options':{'optional':true}})
|
|
181
|
-
|
|
176
|
+
@grok.decorators.param({'options': {'optional': true}}) _metric: string) {
|
|
182
177
|
const entries = col.toList();
|
|
183
178
|
return {entries, options: {}};
|
|
184
179
|
}
|
|
@@ -186,10 +181,9 @@ export class PackageFunctions {
|
|
|
186
181
|
|
|
187
182
|
@grok.decorators.func({
|
|
188
183
|
'top-menu': 'ML | Reduce Dimensionality...',
|
|
189
|
-
'name': 'Multi Column Dimensionality Reduction'
|
|
184
|
+
'name': 'Multi Column Dimensionality Reduction',
|
|
190
185
|
})
|
|
191
186
|
static async reduceDimensionality(): Promise<void> {
|
|
192
|
-
|
|
193
187
|
const editor = new MultiColumnDimReductionEditor();
|
|
194
188
|
const dialog = ui.dialog('Reduce Dimensionality')
|
|
195
189
|
.add(editor.getEditor())
|
|
@@ -230,8 +224,7 @@ export class PackageFunctions {
|
|
|
230
224
|
|
|
231
225
|
@grok.decorators.editor()
|
|
232
226
|
static GetMCLEditor(
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
call: DG.FuncCall): void {
|
|
235
228
|
try {
|
|
236
229
|
const funcEditor = new MCLEditor();
|
|
237
230
|
const dialog = ui.dialog('Markov clustering')
|
|
@@ -255,7 +248,6 @@ export class PackageFunctions {
|
|
|
255
248
|
}
|
|
256
249
|
|
|
257
250
|
|
|
258
|
-
|
|
259
251
|
@grok.decorators.func({
|
|
260
252
|
'top-menu': 'ML | Cluster | MCL...',
|
|
261
253
|
'name': 'MCLClustering',
|
|
@@ -266,16 +258,16 @@ export class PackageFunctions {
|
|
|
266
258
|
static async MCLClustering(
|
|
267
259
|
df: DG.DataFrame,
|
|
268
260
|
cols: DG.Column[],
|
|
269
|
-
@grok.decorators.param({'type':'list<string>'}) metrics: KnownMetrics[],
|
|
261
|
+
@grok.decorators.param({'type': 'list<string>'}) metrics: KnownMetrics[],
|
|
270
262
|
weights: number[],
|
|
271
|
-
@grok.decorators.param({'type':'string'})
|
|
272
|
-
@grok.decorators.param({'type':'list<func>'})
|
|
273
|
-
@grok.decorators.param({'type':'object'})
|
|
274
|
-
@grok.decorators.param({'type':'int','options':{'initialValue':'80'}})
|
|
275
|
-
@grok.decorators.param({'type':'int','options':{'initialValue':'10'}})
|
|
276
|
-
@grok.decorators.param({'type':'bool','options':{'initialValue':'false'}})
|
|
277
|
-
@grok.decorators.param({'type':'double','options':{'initialValue':'2'}})
|
|
278
|
-
@grok.decorators.param({'type':'int','options':{'initialValue':'5'}})
|
|
263
|
+
@grok.decorators.param({'type': 'string'}) aggregationMethod: DistanceAggregationMethod,
|
|
264
|
+
@grok.decorators.param({'type': 'list<func>'}) preprocessingFuncs: any[],
|
|
265
|
+
@grok.decorators.param({'type': 'object'}) preprocessingFuncArgs: any[],
|
|
266
|
+
@grok.decorators.param({'type': 'int', 'options': {'initialValue': '80'}}) threshold: number = 80,
|
|
267
|
+
@grok.decorators.param({'type': 'int', 'options': {'initialValue': '10'}}) maxIterations: number = 10,
|
|
268
|
+
@grok.decorators.param({'type': 'bool', 'options': {'initialValue': 'false'}}) useWebGPU: boolean = false,
|
|
269
|
+
@grok.decorators.param({'type': 'double', 'options': {'initialValue': '2'}}) inflate: number = 0,
|
|
270
|
+
@grok.decorators.param({'type': 'int', 'options': {'initialValue': '5'}}) minClusterSize: number = 5): Promise<MCLViewer> {
|
|
279
271
|
const tv = grok.shell.tableView(df.name) ?? grok.shell.addTableView(df);
|
|
280
272
|
const serializedOptions: string = JSON.stringify({
|
|
281
273
|
cols: cols.map((col) => col.name),
|
|
@@ -296,13 +288,13 @@ export class PackageFunctions {
|
|
|
296
288
|
}
|
|
297
289
|
|
|
298
290
|
@grok.decorators.func({
|
|
299
|
-
'outputs': [{'name': 'result','type': 'viewer'}],
|
|
291
|
+
'outputs': [{'name': 'result', 'type': 'viewer'}],
|
|
300
292
|
'tags': [
|
|
301
|
-
'viewer'
|
|
293
|
+
'viewer',
|
|
302
294
|
],
|
|
303
295
|
'meta': {showInGallery: 'false'},
|
|
304
296
|
'name': 'MCL',
|
|
305
|
-
'description': 'Markov clustering viewer'
|
|
297
|
+
'description': 'Markov clustering viewer',
|
|
306
298
|
})
|
|
307
299
|
static markovClusteringViewer(): MCLViewer {
|
|
308
300
|
return new MCLViewer();
|
|
@@ -310,15 +302,14 @@ export class PackageFunctions {
|
|
|
310
302
|
|
|
311
303
|
@grok.decorators.func({
|
|
312
304
|
'outputs': [{'name': 'plsResults', 'type': 'object'}],
|
|
313
|
-
'description': 'Compute partial least squares (PLS) regression analysis components: prediction, regression coefficients, T- & U-scores, X-loadings.'
|
|
305
|
+
'description': 'Compute partial least squares (PLS) regression analysis components: prediction, regression coefficients, T- & U-scores, X-loadings.',
|
|
314
306
|
})
|
|
315
307
|
static async PLS(
|
|
316
|
-
|
|
317
|
-
@grok.decorators.param({'type':'column_list','options':{'type':'numerical'}})
|
|
318
|
-
@grok.decorators.param({'type':'column','options':{'type':'numerical'}})
|
|
319
|
-
@grok.decorators.param({'type':'int','options':{'initialValue':'3'}})
|
|
320
|
-
@grok.decorators.param({'type':'column','options':{'type':'string'}})
|
|
321
|
-
|
|
308
|
+
table: DG.DataFrame,
|
|
309
|
+
@grok.decorators.param({'type': 'column_list', 'options': {'type': 'numerical'}}) features: DG.ColumnList,
|
|
310
|
+
@grok.decorators.param({'type': 'column', 'options': {'type': 'numerical'}}) predict: DG.Column,
|
|
311
|
+
@grok.decorators.param({'type': 'int', 'options': {'initialValue': '3'}}) components: number,
|
|
312
|
+
@grok.decorators.param({'type': 'column', 'options': {'type': 'string'}}) names: DG.Column): Promise<PlsOutput> {
|
|
322
313
|
return await getPlsAnalysis({
|
|
323
314
|
table: table,
|
|
324
315
|
features: features,
|
|
@@ -332,10 +323,9 @@ export class PackageFunctions {
|
|
|
332
323
|
|
|
333
324
|
@grok.decorators.func({
|
|
334
325
|
'top-menu': 'ML | Analyze | PLS...',
|
|
335
|
-
'description': 'Compute partial least squares (PLS) regression components. They maximally summarize the variation of the predictors while maximizing correlation with the response variable.'
|
|
326
|
+
'description': 'Compute partial least squares (PLS) regression components. They maximally summarize the variation of the predictors while maximizing correlation with the response variable.',
|
|
336
327
|
})
|
|
337
328
|
static async topMenuPLS(): Promise<void> {
|
|
338
|
-
|
|
339
329
|
await runMVA(PLS_ANALYSIS.COMPUTE_COMPONENTS);
|
|
340
330
|
}
|
|
341
331
|
|
|
@@ -343,20 +333,19 @@ export class PackageFunctions {
|
|
|
343
333
|
@grok.decorators.func({
|
|
344
334
|
'top-menu': 'ML | Analyze | Multivariate Analysis...',
|
|
345
335
|
'name': 'multivariateAnalysis',
|
|
346
|
-
'description': 'Multidimensional data analysis using partial least squares (PLS) regression.'
|
|
336
|
+
'description': 'Multidimensional data analysis using partial least squares (PLS) regression.',
|
|
347
337
|
})
|
|
348
338
|
static async MVA(): Promise<void> {
|
|
349
|
-
|
|
350
339
|
await runMVA(PLS_ANALYSIS.PERFORM_MVA);
|
|
351
340
|
}
|
|
352
341
|
|
|
353
342
|
|
|
354
343
|
@grok.decorators.func({
|
|
355
344
|
'meta': {
|
|
356
|
-
'demoPath': 'Compute | Multivariate Analysis'
|
|
345
|
+
'demoPath': 'Compute | Multivariate Analysis',
|
|
357
346
|
},
|
|
358
347
|
'name': 'MVA demo',
|
|
359
|
-
'description': 'Multidimensional data analysis using partial least squares (PLS) regression. It identifies latent factors and constructs a linear model based on them.'
|
|
348
|
+
'description': 'Multidimensional data analysis using partial least squares (PLS) regression. It identifies latent factors and constructs a linear model based on them.',
|
|
360
349
|
})
|
|
361
350
|
static async demoMultivariateAnalysis(): Promise<void> {
|
|
362
351
|
await runDemoMVA();
|
|
@@ -366,14 +355,13 @@ export class PackageFunctions {
|
|
|
366
355
|
@grok.decorators.func({
|
|
367
356
|
'meta': {
|
|
368
357
|
'mlname': 'linear kernel LS-SVM',
|
|
369
|
-
'mlrole': 'train'
|
|
370
|
-
}
|
|
358
|
+
'mlrole': 'train',
|
|
359
|
+
},
|
|
371
360
|
})
|
|
372
361
|
static async trainLinearKernelSVM(
|
|
373
362
|
df: DG.DataFrame,
|
|
374
363
|
predictColumn: DG.Column,
|
|
375
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1.0'}}) gamma: number): Promise<any> {
|
|
376
|
-
|
|
364
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1.0'}}) gamma: number): Promise<any> {
|
|
377
365
|
const trainedModel = await getTrainedModel({gamma: gamma, kernel: LINEAR}, df, predictColumn);
|
|
378
366
|
return getPackedModel(trainedModel);
|
|
379
367
|
}
|
|
@@ -382,13 +370,12 @@ export class PackageFunctions {
|
|
|
382
370
|
@grok.decorators.func({
|
|
383
371
|
'meta': {
|
|
384
372
|
'mlname': 'linear kernel LS-SVM',
|
|
385
|
-
'mlrole': 'apply'
|
|
386
|
-
}
|
|
373
|
+
'mlrole': 'apply',
|
|
374
|
+
},
|
|
387
375
|
})
|
|
388
376
|
static async applyLinearKernelSVM(
|
|
389
377
|
df: DG.DataFrame,
|
|
390
378
|
model: any): Promise<DG.DataFrame> {
|
|
391
|
-
|
|
392
379
|
return await getPrediction(df, model);
|
|
393
380
|
}
|
|
394
381
|
|
|
@@ -396,13 +383,12 @@ export class PackageFunctions {
|
|
|
396
383
|
@grok.decorators.func({
|
|
397
384
|
'meta': {
|
|
398
385
|
'mlname': 'linear kernel LS-SVM',
|
|
399
|
-
'mlrole': 'isApplicable'
|
|
400
|
-
}
|
|
386
|
+
'mlrole': 'isApplicable',
|
|
387
|
+
},
|
|
401
388
|
})
|
|
402
389
|
static async isApplicableLinearKernelSVM(
|
|
403
390
|
df: DG.DataFrame,
|
|
404
391
|
predictColumn: DG.Column): Promise<boolean> {
|
|
405
|
-
|
|
406
392
|
return isApplicableSVM(df, predictColumn);
|
|
407
393
|
}
|
|
408
394
|
|
|
@@ -410,13 +396,12 @@ export class PackageFunctions {
|
|
|
410
396
|
@grok.decorators.func({
|
|
411
397
|
'meta': {
|
|
412
398
|
'mlname': 'linear kernel LS-SVM',
|
|
413
|
-
'mlrole': 'isInteractive'
|
|
414
|
-
}
|
|
399
|
+
'mlrole': 'isInteractive',
|
|
400
|
+
},
|
|
415
401
|
})
|
|
416
402
|
static async isInteractiveLinearKernelSVM(
|
|
417
403
|
df: DG.DataFrame,
|
|
418
404
|
predictColumn: DG.Column): Promise<boolean> {
|
|
419
|
-
|
|
420
405
|
return isInteractiveSVM(df, predictColumn);
|
|
421
406
|
}
|
|
422
407
|
|
|
@@ -424,8 +409,8 @@ export class PackageFunctions {
|
|
|
424
409
|
@grok.decorators.func({
|
|
425
410
|
'meta': {
|
|
426
411
|
'mlname': 'linear kernel LS-SVM',
|
|
427
|
-
'mlrole': 'visualize'
|
|
428
|
-
}
|
|
412
|
+
'mlrole': 'visualize',
|
|
413
|
+
},
|
|
429
414
|
})
|
|
430
415
|
static async visualizeLinearKernelSVM(
|
|
431
416
|
df: DG.DataFrame,
|
|
@@ -436,17 +421,15 @@ export class PackageFunctions {
|
|
|
436
421
|
}
|
|
437
422
|
|
|
438
423
|
|
|
439
|
-
|
|
440
424
|
@grok.decorators.func({
|
|
441
425
|
'meta': {
|
|
442
426
|
'mlname': 'RBF-kernel LS-SVM',
|
|
443
|
-
'mlrole': 'train'
|
|
444
|
-
}
|
|
427
|
+
'mlrole': 'train',
|
|
428
|
+
},
|
|
445
429
|
})
|
|
446
430
|
static async trainRBFkernelSVM(df: DG.DataFrame, predictColumn: DG.Column,
|
|
447
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1.0'}}) gamma: number,
|
|
448
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1.5'}}) sigma: number): Promise<any> {
|
|
449
|
-
|
|
431
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1.0'}}) gamma: number,
|
|
432
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1.5'}}) sigma: number): Promise<any> {
|
|
450
433
|
const trainedModel = await getTrainedModel(
|
|
451
434
|
{gamma: gamma, kernel: RBF, sigma: sigma},
|
|
452
435
|
df, predictColumn);
|
|
@@ -458,13 +441,12 @@ export class PackageFunctions {
|
|
|
458
441
|
@grok.decorators.func({
|
|
459
442
|
'meta': {
|
|
460
443
|
'mlname': 'RBF-kernel LS-SVM',
|
|
461
|
-
'mlrole': 'apply'
|
|
462
|
-
}
|
|
444
|
+
'mlrole': 'apply',
|
|
445
|
+
},
|
|
463
446
|
})
|
|
464
447
|
static async applyRBFkernelSVM(
|
|
465
448
|
df: DG.DataFrame,
|
|
466
449
|
model: any): Promise<DG.DataFrame> {
|
|
467
|
-
|
|
468
450
|
return await getPrediction(df, model);
|
|
469
451
|
}
|
|
470
452
|
|
|
@@ -472,13 +454,12 @@ export class PackageFunctions {
|
|
|
472
454
|
@grok.decorators.func({
|
|
473
455
|
'meta': {
|
|
474
456
|
'mlname': 'RBF-kernel LS-SVM',
|
|
475
|
-
'mlrole': 'isApplicable'
|
|
476
|
-
}
|
|
457
|
+
'mlrole': 'isApplicable',
|
|
458
|
+
},
|
|
477
459
|
})
|
|
478
460
|
static async isApplicableRBFkernelSVM(
|
|
479
461
|
df: DG.DataFrame,
|
|
480
462
|
predictColumn: DG.Column): Promise<boolean> {
|
|
481
|
-
|
|
482
463
|
return isApplicableSVM(df, predictColumn);
|
|
483
464
|
}
|
|
484
465
|
|
|
@@ -486,30 +467,27 @@ export class PackageFunctions {
|
|
|
486
467
|
@grok.decorators.func({
|
|
487
468
|
'meta': {
|
|
488
469
|
'mlname': 'RBF-kernel LS-SVM',
|
|
489
|
-
'mlrole': 'isInteractive'
|
|
490
|
-
}
|
|
470
|
+
'mlrole': 'isInteractive',
|
|
471
|
+
},
|
|
491
472
|
})
|
|
492
473
|
static async isInteractiveRBFkernelSVM(
|
|
493
474
|
df: DG.DataFrame,
|
|
494
475
|
predictColumn: DG.Column): Promise<boolean> {
|
|
495
|
-
|
|
496
476
|
return isInteractiveSVM(df, predictColumn);
|
|
497
477
|
}
|
|
498
478
|
|
|
499
479
|
|
|
500
|
-
|
|
501
480
|
@grok.decorators.func({
|
|
502
481
|
'meta': {
|
|
503
482
|
'mlname': 'RBF-kernel LS-SVM',
|
|
504
|
-
'mlrole': 'visualize'
|
|
505
|
-
}
|
|
483
|
+
'mlrole': 'visualize',
|
|
484
|
+
},
|
|
506
485
|
})
|
|
507
486
|
static async visualizeRBFkernelSVM(
|
|
508
487
|
df: DG.DataFrame,
|
|
509
488
|
targetColumn: DG.Column,
|
|
510
489
|
predictColumn: DG.Column,
|
|
511
490
|
model: any): Promise<any> {
|
|
512
|
-
|
|
513
491
|
return showTrainReport(df, model);
|
|
514
492
|
}
|
|
515
493
|
|
|
@@ -517,14 +495,13 @@ export class PackageFunctions {
|
|
|
517
495
|
@grok.decorators.func({
|
|
518
496
|
'meta': {
|
|
519
497
|
'mlname': 'polynomial kernel LS-SVM',
|
|
520
|
-
'mlrole': 'train'
|
|
498
|
+
'mlrole': 'train',
|
|
521
499
|
},
|
|
522
500
|
})
|
|
523
501
|
static async trainPolynomialKernelSVM(df: DG.DataFrame, predictColumn: DG.Column,
|
|
524
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1.0'}}) gamma: number,
|
|
525
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1'}}) c: number,
|
|
526
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '2'}}) d: number): Promise<any> {
|
|
527
|
-
|
|
502
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1.0'}}) gamma: number,
|
|
503
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1'}}) c: number,
|
|
504
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '2'}}) d: number): Promise<any> {
|
|
528
505
|
const trainedModel = await getTrainedModel(
|
|
529
506
|
{gamma: gamma, kernel: POLYNOMIAL, cParam: c, dParam: d},
|
|
530
507
|
df, predictColumn);
|
|
@@ -536,13 +513,12 @@ export class PackageFunctions {
|
|
|
536
513
|
@grok.decorators.func({
|
|
537
514
|
'meta': {
|
|
538
515
|
'mlname': 'polynomial kernel LS-SVM',
|
|
539
|
-
'mlrole': 'apply'
|
|
516
|
+
'mlrole': 'apply',
|
|
540
517
|
},
|
|
541
518
|
})
|
|
542
519
|
static async applyPolynomialKernelSVM(
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
520
|
+
df: DG.DataFrame,
|
|
521
|
+
model: any): Promise<DG.DataFrame> {
|
|
546
522
|
return await getPrediction(df, model);
|
|
547
523
|
}
|
|
548
524
|
|
|
@@ -550,13 +526,12 @@ export class PackageFunctions {
|
|
|
550
526
|
@grok.decorators.func({
|
|
551
527
|
'meta': {
|
|
552
528
|
'mlname': 'polynomial kernel LS-SVM',
|
|
553
|
-
'mlrole': 'isApplicable'
|
|
554
|
-
}
|
|
529
|
+
'mlrole': 'isApplicable',
|
|
530
|
+
},
|
|
555
531
|
})
|
|
556
532
|
static async isApplicablePolynomialKernelSVM(
|
|
557
533
|
df: DG.DataFrame,
|
|
558
534
|
predictColumn: DG.Column): Promise<boolean> {
|
|
559
|
-
|
|
560
535
|
return isApplicableSVM(df, predictColumn);
|
|
561
536
|
}
|
|
562
537
|
|
|
@@ -564,13 +539,12 @@ export class PackageFunctions {
|
|
|
564
539
|
@grok.decorators.func({
|
|
565
540
|
'meta': {
|
|
566
541
|
'mlname': 'polynomial kernel LS-SVM',
|
|
567
|
-
'mlrole': 'isInteractive'
|
|
568
|
-
}
|
|
542
|
+
'mlrole': 'isInteractive',
|
|
543
|
+
},
|
|
569
544
|
})
|
|
570
545
|
static async isInteractivePolynomialKernelSVM(
|
|
571
546
|
df: DG.DataFrame,
|
|
572
547
|
predictColumn: DG.Column): Promise<boolean> {
|
|
573
|
-
|
|
574
548
|
return isInteractiveSVM(df, predictColumn);
|
|
575
549
|
}
|
|
576
550
|
|
|
@@ -578,17 +552,16 @@ export class PackageFunctions {
|
|
|
578
552
|
@grok.decorators.func({
|
|
579
553
|
'meta': {
|
|
580
554
|
'mlname': 'polynomial kernel LS-SVM',
|
|
581
|
-
'mlrole': 'visualize'
|
|
555
|
+
'mlrole': 'visualize',
|
|
582
556
|
},
|
|
583
|
-
'outputs': [{'name': 'widget','type': 'dynamic'}],
|
|
584
|
-
'name': 'visualizePolynomialKernelSVM'
|
|
557
|
+
'outputs': [{'name': 'widget', 'type': 'dynamic'}],
|
|
558
|
+
'name': 'visualizePolynomialKernelSVM',
|
|
585
559
|
})
|
|
586
560
|
static async visualizePolynomialKernelSVM(
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
561
|
+
df: DG.DataFrame,
|
|
562
|
+
targetColumn: DG.Column,
|
|
563
|
+
predictColumn: DG.Column,
|
|
564
|
+
model: any): Promise<any> {
|
|
592
565
|
return showTrainReport(df, model);
|
|
593
566
|
}
|
|
594
567
|
|
|
@@ -596,15 +569,14 @@ export class PackageFunctions {
|
|
|
596
569
|
@grok.decorators.func({
|
|
597
570
|
'meta': {
|
|
598
571
|
'mlname': 'sigmoid kernel LS-SVM',
|
|
599
|
-
'mlrole': 'train'
|
|
572
|
+
'mlrole': 'train',
|
|
600
573
|
},
|
|
601
|
-
'name': 'trainSigmoidKernelSVM'
|
|
574
|
+
'name': 'trainSigmoidKernelSVM',
|
|
602
575
|
})
|
|
603
576
|
static async trainSigmoidKernelSVM(df: DG.DataFrame, predictColumn: DG.Column,
|
|
604
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1.0'}}) gamma: number,
|
|
605
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1'}}) kappa: number,
|
|
606
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1'}}) theta: number): Promise<any> {
|
|
607
|
-
|
|
577
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1.0'}}) gamma: number,
|
|
578
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1'}}) kappa: number,
|
|
579
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1'}}) theta: number): Promise<any> {
|
|
608
580
|
const trainedModel = await getTrainedModel(
|
|
609
581
|
{gamma: gamma, kernel: SIGMOID, kappa: kappa, theta: theta},
|
|
610
582
|
df, predictColumn);
|
|
@@ -616,14 +588,13 @@ export class PackageFunctions {
|
|
|
616
588
|
@grok.decorators.func({
|
|
617
589
|
'meta': {
|
|
618
590
|
'mlname': 'sigmoid kernel LS-SVM',
|
|
619
|
-
'mlrole': 'apply'
|
|
591
|
+
'mlrole': 'apply',
|
|
620
592
|
},
|
|
621
|
-
'name': 'applySigmoidKernelSVM'
|
|
593
|
+
'name': 'applySigmoidKernelSVM',
|
|
622
594
|
})
|
|
623
595
|
static async applySigmoidKernelSVM(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
596
|
+
df: DG.DataFrame,
|
|
597
|
+
model: any): Promise<DG.DataFrame> {
|
|
627
598
|
return await getPrediction(df, model);
|
|
628
599
|
}
|
|
629
600
|
|
|
@@ -631,14 +602,13 @@ export class PackageFunctions {
|
|
|
631
602
|
@grok.decorators.func({
|
|
632
603
|
'meta': {
|
|
633
604
|
'mlname': 'sigmoid kernel LS-SVM',
|
|
634
|
-
'mlrole': 'isApplicable'
|
|
605
|
+
'mlrole': 'isApplicable',
|
|
635
606
|
},
|
|
636
|
-
'name': 'isApplicableSigmoidKernelSVM'
|
|
607
|
+
'name': 'isApplicableSigmoidKernelSVM',
|
|
637
608
|
})
|
|
638
609
|
static async isApplicableSigmoidKernelSVM(
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
610
|
+
df: DG.DataFrame,
|
|
611
|
+
predictColumn: DG.Column): Promise<boolean> {
|
|
642
612
|
return isApplicableSVM(df, predictColumn);
|
|
643
613
|
}
|
|
644
614
|
|
|
@@ -646,14 +616,13 @@ export class PackageFunctions {
|
|
|
646
616
|
@grok.decorators.func({
|
|
647
617
|
'meta': {
|
|
648
618
|
'mlname': 'sigmoid kernel LS-SVM',
|
|
649
|
-
'mlrole': 'isInteractive'
|
|
619
|
+
'mlrole': 'isInteractive',
|
|
650
620
|
},
|
|
651
|
-
'name': 'isInteractiveSigmoidKernelSVM'
|
|
621
|
+
'name': 'isInteractiveSigmoidKernelSVM',
|
|
652
622
|
})
|
|
653
623
|
static async isInteractiveSigmoidKernelSVM(
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
624
|
+
df: DG.DataFrame,
|
|
625
|
+
predictColumn: DG.Column): Promise<boolean> {
|
|
657
626
|
return isInteractiveSVM(df, predictColumn);
|
|
658
627
|
}
|
|
659
628
|
|
|
@@ -661,16 +630,15 @@ export class PackageFunctions {
|
|
|
661
630
|
@grok.decorators.func({
|
|
662
631
|
'meta': {
|
|
663
632
|
'mlname': 'sigmoid kernel LS-SVM',
|
|
664
|
-
'mlrole': 'visualize'
|
|
633
|
+
'mlrole': 'visualize',
|
|
665
634
|
},
|
|
666
|
-
'name': 'visualizeSigmoidKernelSVM'
|
|
635
|
+
'name': 'visualizeSigmoidKernelSVM',
|
|
667
636
|
})
|
|
668
637
|
static async visualizeSigmoidKernelSVM(
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
638
|
+
df: DG.DataFrame,
|
|
639
|
+
targetColumn: DG.Column,
|
|
640
|
+
predictColumn: DG.Column,
|
|
641
|
+
model: any): Promise<any> {
|
|
674
642
|
return showTrainReport(df, model);
|
|
675
643
|
}
|
|
676
644
|
|
|
@@ -678,10 +646,9 @@ export class PackageFunctions {
|
|
|
678
646
|
@grok.decorators.func({
|
|
679
647
|
'top-menu': 'ML | Analyze | ANOVA...',
|
|
680
648
|
'name': 'ANOVA',
|
|
681
|
-
'description': 'One-way analysis of variances (ANOVA) determines whether the examined factor has a significant impact on the explored feature.'
|
|
649
|
+
'description': 'One-way analysis of variances (ANOVA) determines whether the examined factor has a significant impact on the explored feature.',
|
|
682
650
|
})
|
|
683
651
|
static anova(): void {
|
|
684
|
-
|
|
685
652
|
runOneWayAnova();
|
|
686
653
|
}
|
|
687
654
|
|
|
@@ -689,21 +656,19 @@ export class PackageFunctions {
|
|
|
689
656
|
@grok.decorators.func({
|
|
690
657
|
'top-menu': 'ML | Impute Missing Values...',
|
|
691
658
|
'name': 'KNN impute',
|
|
692
|
-
'description': 'Missing values imputation using the k-nearest neighbors method (KNN)'
|
|
659
|
+
'description': 'Missing values imputation using the k-nearest neighbors method (KNN)',
|
|
693
660
|
})
|
|
694
661
|
static kNNImputation() {
|
|
695
|
-
|
|
696
662
|
runKNNImputer();
|
|
697
663
|
}
|
|
698
664
|
|
|
699
665
|
|
|
700
666
|
@grok.decorators.func({
|
|
701
667
|
'name': 'KNN imputation for a table',
|
|
702
|
-
'description': 'Missing values imputation using the k-nearest neighbors method'
|
|
668
|
+
'description': 'Missing values imputation using the k-nearest neighbors method',
|
|
703
669
|
})
|
|
704
670
|
static async kNNImputationForTable(
|
|
705
|
-
|
|
706
|
-
|
|
671
|
+
table: DG.DataFrame) {
|
|
707
672
|
await runKNNImputer(table);
|
|
708
673
|
}
|
|
709
674
|
|
|
@@ -711,15 +676,14 @@ export class PackageFunctions {
|
|
|
711
676
|
@grok.decorators.func({
|
|
712
677
|
'meta': {
|
|
713
678
|
'mlname': 'Linear Regression',
|
|
714
|
-
'mlrole': 'train'
|
|
679
|
+
'mlrole': 'train',
|
|
715
680
|
},
|
|
716
681
|
'name': 'trainLinearRegression',
|
|
717
|
-
'outputs': [{'type': 'dynamic', 'name': 'model'}]
|
|
682
|
+
'outputs': [{'type': 'dynamic', 'name': 'model'}],
|
|
718
683
|
})
|
|
719
684
|
static async trainLinearRegression(
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
685
|
+
df: DG.DataFrame,
|
|
686
|
+
predictColumn: DG.Column): Promise<Uint8Array> {
|
|
723
687
|
const features = df.columns;
|
|
724
688
|
const params = await getLinearRegressionParams(features, predictColumn);
|
|
725
689
|
|
|
@@ -730,14 +694,13 @@ export class PackageFunctions {
|
|
|
730
694
|
@grok.decorators.func({
|
|
731
695
|
'meta': {
|
|
732
696
|
'mlname': 'Linear Regression',
|
|
733
|
-
'mlrole': 'apply'
|
|
697
|
+
'mlrole': 'apply',
|
|
734
698
|
},
|
|
735
|
-
'name': 'applyLinearRegression'
|
|
699
|
+
'name': 'applyLinearRegression',
|
|
736
700
|
})
|
|
737
701
|
static applyLinearRegression(
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
702
|
+
df: DG.DataFrame,
|
|
703
|
+
model: any): DG.DataFrame {
|
|
741
704
|
const features = df.columns;
|
|
742
705
|
const params = new Float32Array((model as Uint8Array).buffer);
|
|
743
706
|
return DG.DataFrame.fromColumns([getPredictionByLinearRegression(features, params)]);
|
|
@@ -747,14 +710,13 @@ export class PackageFunctions {
|
|
|
747
710
|
@grok.decorators.func({
|
|
748
711
|
'meta': {
|
|
749
712
|
'mlname': 'Linear Regression',
|
|
750
|
-
'mlrole': 'isApplicable'
|
|
713
|
+
'mlrole': 'isApplicable',
|
|
751
714
|
},
|
|
752
|
-
'name': 'isApplicableLinearRegression'
|
|
715
|
+
'name': 'isApplicableLinearRegression',
|
|
753
716
|
})
|
|
754
717
|
static isApplicableLinearRegression(
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
718
|
+
df: DG.DataFrame,
|
|
719
|
+
predictColumn: DG.Column): boolean {
|
|
758
720
|
for (const col of df.columns) {
|
|
759
721
|
if (!col.matches('numerical'))
|
|
760
722
|
return false;
|
|
@@ -767,14 +729,13 @@ export class PackageFunctions {
|
|
|
767
729
|
@grok.decorators.func({
|
|
768
730
|
'meta': {
|
|
769
731
|
'mlname': 'Linear Regression',
|
|
770
|
-
'mlrole': 'isInteractive'
|
|
732
|
+
'mlrole': 'isInteractive',
|
|
771
733
|
},
|
|
772
|
-
'name': 'isInteractiveLinearRegression'
|
|
734
|
+
'name': 'isInteractiveLinearRegression',
|
|
773
735
|
})
|
|
774
736
|
static isInteractiveLinearRegression(
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
737
|
+
df: DG.DataFrame,
|
|
738
|
+
predictColumn: DG.Column): boolean {
|
|
778
739
|
return df.rowCount <= 100000;
|
|
779
740
|
}
|
|
780
741
|
|
|
@@ -782,17 +743,16 @@ export class PackageFunctions {
|
|
|
782
743
|
@grok.decorators.func({
|
|
783
744
|
'meta': {
|
|
784
745
|
'mlname': 'Softmax',
|
|
785
|
-
'mlrole': 'train'
|
|
746
|
+
'mlrole': 'train',
|
|
786
747
|
},
|
|
787
748
|
'name': 'trainSoftmax',
|
|
788
|
-
'outputs': [{'type': 'dynamic', 'name': 'model'}]
|
|
749
|
+
'outputs': [{'type': 'dynamic', 'name': 'model'}],
|
|
789
750
|
})
|
|
790
751
|
static async trainSoftmax(df: DG.DataFrame, predictColumn: DG.Column,
|
|
791
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '1.0', 'min': '0.001', 'max': '20', description: 'Learning rate.'}}) rate: number,
|
|
792
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '100', 'min': '1', 'max': '10000', 'step': '10', description: 'Fitting iterations count'}}) iterations: number,
|
|
793
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '0.1', 'min': '0.0001', 'max': '1', description: 'Regularization rate.'}}) penalty: number,
|
|
794
|
-
@grok.decorators.param({'options':{'category':'Hyperparameters', 'initialValue': '0.001', 'min': '0.00001', 'max': '0.1', description: 'Fitting tolerance.'}}) tolerance: number): Promise<Uint8Array> {
|
|
795
|
-
|
|
752
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '1.0', 'min': '0.001', 'max': '20', 'description': 'Learning rate.'}}) rate: number,
|
|
753
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '100', 'min': '1', 'max': '10000', 'step': '10', 'description': 'Fitting iterations count'}}) iterations: number,
|
|
754
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '0.1', 'min': '0.0001', 'max': '1', 'description': 'Regularization rate.'}}) penalty: number,
|
|
755
|
+
@grok.decorators.param({'options': {'category': 'Hyperparameters', 'initialValue': '0.001', 'min': '0.00001', 'max': '0.1', 'description': 'Fitting tolerance.'}}) tolerance: number): Promise<Uint8Array> {
|
|
796
756
|
const features = df.columns;
|
|
797
757
|
|
|
798
758
|
const model = new SoftmaxClassifier({
|
|
@@ -809,14 +769,13 @@ export class PackageFunctions {
|
|
|
809
769
|
@grok.decorators.func({
|
|
810
770
|
'meta': {
|
|
811
771
|
'mlname': 'Softmax',
|
|
812
|
-
'mlrole': 'apply'
|
|
772
|
+
'mlrole': 'apply',
|
|
813
773
|
},
|
|
814
|
-
'name': 'applySoftmax'
|
|
774
|
+
'name': 'applySoftmax',
|
|
815
775
|
})
|
|
816
776
|
static applySoftmax(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
777
|
+
df: DG.DataFrame,
|
|
778
|
+
model: any): DG.DataFrame {
|
|
820
779
|
const features = df.columns;
|
|
821
780
|
const unpackedModel = new SoftmaxClassifier(undefined, model);
|
|
822
781
|
|
|
@@ -827,14 +786,13 @@ export class PackageFunctions {
|
|
|
827
786
|
@grok.decorators.func({
|
|
828
787
|
'meta': {
|
|
829
788
|
'mlname': 'Softmax',
|
|
830
|
-
'mlrole': 'isApplicable'
|
|
789
|
+
'mlrole': 'isApplicable',
|
|
831
790
|
},
|
|
832
|
-
'name': 'isApplicableSoftmax'
|
|
791
|
+
'name': 'isApplicableSoftmax',
|
|
833
792
|
})
|
|
834
793
|
static isApplicableSoftmax(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
794
|
+
df: DG.DataFrame,
|
|
795
|
+
predictColumn: DG.Column): boolean {
|
|
838
796
|
return SoftmaxClassifier.isApplicable(df.columns, predictColumn);
|
|
839
797
|
}
|
|
840
798
|
|
|
@@ -842,14 +800,13 @@ export class PackageFunctions {
|
|
|
842
800
|
@grok.decorators.func({
|
|
843
801
|
'meta': {
|
|
844
802
|
'mlname': 'Softmax',
|
|
845
|
-
'mlrole': 'isInteractive'
|
|
803
|
+
'mlrole': 'isInteractive',
|
|
846
804
|
},
|
|
847
|
-
'name': 'isInteractiveSoftmax'
|
|
805
|
+
'name': 'isInteractiveSoftmax',
|
|
848
806
|
})
|
|
849
807
|
static isInteractiveSoftmax(
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
808
|
+
df: DG.DataFrame,
|
|
809
|
+
predictColumn: DG.Column): boolean {
|
|
853
810
|
return SoftmaxClassifier.isInteractive(df.columns, predictColumn);
|
|
854
811
|
}
|
|
855
812
|
|
|
@@ -857,16 +814,15 @@ export class PackageFunctions {
|
|
|
857
814
|
@grok.decorators.func({
|
|
858
815
|
'meta': {
|
|
859
816
|
'mlname': 'PLS Regression',
|
|
860
|
-
'mlrole': 'train'
|
|
817
|
+
'mlrole': 'train',
|
|
861
818
|
},
|
|
862
819
|
'name': 'trainPLSRegression',
|
|
863
820
|
'outputs': [{'name': 'model', 'type': 'dynamic'}],
|
|
864
821
|
})
|
|
865
822
|
static async trainPLSRegression(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
@grok.decorators.param({'type':'int','options':{'min':'1','max':'10','initialValue':'3', description: 'Number of latent components.'}})
|
|
869
|
-
|
|
823
|
+
df: DG.DataFrame,
|
|
824
|
+
predictColumn: DG.Column,
|
|
825
|
+
@grok.decorators.param({'type': 'int', 'options': {'min': '1', 'max': '10', 'initialValue': '3', 'description': 'Number of latent components.'}}) components: number): Promise<Uint8Array> {
|
|
870
826
|
const features = df.columns;
|
|
871
827
|
|
|
872
828
|
const model = new PlsModel();
|
|
@@ -883,14 +839,13 @@ export class PackageFunctions {
|
|
|
883
839
|
@grok.decorators.func({
|
|
884
840
|
'meta': {
|
|
885
841
|
'mlname': 'PLS Regression',
|
|
886
|
-
'mlrole': 'apply'
|
|
842
|
+
'mlrole': 'apply',
|
|
887
843
|
},
|
|
888
|
-
'name': 'applyPLSRegression'
|
|
844
|
+
'name': 'applyPLSRegression',
|
|
889
845
|
})
|
|
890
846
|
static applyPLSRegression(
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
847
|
+
df: DG.DataFrame,
|
|
848
|
+
model: any): DG.DataFrame {
|
|
894
849
|
const unpackedModel = new PlsModel(model);
|
|
895
850
|
return DG.DataFrame.fromColumns([unpackedModel.predict(df.columns)]);
|
|
896
851
|
}
|
|
@@ -899,14 +854,13 @@ export class PackageFunctions {
|
|
|
899
854
|
@grok.decorators.func({
|
|
900
855
|
'meta': {
|
|
901
856
|
'mlname': 'PLS Regression',
|
|
902
|
-
'mlrole': 'isApplicable'
|
|
857
|
+
'mlrole': 'isApplicable',
|
|
903
858
|
},
|
|
904
|
-
'name': 'isApplicablePLSRegression'
|
|
859
|
+
'name': 'isApplicablePLSRegression',
|
|
905
860
|
})
|
|
906
861
|
static isApplicablePLSRegression(
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
862
|
+
df: DG.DataFrame,
|
|
863
|
+
predictColumn: DG.Column): boolean {
|
|
910
864
|
return PlsModel.isApplicable(df.columns, predictColumn);
|
|
911
865
|
}
|
|
912
866
|
|
|
@@ -914,16 +868,15 @@ export class PackageFunctions {
|
|
|
914
868
|
@grok.decorators.func({
|
|
915
869
|
'meta': {
|
|
916
870
|
'mlname': 'PLS Regression',
|
|
917
|
-
'mlrole': 'visualize'
|
|
871
|
+
'mlrole': 'visualize',
|
|
918
872
|
},
|
|
919
|
-
'name': 'visualizePLSRegression'
|
|
873
|
+
'name': 'visualizePLSRegression',
|
|
920
874
|
})
|
|
921
875
|
static async visualizePLSRegression(
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
876
|
+
df: DG.DataFrame,
|
|
877
|
+
targetColumn: DG.Column,
|
|
878
|
+
predictColumn: DG.Column,
|
|
879
|
+
model: any): Promise<any> {
|
|
927
880
|
const unpackedModel = new PlsModel(model);
|
|
928
881
|
const viewers = unpackedModel.viewers();
|
|
929
882
|
|
|
@@ -934,33 +887,32 @@ export class PackageFunctions {
|
|
|
934
887
|
@grok.decorators.func({
|
|
935
888
|
'meta': {
|
|
936
889
|
'mlname': 'PLS Regression',
|
|
937
|
-
'mlrole': 'isInteractive'
|
|
890
|
+
'mlrole': 'isInteractive',
|
|
938
891
|
},
|
|
939
|
-
'name': 'isInteractivePLSRegression'
|
|
892
|
+
'name': 'isInteractivePLSRegression',
|
|
940
893
|
})
|
|
941
894
|
static isInteractivePLSRegression(
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
895
|
+
df: DG.DataFrame,
|
|
896
|
+
predictColumn: DG.Column): boolean {
|
|
945
897
|
return PlsModel.isInteractive(df.columns, predictColumn);
|
|
946
898
|
}
|
|
947
899
|
|
|
948
900
|
@grok.decorators.func({
|
|
949
901
|
'meta': {
|
|
950
902
|
'mlname': 'XGBoost',
|
|
951
|
-
'mlrole': 'train'
|
|
903
|
+
'mlrole': 'train',
|
|
952
904
|
},
|
|
953
905
|
'name': 'trainXGBooster',
|
|
954
906
|
'outputs': [{'name': 'model', 'type': 'dynamic'}],
|
|
955
907
|
})
|
|
956
908
|
static async trainXGBooster(
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
@grok.decorators.param({'type':'int','options':{'min':'1','max':'100','initialValue':'20', description: 'Number of training iterations.'}})
|
|
960
|
-
@grok.decorators.param({'type':'double','options':{'caption':'Rate','min':'0','max':'1','initialValue':'0.3', description: 'Learning rate.'}})
|
|
961
|
-
@grok.decorators.param({'type':'int','options':{'min':'0','max':'20','initialValue':'6', description: 'Maximum depth of a tree.'}})
|
|
962
|
-
@grok.decorators.param({'type':'double','options':{'min':'0','max':'100','initialValue':'1', description: 'L2 regularization term.'}})
|
|
963
|
-
@grok.decorators.param({'type':'double','options':{'min':'0','max':'100','initialValue':'0', description: 'L1 regularization term.'}})
|
|
909
|
+
df: DG.DataFrame,
|
|
910
|
+
predictColumn: DG.Column,
|
|
911
|
+
@grok.decorators.param({'type': 'int', 'options': {'min': '1', 'max': '100', 'initialValue': '20', 'description': 'Number of training iterations.'}}) iterations: number,
|
|
912
|
+
@grok.decorators.param({'type': 'double', 'options': {'caption': 'Rate', 'min': '0', 'max': '1', 'initialValue': '0.3', 'description': 'Learning rate.'}}) eta: number,
|
|
913
|
+
@grok.decorators.param({'type': 'int', 'options': {'min': '0', 'max': '20', 'initialValue': '6', 'description': 'Maximum depth of a tree.'}}) maxDepth: number,
|
|
914
|
+
@grok.decorators.param({'type': 'double', 'options': {'min': '0', 'max': '100', 'initialValue': '1', 'description': 'L2 regularization term.'}}) lambda: number,
|
|
915
|
+
@grok.decorators.param({'type': 'double', 'options': {'min': '0', 'max': '100', 'initialValue': '0', 'description': 'L1 regularization term.'}}) alpha: number): Promise<Uint8Array> {
|
|
964
916
|
const features = df.columns;
|
|
965
917
|
|
|
966
918
|
const booster = new XGBooster();
|
|
@@ -973,14 +925,13 @@ export class PackageFunctions {
|
|
|
973
925
|
@grok.decorators.func({
|
|
974
926
|
'meta': {
|
|
975
927
|
'mlname': 'XGBoost',
|
|
976
|
-
'mlrole': 'apply'
|
|
928
|
+
'mlrole': 'apply',
|
|
977
929
|
},
|
|
978
|
-
'name': 'applyXGBooster'
|
|
930
|
+
'name': 'applyXGBooster',
|
|
979
931
|
})
|
|
980
932
|
static applyXGBooster(
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
933
|
+
df: DG.DataFrame,
|
|
934
|
+
model: any): DG.DataFrame {
|
|
984
935
|
const unpackedModel = new XGBooster(model);
|
|
985
936
|
return DG.DataFrame.fromColumns([unpackedModel.predict(df.columns)]);
|
|
986
937
|
}
|
|
@@ -989,14 +940,13 @@ export class PackageFunctions {
|
|
|
989
940
|
@grok.decorators.func({
|
|
990
941
|
'meta': {
|
|
991
942
|
'mlname': 'XGBoost',
|
|
992
|
-
'mlrole': 'isInteractive'
|
|
943
|
+
'mlrole': 'isInteractive',
|
|
993
944
|
},
|
|
994
|
-
'name': 'isInteractiveXGBooster'
|
|
945
|
+
'name': 'isInteractiveXGBooster',
|
|
995
946
|
})
|
|
996
947
|
static isInteractiveXGBooster(
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
948
|
+
df: DG.DataFrame,
|
|
949
|
+
predictColumn: DG.Column): boolean {
|
|
1000
950
|
return XGBooster.isInteractive(df.columns, predictColumn);
|
|
1001
951
|
}
|
|
1002
952
|
|
|
@@ -1004,14 +954,41 @@ export class PackageFunctions {
|
|
|
1004
954
|
@grok.decorators.func({
|
|
1005
955
|
'meta': {
|
|
1006
956
|
'mlname': 'XGBoost',
|
|
1007
|
-
'mlrole': 'isApplicable'
|
|
957
|
+
'mlrole': 'isApplicable',
|
|
1008
958
|
},
|
|
1009
|
-
'name': 'isApplicableXGBooster'
|
|
959
|
+
'name': 'isApplicableXGBooster',
|
|
1010
960
|
})
|
|
1011
961
|
static isApplicableXGBooster(
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
962
|
+
df: DG.DataFrame,
|
|
963
|
+
predictColumn: DG.Column): boolean {
|
|
1015
964
|
return XGBooster.isApplicable(df.columns, predictColumn);
|
|
1016
965
|
}
|
|
966
|
+
|
|
967
|
+
@grok.decorators.func({
|
|
968
|
+
'top-menu': 'ML | Pareto Front...',
|
|
969
|
+
'name': 'Pareto Front',
|
|
970
|
+
'description': 'Perform optimization across multiple objectives: analyze trade-offs between conflicting objectives and identify Pareto-optimal points.',
|
|
971
|
+
})
|
|
972
|
+
static paretoFront(): void {
|
|
973
|
+
const df = grok.shell.t;
|
|
974
|
+
if (df === null) {
|
|
975
|
+
grok.shell.warning('No dataframe is opened');
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
const optimizer = new ParetoOptimizer(df);
|
|
980
|
+
optimizer.run();
|
|
981
|
+
//runParetoOptimizer();
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
@grok.decorators.func({
|
|
985
|
+
'name': 'Pareto front',
|
|
986
|
+
'description': 'Pareto front viewer',
|
|
987
|
+
'tags': ['viewer'],
|
|
988
|
+
'outputs': [{'name': 'result', 'type': 'viewer'}],
|
|
989
|
+
'meta': {'icon': 'icons/pareto-front-viewer.svg'},
|
|
990
|
+
})
|
|
991
|
+
static paretoFrontViewer(): DG.Viewer {
|
|
992
|
+
return new ParetoFrontViewer();
|
|
993
|
+
}
|
|
1017
994
|
}
|