Skip to content

Commit d503f5d

Browse files
authored
Merge pull request #252 from minjk-bl/devops
Devops for v3.0.1
2 parents b195d05 + 25bd448 commit d503f5d

File tree

6 files changed

+39
-20
lines changed

6 files changed

+39
-20
lines changed

visualpython/html/m_ml/evaluation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<label><input type="checkbox" id="accuracy" class="vp-state"><span>Accuracy</span></label>
3939
<label><input type="checkbox" id="precision" class="vp-state"><span>Precision</span></label>
4040
<label><input type="checkbox" id="recall" class="vp-state"><span>Recall</span></label>
41-
<label><input type="checkbox" id="f1_score" class="vp-state"><span>F1-scorev</label>
41+
<label><input type="checkbox" id="f1_score" class="vp-state"><span>F1-score</label>
4242
<!-- <hr style="margin: 5px;"/> -->
4343
<!-- <label><input type="checkbox" id="roc_curve" class="vp-eval-check vp-state" data-type="roc-auc"><span>ROC Curve</span></label>
4444
<label><input type="checkbox" id="auc" class="vp-eval-check vp-state" data-type="roc-auc"><span>AUC</span></label> -->

visualpython/js/m_apps/Frame.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ define([
115115
id: 'encoding',
116116
label: 'Encoding',
117117
axis: FRAME_AXIS.COLUMN,
118-
selection: FRAME_SELECT_TYPE.SINGLE,
118+
selection: FRAME_SELECT_TYPE.MULTI,
119119
child: [
120-
{ id: 'label_encoding', label: 'Label encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.SINGLE, menuType: FRAME_EDIT_TYPE.LABEL_ENCODING },
121-
{ id: 'one_hot_encoding', label: 'Onehot encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.SINGLE, menuType: FRAME_EDIT_TYPE.ONE_HOT_ENCODING },
120+
{ id: 'label_encoding', label: 'Label encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.MULTI, menuType: FRAME_EDIT_TYPE.LABEL_ENCODING },
121+
{ id: 'one_hot_encoding', label: 'Onehot encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.MULTI, menuType: FRAME_EDIT_TYPE.ONE_HOT_ENCODING },
122122
]
123123
},
124124
{
@@ -2767,7 +2767,7 @@ define([
27672767
var condText = $(condTextTag[i]).prop('checked');
27682768
var operConn = $(operConnTag[i]).val();
27692769
var condObj = {};
2770-
if (col !== '' && oper !== '' && cond !== '') {
2770+
if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
27712771
condObj = {
27722772
oper: oper,
27732773
cond: com_util.convertToStr(cond, condText)
@@ -2808,7 +2808,7 @@ define([
28082808
var condText = $(condTextTag[i]).prop('checked');
28092809
var operConn = $(operConnTag[i]).val();
28102810
var condObj = {};
2811-
if (col !== '' && oper !== '' && cond !== '') {
2811+
if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
28122812
condObj = {
28132813
colName: col,
28142814
oper: oper,
@@ -2861,7 +2861,7 @@ define([
28612861
var condText = $(condTextTag[i]).prop('checked');
28622862
var operConn = $(operConnTag[i]).val();
28632863
var condObj = {};
2864-
if (col !== '' && oper !== '' && cond !== '') {
2864+
if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
28652865
condObj = {
28662866
colName: col,
28672867
oper: oper,
@@ -2894,7 +2894,7 @@ define([
28942894
var condText = $(condTextTag[i]).prop('checked');
28952895
var operConn = $(operConnTag[i]).val();
28962896
var condObj = {};
2897-
if (col !== '' && oper !== '' && cond !== '') {
2897+
if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
28982898
condObj = {
28992899
oper: oper,
29002900
cond: com_util.convertToStr(cond, condText)
@@ -3237,13 +3237,18 @@ define([
32373237
break;
32383238
case FRAME_EDIT_TYPE.LABEL_ENCODING:
32393239
if (axis == FRAME_AXIS.COLUMN) {
3240-
let encodedColName = this.state.selected.map(col=> {
3240+
let encodedColNameList = this.state.selected.map(col=> {
32413241
if (col.code !== col.label) {
3242-
return com_util.formatString("'{0}'", col.label + '_label');
3242+
return { 'origin': com_util.formatString("'{0}'", col.label), 'encoded': com_util.formatString("'{0}'", col.label + '_label') };
32433243
}
3244-
return col.label + '_label'
3245-
}).join(',');
3246-
code.appendFormat("{0}[{1}] = pd.Categorical({2}[{3}]).codes", tempObj, encodedColName, tempObj, selectedName);
3244+
return { 'origin': col.label, 'encoded': col.label + '_label' };
3245+
});
3246+
encodedColNameList.forEach((encodedColObj, idx) => {
3247+
if (idx > 0) {
3248+
code.appendLine();
3249+
}
3250+
code.appendFormat("{0}[{1}] = pd.Categorical({2}[{3}]).codes", tempObj, encodedColObj['encoded'], tempObj, encodedColObj['origin']);
3251+
});
32473252
}
32483253
break;
32493254
case FRAME_EDIT_TYPE.ONE_HOT_ENCODING:

visualpython/js/m_apps/Groupby.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ define([
177177
var colList = event.dataList;
178178
that.state.display = colList;
179179

180-
if (colList && colList.length == 1) {
180+
if ((colList && colList.length == 1) || that.state.method === 'size') {
181181
$(that.wrapSelector('#vp_gbToFrame')).parent().show();
182182
} else {
183183
$(that.wrapSelector('#vp_gbToFrame')).parent().hide();
@@ -196,6 +196,12 @@ define([
196196
var method = $(this).val();
197197
that.state.method = method;
198198
$(that.wrapSelector('#vp_gbMethod')).val(method);
199+
200+
if (method === 'size' || (that.state.display && that.state.display.length == 1)) {
201+
$(that.wrapSelector('#vp_gbToFrame')).parent().show();
202+
} else {
203+
$(that.wrapSelector('#vp_gbToFrame')).parent().hide();
204+
}
199205
});
200206

201207
// advanced checkbox event
@@ -744,7 +750,7 @@ define([
744750
// Display columns
745751
//====================================================================
746752
var colStr = '';
747-
if (display) {
753+
if (display && display.length > 0) {
748754
if (toFrame || display.length > 1) {
749755
// over 2 columns
750756
colStr = '[[' + display.join(',') + ']]';
@@ -891,6 +897,10 @@ define([
891897
methodStr.appendFormat('{0}(numeric_only=True)', method);
892898
} else {
893899
methodStr.appendFormat('{0}()', method);
900+
if (method === 'size' && toFrame === true) {
901+
// if to_Frame on size() method
902+
methodStr.append(".to_frame(name='size')");
903+
}
894904
}
895905
}
896906
}

visualpython/js/m_apps/Subset.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,10 @@ define([
18101810
rowSelection.append(')');
18111811
} else {
18121812
rowSelection.appendFormat('({0}', varName);
1813+
if (colName == '.index') {
1814+
// index
1815+
rowSelection.append('.index');
1816+
}
18131817
oper && rowSelection.appendFormat(' {0}', oper);
18141818
if (cond) {
18151819
// condition value as text
@@ -1863,7 +1867,7 @@ define([
18631867
var colList = [];
18641868
for (var i = 0; i < colTags.length; i++) {
18651869
var colValue = $(colTags[i]).data('code');
1866-
if (colValue) {
1870+
if (colValue !== undefined) {
18671871
colList.push(colValue);
18681872
}
18691873
}
@@ -1873,7 +1877,7 @@ define([
18731877
$(this.wrapSelector('.' + VP_DS_TO_FRAME)).parent().show();
18741878

18751879
// to frame
1876-
if (this.state.toFrame) {
1880+
if (this.state.toFrame === true) {
18771881
colSelection.appendFormat('[{0}]', colList.toString());
18781882
this.state.returnType = 'DataFrame';
18791883
} else {

visualpython/js/m_ml/evaluation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ define([
276276
// }
277277
if (r_squared) {
278278
code = new com_String();
279-
code.appendLine("# R square");
280-
code.appendFormat("print('R square: {}'.format(metrics.r2_score({0}, {1})))", targetData, predictData);
279+
code.appendLine("# R squared");
280+
code.appendFormat("print('R squared: {}'.format(metrics.r2_score({0}, {1})))", targetData, predictData);
281281
codeCells.push(code.toString());
282282
}
283283
if (mae) {

visualpython/python/userCommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def vp_create_permutation_importances(model, X_train, y_train, scoring=None, sor
130130
if isinstance(X_train, _vp_pd.core.frame.DataFrame):
131131
feature_names = X_train.columns
132132
else:
133-
feature_names = [ 'X{}'.format(i) for i in range(len(model.feature_importances_)) ]
133+
feature_names = [ 'X{}'.format(i) for i in range(X_train.shape[1]) ]
134134

135135
imp = permutation_importance(model, X_train, y_train, scoring=scoring)
136136

0 commit comments

Comments
 (0)