@@ -85,26 +85,28 @@ define([
8585} ,
8686'predict' :{
8787name :'predict' ,
88- code :'${model}.predict(${featureData})' ,
88+ code :'${allocatePredict} = ${ model}.predict(${featureData})' ,
8989description :'Predict the closest target data X belongs to.' ,
9090options :[
91- { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X_train' }
91+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X_test' } ,
92+ { name :'allocatePredict' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' , default :'pred' }
9293]
9394} ,
9495'predict_proba' :{
9596name :'predict_proba' ,
96- code :'${model}.predict_proba(${featureData})' ,
97+ code :'${allocatePredict} = ${ model}.predict_proba(${featureData})' ,
9798description :'Predict class probabilities for X.' ,
9899options :[
99- { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X_train' }
100+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X_test' } ,
101+ { name :'allocatePredict' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' , default :'pred' }
100102]
101103} ,
102104'transform' :{
103105name :'transform' ,
104106code :'${allocateTransform} = ${model}.transform(${featureData})' ,
105107description :'Apply dimensionality reduction to X.' ,
106108options :[
107- { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X_train ' } ,
109+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X ' } ,
108110{ name :'allocateTransform' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' }
109111]
110112}
@@ -113,7 +115,23 @@ define([
113115switch ( category ) {
114116case 'Data Preparation' :
115117actions = {
116- 'fit' :defaultActions [ 'fit' ] ,
118+ 'fit' :{
119+ name :'fit' ,
120+ code :'${model}.fit(${featureData})' ,
121+ description :'Fit Encoder/Scaler to X.' ,
122+ options :[
123+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X' }
124+ ]
125+ } ,
126+ 'fit_transform' :{
127+ name :'fit_transform' ,
128+ code :'${allocateTransform} = ${model}.fit_transform(${featureData})' ,
129+ description :'Fit Encoder/Scaler to X, then transform X.' ,
130+ options :[
131+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X' } ,
132+ { name :'allocateTransform' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' }
133+ ]
134+ } ,
117135'transform' :{
118136 ...defaultActions [ 'transform' ] ,
119137description :'Transform labels to normalized encoding.'
@@ -141,11 +159,31 @@ define([
141159'predict' :defaultActions [ 'predict' ] ,
142160'predict_proba' :defaultActions [ 'predict_proba' ] ,
143161}
162+ if ( [ 'LogisticRegression' , 'SVC' , 'GradientBoostingClassifier' ] . includes ( modelType ) ) {
163+ actions = {
164+ ...actions ,
165+ 'decision_function' :{
166+ name :'decision_function' ,
167+ code :'${allocateScore} = ${model}.decision_function(${featureData})' ,
168+ description :'Compute the decision function of X.' ,
169+ options :[
170+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X' } ,
171+ { name :'allocateScore' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' }
172+ ]
173+ }
174+ }
175+ }
144176break ;
145177case 'Auto ML' :
146178actions = {
147179'fit' :defaultActions [ 'fit' ] ,
148- 'predict' :defaultActions [ 'predict' ] ,
180+ 'predict' :defaultActions [ 'predict' ]
181+ }
182+ if ( modelType == 'TPOTClassifier' ) {
183+ actions = {
184+ ...actions ,
185+ 'predict_proba' :defaultActions [ 'predict_proba' ]
186+ }
149187}
150188break ;
151189case 'Clustering' :
@@ -155,10 +193,11 @@ define([
155193'fit' :defaultActions [ 'fit' ] ,
156194'fit_predict' :{
157195name :'fit_predict' ,
158- code :'${model}.fit_predict(${featureData})' ,
196+ code :'${allocatePredict} = ${ model}.fit_predict(${featureData})' ,
159197description :'Compute clusters from a data or distance matrix and predict labels.' ,
160198options :[
161- { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X_train' }
199+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X' } ,
200+ { name :'allocatePredict' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' , default :'pred' }
162201]
163202}
164203}
@@ -167,6 +206,37 @@ define([
167206actions = {
168207'fit' :defaultActions [ 'fit' ] ,
169208'predict' :defaultActions [ 'predict' ] ,
209+ 'fit_predict' :{
210+ name :'fit_predict' ,
211+ code :'${allocatePredict} = ${model}.fit_predict(${featureData})' ,
212+ description :'Compute cluster centers and predict cluster index for each sample.' ,
213+ options :[
214+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X' } ,
215+ { name :'allocatePredict' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' , default :'pred' }
216+ ]
217+ }
218+ }
219+ if ( modelType == 'KMeans' ) {
220+ actions = {
221+ ...actions ,
222+ 'fit_transform' :{
223+ name :'fit_transform' ,
224+ code :'${model}.fit_transform(${featureData})' ,
225+ description :'Compute clustering and transform X to cluster-distance space.' ,
226+ options :[
227+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X_train' }
228+ ]
229+ } ,
230+ 'transform' :{
231+ name :'transform' ,
232+ code :'${allocateTransform} = ${model}.transform(${featureData})' ,
233+ description :'Transform X to a cluster-distance space.' ,
234+ options :[
235+ { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X' } ,
236+ { name :'allocateTransform' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' }
237+ ]
238+ }
239+ }
170240}
171241break ;
172242case 'Dimension Reduction' :
@@ -303,15 +373,6 @@ define([
303373options :[
304374{ name :'allocateCenters' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' }
305375]
306- } ,
307- 'transform' :{
308- name :'transform' ,
309- code :'${allocateTransform} = ${model}.transform(${featureData})' ,
310- description :'Transform X to a cluster-distance space.' ,
311- options :[
312- { name :'featureData' , label :'Feature Data' , component :[ 'var_select' ] , var_type :[ 'DataFrame' , 'Series' ] , default :'X' } ,
313- { name :'allocateTransform' , label :'Allocate to' , component :[ 'input' ] , placeholder :'New variable' }
314- ]
315376}
316377}
317378}