@@ -135,7 +135,7 @@ define([
135
135
description : 'Fit Encoder/Scaler to X, then transform X.' ,
136
136
options : [
137
137
{ name : 'fit_trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
138
- { name : 'fit_trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' }
138
+ { name : 'fit_trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'trans' }
139
139
]
140
140
} ,
141
141
'transform' : {
@@ -154,7 +154,7 @@ define([
154
154
description : 'Transform binary labels back to multi-class labels.' ,
155
155
options : [
156
156
{ name : 'inverse_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
157
- { name : 'inverse_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' }
157
+ { name : 'inverse_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'inv_trans' }
158
158
]
159
159
}
160
160
}
@@ -209,7 +209,15 @@ define([
209
209
if ( modelType == 'AgglomerativeClustering'
210
210
|| modelType == 'DBSCAN' ) {
211
211
actions = {
212
- 'fit' : defaultActions [ 'fit' ] ,
212
+ 'fit' : {
213
+ name : 'fit' ,
214
+ label : 'Fit' ,
215
+ code : '${model}.fit(${fit_featureData})' ,
216
+ description : 'Perform clustering from features, or distance matrix.' ,
217
+ options : [
218
+ { name : 'fit_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' }
219
+ ]
220
+ } ,
213
221
'fit_predict' : {
214
222
name : 'fit_predict' ,
215
223
label : 'Fit and predict' ,
@@ -224,8 +232,25 @@ define([
224
232
break ;
225
233
}
226
234
actions = {
227
- 'fit' : defaultActions [ 'fit' ] ,
228
- 'predict' : defaultActions [ 'predict' ] ,
235
+ 'fit' : {
236
+ name : 'fit' ,
237
+ label : 'Fit' ,
238
+ code : '${model}.fit(${fit_featureData})' ,
239
+ description : 'Compute clustering.' ,
240
+ options : [
241
+ { name : 'fit_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' }
242
+ ]
243
+ } ,
244
+ 'predict' : {
245
+ name : 'predict' ,
246
+ label : 'Predict' ,
247
+ code : '${pred_allocate} = ${model}.predict(${pred_featureData})' ,
248
+ description : 'Predict the closest target data X belongs to.' ,
249
+ options : [
250
+ { name : 'pred_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
251
+ { name : 'pred_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'pred' }
252
+ ]
253
+ } ,
229
254
'fit_predict' : {
230
255
name : 'fit_predict' ,
231
256
label : 'Fit and predict' ,
@@ -246,7 +271,7 @@ define([
246
271
code : '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})' ,
247
272
description : 'Compute clustering and transform X to cluster-distance space.' ,
248
273
options : [
249
- { name : 'fit_trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X_train ' } ,
274
+ { name : 'fit_trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X ' } ,
250
275
{ name : 'fit_trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'trans' }
251
276
]
252
277
} ,
@@ -266,23 +291,114 @@ define([
266
291
case 'Dimension Reduction' :
267
292
if ( modelType == 'TSNE' ) {
268
293
actions = {
269
- 'fit' : defaultActions [ 'fit' ] ,
294
+ 'fit' : {
295
+ name : 'fit' ,
296
+ label : 'Fit' ,
297
+ code : '${model}.fit(${fit_featureData})' ,
298
+ description : 'Fit X into an embedded space.' ,
299
+ options : [
300
+ { name : 'fit_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' }
301
+ ]
302
+ } ,
270
303
'fit_transform' : {
271
304
name : 'fit_transform' ,
272
305
label : 'Fit and transform' ,
273
306
code : '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})' ,
274
307
description : 'Fit X into an embedded space and return that transformed output.' ,
275
308
options : [
276
- { name : 'fit_trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X_train ' } ,
309
+ { name : 'fit_trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X ' } ,
277
310
{ name : 'fit_trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'trans' }
278
311
]
279
312
}
280
313
}
281
314
break ;
282
315
}
316
+ if ( modelType == 'LinearDiscriminantAnalysis' ) { // LDA
317
+ actions = {
318
+ 'fit' : {
319
+ name : 'fit' ,
320
+ label : 'Fit' ,
321
+ code : '${model}.fit(${fit_featureData}, ${fit_targetData})' ,
322
+ description : 'Fit the Linear Discriminant Analysis model.' ,
323
+ options : [
324
+ { name : 'fit_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
325
+ { name : 'fit_targetData' , label : 'Target Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'y' }
326
+ ]
327
+ } ,
328
+ 'fit_transform' : {
329
+ name : 'fit_transform' ,
330
+ label : 'Fit and transform' ,
331
+ code : '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData}${fit_trans_targetData})' ,
332
+ description : 'Fit to data, then transform it.' ,
333
+ options : [
334
+ { name : 'fit_trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
335
+ { name : 'fit_trans_targetData' , label : 'Target Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'y' } ,
336
+ { name : 'fit_trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'trans' }
337
+ ]
338
+ } ,
339
+ 'predict' : {
340
+ name : 'predict' ,
341
+ label : 'Predict' ,
342
+ code : '${pred_allocate} = ${model}.predict(${pred_featureData})' ,
343
+ description : 'Predict class labels for samples in X.' ,
344
+ options : [
345
+ { name : 'pred_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
346
+ { name : 'pred_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'pred' }
347
+ ]
348
+ } ,
349
+ 'transform' : {
350
+ name : 'transform' ,
351
+ label : 'Transform' ,
352
+ code : '${trans_allocate} = ${model}.transform(${trans_featureData})' ,
353
+ description : 'Project data to maximize class separation.' ,
354
+ options : [
355
+ { name : 'trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
356
+ { name : 'trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'trans' }
357
+ ]
358
+ }
359
+ }
360
+ break ;
361
+ }
283
362
actions = {
284
- 'fit' : defaultActions [ 'fit' ] ,
285
- 'transform' : defaultActions [ 'transform' ] ,
363
+ 'fit' : {
364
+ name : 'fit' ,
365
+ label : 'Fit' ,
366
+ code : '${model}.fit(${fit_featureData})' ,
367
+ description : 'Fit X into an embedded space.' ,
368
+ options : [
369
+ { name : 'fit_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' }
370
+ ]
371
+ } ,
372
+ 'fit_transform' : {
373
+ name : 'fit_transform' ,
374
+ label : 'Fit and transform' ,
375
+ code : '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})' ,
376
+ description : 'Fit the model with X and apply the dimensionality reduction on X.' ,
377
+ options : [
378
+ { name : 'fit_trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
379
+ { name : 'fit_trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'trans' }
380
+ ]
381
+ } ,
382
+ 'inverse_transform' : {
383
+ name : 'inverse_transform' ,
384
+ label : 'Inverse transform' ,
385
+ code : '${inverse_allocate} = ${model}.inverse_transform(${inverse_featureData})' ,
386
+ description : 'Transform data back to its original space.' ,
387
+ options : [
388
+ { name : 'inverse_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
389
+ { name : 'inverse_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'inv_trans' }
390
+ ]
391
+ } ,
392
+ 'transform' : {
393
+ name : 'transform' ,
394
+ label : 'Transform' ,
395
+ code : '${trans_allocate} = ${model}.transform(${trans_featureData})' ,
396
+ description : 'Apply dimensionality reduction to X.' ,
397
+ options : [
398
+ { name : 'trans_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
399
+ { name : 'trans_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'trans' }
400
+ ]
401
+ }
286
402
}
287
403
break ;
288
404
}
@@ -533,6 +649,22 @@ define([
533
649
}
534
650
break ;
535
651
case 'Dimension Reduction' :
652
+ if ( modelType == 'LDA' ) {
653
+ infos = {
654
+ 'score' : {
655
+ name : 'score' ,
656
+ label : 'Score' ,
657
+ code : '${score_allocate} = ${model}.score(${score_featureData}, ${score_targetData})' ,
658
+ description : 'Return the average log-likelihood of all samples.' ,
659
+ options : [
660
+ { name : 'score_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
661
+ { name : 'score_targetData' , label : 'Target Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'y' } ,
662
+ { name : 'score_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'scores' }
663
+ ]
664
+ }
665
+ }
666
+ break ;
667
+ }
536
668
if ( modelType == 'PCA' ) {
537
669
infos = {
538
670
'explained_variance_ratio_' : {
@@ -546,6 +678,19 @@ define([
546
678
}
547
679
}
548
680
}
681
+ infos = {
682
+ ...infos ,
683
+ 'score' : {
684
+ name : 'score' ,
685
+ label : 'Score' ,
686
+ code : '${score_allocate} = ${model}.score(${score_featureData})' ,
687
+ description : 'Return the average log-likelihood of all samples.' ,
688
+ options : [
689
+ { name : 'score_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' ] , value : 'X' } ,
690
+ { name : 'score_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'scores' }
691
+ ]
692
+ }
693
+ }
549
694
break ;
550
695
}
551
696
return infos ;
0 commit comments