Skip to content

Devops for v3.0.1 #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion visualpython/html/m_ml/evaluation.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<label><input type="checkbox" id="accuracy" class="vp-state"><span>Accuracy</span></label>
<label><input type="checkbox" id="precision" class="vp-state"><span>Precision</span></label>
<label><input type="checkbox" id="recall" class="vp-state"><span>Recall</span></label>
<label><input type="checkbox" id="f1_score" class="vp-state"><span>F1-scorev</label>
<label><input type="checkbox" id="f1_score" class="vp-state"><span>F1-score</label>
<!-- <hr style="margin: 5px;"/> -->
<!-- <label><input type="checkbox" id="roc_curve" class="vp-eval-check vp-state" data-type="roc-auc"><span>ROC Curve</span></label>
<label><input type="checkbox" id="auc" class="vp-eval-check vp-state" data-type="roc-auc"><span>AUC</span></label> -->
Expand Down
29 changes: 17 additions & 12 deletions visualpython/js/m_apps/Frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
]
},
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 12 additions & 2 deletions visualpython/js/m_apps/Groupby.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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(',') + ']]';
Expand Down Expand Up @@ -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')");
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions visualpython/js/m_apps/Subset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions visualpython/js/m_ml/evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion visualpython/python/userCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down