diff --git a/visualpython/html/m_ml/evaluation.html b/visualpython/html/m_ml/evaluation.html
index 88979916..407d2870 100644
--- a/visualpython/html/m_ml/evaluation.html
+++ b/visualpython/html/m_ml/evaluation.html
@@ -38,7 +38,7 @@
-
+
diff --git a/visualpython/js/m_apps/Frame.js b/visualpython/js/m_apps/Frame.js
index 438dfc79..c45b7ad1 100644
--- a/visualpython/js/m_apps/Frame.js
+++ b/visualpython/js/m_apps/Frame.js
@@ -115,10 +115,10 @@ define([
id: 'encoding',
label: 'Encoding',
axis: FRAME_AXIS.COLUMN,
- selection: FRAME_SELECT_TYPE.SINGLE,
+ selection: FRAME_SELECT_TYPE.MULTI,
child: [
- { id: 'label_encoding', label: 'Label encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.SINGLE, menuType: FRAME_EDIT_TYPE.LABEL_ENCODING },
- { id: 'one_hot_encoding', label: 'Onehot encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.SINGLE, menuType: FRAME_EDIT_TYPE.ONE_HOT_ENCODING },
+ { id: 'label_encoding', label: 'Label encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.MULTI, menuType: FRAME_EDIT_TYPE.LABEL_ENCODING },
+ { id: 'one_hot_encoding', label: 'Onehot encoding', axis: FRAME_AXIS.COLUMN, selection: FRAME_SELECT_TYPE.MULTI, menuType: FRAME_EDIT_TYPE.ONE_HOT_ENCODING },
]
},
{
@@ -2767,7 +2767,7 @@ define([
var condText = $(condTextTag[i]).prop('checked');
var operConn = $(operConnTag[i]).val();
var condObj = {};
- if (col !== '' && oper !== '' && cond !== '') {
+ if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
condObj = {
oper: oper,
cond: com_util.convertToStr(cond, condText)
@@ -2808,7 +2808,7 @@ define([
var condText = $(condTextTag[i]).prop('checked');
var operConn = $(operConnTag[i]).val();
var condObj = {};
- if (col !== '' && oper !== '' && cond !== '') {
+ if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
condObj = {
colName: col,
oper: oper,
@@ -2861,7 +2861,7 @@ define([
var condText = $(condTextTag[i]).prop('checked');
var operConn = $(operConnTag[i]).val();
var condObj = {};
- if (col !== '' && oper !== '' && cond !== '') {
+ if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
condObj = {
colName: col,
oper: oper,
@@ -2894,7 +2894,7 @@ define([
var condText = $(condTextTag[i]).prop('checked');
var operConn = $(operConnTag[i]).val();
var condObj = {};
- if (col !== '' && oper !== '' && cond !== '') {
+ if (col !== '' && oper !== '' && (oper == 'isnull()' || oper === 'notnull()' || cond !== '')) {
condObj = {
oper: oper,
cond: com_util.convertToStr(cond, condText)
@@ -3237,13 +3237,18 @@ define([
break;
case FRAME_EDIT_TYPE.LABEL_ENCODING:
if (axis == FRAME_AXIS.COLUMN) {
- let encodedColName = this.state.selected.map(col=> {
+ let encodedColNameList = this.state.selected.map(col=> {
if (col.code !== col.label) {
- return com_util.formatString("'{0}'", col.label + '_label');
+ return { 'origin': com_util.formatString("'{0}'", col.label), 'encoded': com_util.formatString("'{0}'", col.label + '_label') };
}
- return col.label + '_label'
- }).join(',');
- code.appendFormat("{0}[{1}] = pd.Categorical({2}[{3}]).codes", tempObj, encodedColName, tempObj, selectedName);
+ return { 'origin': col.label, 'encoded': col.label + '_label' };
+ });
+ encodedColNameList.forEach((encodedColObj, idx) => {
+ if (idx > 0) {
+ code.appendLine();
+ }
+ code.appendFormat("{0}[{1}] = pd.Categorical({2}[{3}]).codes", tempObj, encodedColObj['encoded'], tempObj, encodedColObj['origin']);
+ });
}
break;
case FRAME_EDIT_TYPE.ONE_HOT_ENCODING:
diff --git a/visualpython/js/m_apps/Groupby.js b/visualpython/js/m_apps/Groupby.js
index 7b61d561..589882f0 100644
--- a/visualpython/js/m_apps/Groupby.js
+++ b/visualpython/js/m_apps/Groupby.js
@@ -177,7 +177,7 @@ define([
var colList = event.dataList;
that.state.display = colList;
- if (colList && colList.length == 1) {
+ if ((colList && colList.length == 1) || that.state.method === 'size') {
$(that.wrapSelector('#vp_gbToFrame')).parent().show();
} else {
$(that.wrapSelector('#vp_gbToFrame')).parent().hide();
@@ -196,6 +196,12 @@ define([
var method = $(this).val();
that.state.method = method;
$(that.wrapSelector('#vp_gbMethod')).val(method);
+
+ if (method === 'size' || (that.state.display && that.state.display.length == 1)) {
+ $(that.wrapSelector('#vp_gbToFrame')).parent().show();
+ } else {
+ $(that.wrapSelector('#vp_gbToFrame')).parent().hide();
+ }
});
// advanced checkbox event
@@ -744,7 +750,7 @@ define([
// Display columns
//====================================================================
var colStr = '';
- if (display) {
+ if (display && display.length > 0) {
if (toFrame || display.length > 1) {
// over 2 columns
colStr = '[[' + display.join(',') + ']]';
@@ -891,6 +897,10 @@ define([
methodStr.appendFormat('{0}(numeric_only=True)', method);
} else {
methodStr.appendFormat('{0}()', method);
+ if (method === 'size' && toFrame === true) {
+ // if to_Frame on size() method
+ methodStr.append(".to_frame(name='size')");
+ }
}
}
}
diff --git a/visualpython/js/m_apps/Subset.js b/visualpython/js/m_apps/Subset.js
index 35f2e74e..7c7c74c8 100644
--- a/visualpython/js/m_apps/Subset.js
+++ b/visualpython/js/m_apps/Subset.js
@@ -1810,6 +1810,10 @@ define([
rowSelection.append(')');
} else {
rowSelection.appendFormat('({0}', varName);
+ if (colName == '.index') {
+ // index
+ rowSelection.append('.index');
+ }
oper && rowSelection.appendFormat(' {0}', oper);
if (cond) {
// condition value as text
@@ -1863,7 +1867,7 @@ define([
var colList = [];
for (var i = 0; i < colTags.length; i++) {
var colValue = $(colTags[i]).data('code');
- if (colValue) {
+ if (colValue !== undefined) {
colList.push(colValue);
}
}
@@ -1873,7 +1877,7 @@ define([
$(this.wrapSelector('.' + VP_DS_TO_FRAME)).parent().show();
// to frame
- if (this.state.toFrame) {
+ if (this.state.toFrame === true) {
colSelection.appendFormat('[{0}]', colList.toString());
this.state.returnType = 'DataFrame';
} else {
diff --git a/visualpython/js/m_ml/evaluation.js b/visualpython/js/m_ml/evaluation.js
index 92c59eca..1cf1552d 100644
--- a/visualpython/js/m_ml/evaluation.js
+++ b/visualpython/js/m_ml/evaluation.js
@@ -276,8 +276,8 @@ define([
// }
if (r_squared) {
code = new com_String();
- code.appendLine("# R square");
- code.appendFormat("print('R square: {}'.format(metrics.r2_score({0}, {1})))", targetData, predictData);
+ code.appendLine("# R squared");
+ code.appendFormat("print('R squared: {}'.format(metrics.r2_score({0}, {1})))", targetData, predictData);
codeCells.push(code.toString());
}
if (mae) {
diff --git a/visualpython/python/userCommand.py b/visualpython/python/userCommand.py
index 12ad039b..78034078 100644
--- a/visualpython/python/userCommand.py
+++ b/visualpython/python/userCommand.py
@@ -130,7 +130,7 @@ def vp_create_permutation_importances(model, X_train, y_train, scoring=None, sor
if isinstance(X_train, _vp_pd.core.frame.DataFrame):
feature_names = X_train.columns
else:
- feature_names = [ 'X{}'.format(i) for i in range(len(model.feature_importances_)) ]
+ feature_names = [ 'X{}'.format(i) for i in range(X_train.shape[1]) ]
imp = permutation_importance(model, X_train, y_train, scoring=scoring)