@@ -59,7 +59,7 @@ define([
5959 this . modelTypeList = {
6060 'Encoding' : [ 'prep-onehot' , 'prep-label' , 'prep-ordinal' , 'prep-target' , 'prep-smote' ] ,
6161 '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']
6363 }
6464
6565 this . mctEstimator = {
@@ -94,10 +94,19 @@ define([
9494 $ ( that . wrapSelector ( '#vp_installLibrary' ) ) . hide ( ) ;
9595 }
9696
97- if ( modelType == 'make-column-transformer' ) {
97+ if ( modelType === 'make-column-transformer' ) {
9898 // load mct-targetData
9999 that . loadVariableList ( ) ;
100100 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>` ) ;
101110 }
102111 } ) ;
103112
@@ -411,6 +420,7 @@ define([
411420
412421 generateCode ( ) {
413422 let { modelControlType, modelType, userOption, allocateToCreation, model } = this . state ;
423+ let state = JSON . parse ( JSON . stringify ( this . state ) ) ;
414424 let code = new com_String ( ) ;
415425 if ( modelControlType == 'creation' ) {
416426 /**
@@ -422,22 +432,33 @@ define([
422432 let config = this . modelConfig [ modelType ] ;
423433 code . appendLine ( config . import ) ;
424434
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+
425446 // model code
426447 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 : '' ) ) ;
428449
429450 // generate mct code
430- if ( modelType == 'make-column-transformer' ) {
451+ if ( modelType === 'make-column-transformer' ) {
431452 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 ;
433454 if ( mct_estimator1 != undefined && mct_estimator1 != '' ) {
434455 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 : '' ) ) ;
436457 mctCodes . push ( com_util . formatString ( '({0}, [{1}])' , estimator1code , mct_columns1 ) ) ;
437458 }
438459 if ( mct_estimator2 != undefined && mct_estimator2 != '' ) {
439460 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 : '' ) ) ;
441462 mctCodes . push ( com_util . formatString ( '({0}, [{1}])' , estimator2code , mct_columns2 ) ) ;
442463 }
443464 modelCode = modelCode . replace ( '${mct_code}' , mctCodes . join ( ', ' ) ) ;
0 commit comments