@@ -36,6 +36,7 @@ define([
3636 featureData : '' ,
3737 targetData : '' ,
3838 testSize : 0.25 ,
39+ shuffle : 'True' ,
3940 trainFeatures : 'X_train' ,
4041 trainTarget : 'y_train' ,
4142 testFeatures : 'X_test' ,
@@ -74,6 +75,18 @@ define([
7475 $ ( that . wrapSelector ( '#testFeatures' ) ) . val ( 'test' ) . trigger ( 'change' ) ;
7576 }
7677 } ) ;
78+
79+ // Stratify depends on Shuffle
80+ $ ( this . wrapSelector ( '#shuffle' ) ) . on ( 'change' , function ( ) {
81+ let shuffle = $ ( this ) . val ( ) ;
82+ if ( shuffle == 'True' ) {
83+ // enable stratify
84+ $ ( that . wrapSelector ( '#stratify' ) ) . prop ( 'disabled' , false ) ;
85+ } else {
86+ // disable stratify
87+ $ ( that . wrapSelector ( '#stratify' ) ) . prop ( 'disabled' , true ) ;
88+ }
89+ } ) ;
7790 }
7891
7992 templateForBody ( ) {
@@ -82,7 +95,7 @@ define([
8295 // test size generating
8396 let sizeOptions = '' ;
8497 for ( let i = 5 ; i < 95 ; i += 5 ) {
85- sizeOptions += `<option value="0. ${ i } " ${ this . state . testSize == ( '0.' + i ) ?'selected' :'' } >
98+ sizeOptions += `<option value="${ i / 100 } " ${ parseFloat ( this . state . testSize ) == ( i / 100 ) ?'selected' :'' } >
8699 ${ i } %${ i == 25 ?' (default)' :'' }
87100 </option>` ;
88101 }
@@ -106,7 +119,7 @@ define([
106119 varSelector = new VarSelector2 ( this . wrapSelector ( ) , [ 'DataFrame' , 'List' , 'string' ] ) ;
107120 varSelector . setComponentID ( 'stratify' ) ;
108121 varSelector . addClass ( 'vp-state vp-input' ) ;
109- varSelector . setValue ( this . state . targetData ) ;
122+ varSelector . setValue ( this . state . stratify ) ;
110123 varSelector . setPlaceholder ( 'None' ) ;
111124 $ ( page ) . find ( '#stratify' ) . replaceWith ( varSelector . toTagString ( ) ) ;
112125
@@ -152,7 +165,7 @@ define([
152165 let {
153166 trainFeatures, trainTarget, testFeatures, testTarget,
154167 inputData, featureData, targetData,
155- testSize, randomState, shuffle, startify
168+ testSize, randomState, shuffle, stratify
156169 } = this . state ;
157170
158171 let options = new com_String ( ) ;
@@ -162,11 +175,11 @@ define([
162175 if ( randomState && randomState != '' ) {
163176 options . appendFormat ( ', random_state={0}' , randomState ) ;
164177 }
165- if ( shuffle && shuffle != '' ) {
178+ if ( shuffle && shuffle != 'True ' ) {
166179 options . appendFormat ( ', shuffle={0}' , shuffle ) ;
167180 }
168- if ( startify && startify != '' ) {
169- options . appendFormat ( ', startify={0}' , startify ) ;
181+ if ( shuffle != 'False' && stratify && stratify != '' ) {
182+ options . appendFormat ( ', startify={0}' , stratify ) ;
170183 }
171184
172185 let code = new com_String ( ) ;
0 commit comments