@@ -59,7 +59,7 @@ define([
59
59
this . modelTypeList = {
60
60
'Encoding' : [ 'prep-onehot' , 'prep-label' , 'prep-ordinal' , 'prep-target' , 'prep-smote' ] ,
61
61
'Scaling' : [ 'prep-standard' , 'prep-robust' , 'prep-minmax' , 'prep-normalizer' , 'prep-func-trsfrm-log' , 'prep-func-trsfrm-exp' , 'prep-poly-feat' , 'prep-kbins-discretizer' ] ,
62
- 'ETC' : [ 'make-column-transformer' ]
62
+ 'ETC' : [ 'prep-simple-imputer' , ' make-column-transformer']
63
63
}
64
64
65
65
this . mctEstimator = {
@@ -94,10 +94,19 @@ define([
94
94
$ ( that . wrapSelector ( '#vp_installLibrary' ) ) . hide ( ) ;
95
95
}
96
96
97
- if ( modelType == 'make-column-transformer' ) {
97
+ if ( modelType === 'make-column-transformer' ) {
98
98
// load mct-targetData
99
99
that . loadVariableList ( ) ;
100
100
that . bindMCT ( ) ;
101
+ } else if ( modelType === 'prep-simple-imputer' ) {
102
+ $ ( that . wrapSelector ( '#missing_values' ) ) . replaceWith ( `<div>
103
+ ${ $ ( that . wrapSelector ( '#missing_values' ) ) [ 0 ] . outerHTML }
104
+ <label><input type="checkbox" id="missing_values_istext" class="vp-state"/><span>Text</span></label>
105
+ </div>` ) ;
106
+ $ ( that . wrapSelector ( '#fill_value' ) ) . replaceWith ( `<div>
107
+ ${ $ ( that . wrapSelector ( '#fill_value' ) ) [ 0 ] . outerHTML }
108
+ <label><input type="checkbox" id="fill_value_istext" class="vp-state"/><span>Text</span></label>
109
+ </div>` ) ;
101
110
}
102
111
} ) ;
103
112
@@ -411,6 +420,7 @@ define([
411
420
412
421
generateCode ( ) {
413
422
let { modelControlType, modelType, userOption, allocateToCreation, model } = this . state ;
423
+ let state = JSON . parse ( JSON . stringify ( this . state ) ) ;
414
424
let code = new com_String ( ) ;
415
425
if ( modelControlType == 'creation' ) {
416
426
/**
@@ -422,22 +432,33 @@ define([
422
432
let config = this . modelConfig [ modelType ] ;
423
433
code . appendLine ( config . import ) ;
424
434
435
+ if ( modelType === 'prep-simple-imputer' ) {
436
+ let checkList = [ 'missing_values' , 'fill_value' ] ;
437
+ checkList . forEach ( checkKey => {
438
+ try {
439
+ state [ checkKey ] = com_util . convertToStr ( state [ checkKey ] , state [ checkKey + '_istext' ] ) ;
440
+ } catch ( e ) {
441
+ ;
442
+ }
443
+ } ) ;
444
+ }
445
+
425
446
// model code
426
447
let modelCode = config . code ;
427
- modelCode = com_generator . vp_codeGenerator ( this , config , this . state , ( userOption != '' ? ', ' + userOption : '' ) ) ;
448
+ modelCode = com_generator . vp_codeGenerator ( this , config , state , ( userOption != '' ? ', ' + userOption : '' ) ) ;
428
449
429
450
// generate mct code
430
- if ( modelType == 'make-column-transformer' ) {
451
+ if ( modelType === 'make-column-transformer' ) {
431
452
let mctCodes = [ ] ;
432
- let { mct_estimator1, mct_columns1, mct_estimator2, mct_columns2 } = this . state ;
453
+ let { mct_estimator1, mct_columns1, mct_estimator2, mct_columns2 } = state ;
433
454
if ( mct_estimator1 != undefined && mct_estimator1 != '' ) {
434
455
code . appendLine ( this . modelConfig [ mct_estimator1 ] . import ) ;
435
- let estimator1code = com_generator . vp_codeGenerator ( this , this . modelConfig [ mct_estimator1 ] , this . state , ( userOption != '' ? ', ' + userOption : '' ) ) ;
456
+ let estimator1code = com_generator . vp_codeGenerator ( this , this . modelConfig [ mct_estimator1 ] , state , ( userOption != '' ? ', ' + userOption : '' ) ) ;
436
457
mctCodes . push ( com_util . formatString ( '({0}, [{1}])' , estimator1code , mct_columns1 ) ) ;
437
458
}
438
459
if ( mct_estimator2 != undefined && mct_estimator2 != '' ) {
439
460
code . appendLine ( this . modelConfig [ mct_estimator2 ] . import ) ;
440
- let estimator2code = com_generator . vp_codeGenerator ( this , this . modelConfig [ mct_estimator2 ] , this . state , ( userOption != '' ? ', ' + userOption : '' ) ) ;
461
+ let estimator2code = com_generator . vp_codeGenerator ( this , this . modelConfig [ mct_estimator2 ] , state , ( userOption != '' ? ', ' + userOption : '' ) ) ;
441
462
mctCodes . push ( com_util . formatString ( '({0}, [{1}])' , estimator2code , mct_columns2 ) ) ;
442
463
}
443
464
modelCode = modelCode . replace ( '${mct_code}' , mctCodes . join ( ', ' ) ) ;
0 commit comments