@@ -85,26 +85,28 @@ define([
85
85
} ,
86
86
'predict' : {
87
87
name : 'predict' ,
88
- code : '${model}.predict(${featureData})' ,
88
+ code : '${allocatePredict} = ${ model}.predict(${featureData})' ,
89
89
description : 'Predict the closest target data X belongs to.' ,
90
90
options : [
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' }
92
93
]
93
94
} ,
94
95
'predict_proba' : {
95
96
name : 'predict_proba' ,
96
- code : '${model}.predict_proba(${featureData})' ,
97
+ code : '${allocatePredict} = ${ model}.predict_proba(${featureData})' ,
97
98
description : 'Predict class probabilities for X.' ,
98
99
options : [
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' }
100
102
]
101
103
} ,
102
104
'transform' : {
103
105
name : 'transform' ,
104
106
code : '${allocateTransform} = ${model}.transform(${featureData})' ,
105
107
description : 'Apply dimensionality reduction to X.' ,
106
108
options : [
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 ' } ,
108
110
{ name : 'allocateTransform' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' }
109
111
]
110
112
}
@@ -113,7 +115,23 @@ define([
113
115
switch ( category ) {
114
116
case 'Data Preparation' :
115
117
actions = {
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
+ } ,
117
135
'transform' : {
118
136
...defaultActions [ 'transform' ] ,
119
137
description : 'Transform labels to normalized encoding.'
@@ -141,11 +159,31 @@ define([
141
159
'predict' : defaultActions [ 'predict' ] ,
142
160
'predict_proba' : defaultActions [ 'predict_proba' ] ,
143
161
}
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
+ }
144
176
break ;
145
177
case 'Auto ML' :
146
178
actions = {
147
179
'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
+ }
149
187
}
150
188
break ;
151
189
case 'Clustering' :
@@ -155,10 +193,11 @@ define([
155
193
'fit' : defaultActions [ 'fit' ] ,
156
194
'fit_predict' : {
157
195
name : 'fit_predict' ,
158
- code : '${model}.fit_predict(${featureData})' ,
196
+ code : '${allocatePredict} = ${ model}.fit_predict(${featureData})' ,
159
197
description : 'Compute clusters from a data or distance matrix and predict labels.' ,
160
198
options : [
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' }
162
201
]
163
202
}
164
203
}
@@ -167,6 +206,37 @@ define([
167
206
actions = {
168
207
'fit' : defaultActions [ 'fit' ] ,
169
208
'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
+ }
170
240
}
171
241
break ;
172
242
case 'Dimension Reduction' :
@@ -303,15 +373,6 @@ define([
303
373
options : [
304
374
{ name : 'allocateCenters' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' }
305
375
]
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
- ]
315
376
}
316
377
}
317
378
}
0 commit comments