diff --git a/build.sh b/build.sh
index 0652bfab..2178b3ce 100755
--- a/build.sh
+++ b/build.sh
@@ -11,8 +11,8 @@
#=============================================================================
# Set version and replace it
#=============================================================================
-VP_ORG_VER=3.0.0
-VP_NEW_VER=3.0.1
+VP_ORG_VER=3.0.1
+VP_NEW_VER=3.0.2
# update version info
grep -REil "VP_ORG_VER=.+$" colab/build.colab.sh jupyterlab/build.jupyterlab.sh jupyternotebook/build.jupyternotebook.sh | xargs sed -i "s/VP_ORG_VER=.\+$/VP_ORG_VER=${VP_ORG_VER}/g"
diff --git a/colab/build.colab.sh b/colab/build.colab.sh
index 060adaa7..2ad68893 100755
--- a/colab/build.colab.sh
+++ b/colab/build.colab.sh
@@ -11,8 +11,8 @@
#=============================================================================
# Replace Version
#=============================================================================
-VP_ORG_VER=3.0.0
-VP_NEW_VER=3.0.1
+VP_ORG_VER=3.0.1
+VP_NEW_VER=3.0.2
# update version info
# update manifest version with new numbering for new version
diff --git a/colab/manifest.json b/colab/manifest.json
index cf99ce04..c3509bcc 100644
--- a/colab/manifest.json
+++ b/colab/manifest.json
@@ -1,7 +1,7 @@
{
"name": "Visual Python for Colab",
"description": "GUI-based Python code generator for Google Colab as an extension",
- "version": "3.0.1",
+ "version": "3.0.2",
"manifest_version": 3,
"icons": {
"48": "icon.png",
diff --git a/jupyterlab/README.md b/jupyterlab/README.md
index a03d89a5..6b4bcd90 100644
--- a/jupyterlab/README.md
+++ b/jupyterlab/README.md
@@ -47,7 +47,7 @@ pip install jupyterlab-visualpython
Click orange square button on the right side of Jupyter Lab.
-## Getting Started with Jupyter Notebook(>= 7.x)
+## Getting Started with Jupyter Notebook 7
### 1. Requirements
@@ -66,13 +66,13 @@ pip install jupyterlab-visualpython
Click orange square button on the toolbar of Jupyter Notebook.
-## Getting Started with Jupyter Notebook(<=6.x.x)
+## Getting Started with Jupyter Notebook (for 6.x.x and older version)
### 1. Requirements
Visual Python is an extension to Jupyter Notebook, so you must have Jupyter Notebook installed already. You need old version of Jupyter Notebook under version 6.x.x.
- Python version 3.x
-- Jupyter notebook environment <=6.x
+- Jupyter notebook environment <= 6.x
### 2. How to Install
@@ -152,6 +152,7 @@ All skills from programmers, non-programmers, designers are welcomed.
[ ](https://github.com/llbtl)
[ ](https://github.com/blacklogicdev)
[ ](https://github.com/Minku-Koo)
+[ ](https://github.com/8orrin9)
Whoever wants to contribute or join our community,
You can contact us by creating issues on [Issue page](https://github.com/visualpython/visualpython/issues) or using [Discord server](https://discord.gg/PypQrBZWZv).
@@ -171,4 +172,4 @@ To create an environment where everyone can learn and use big data analytical sk
Love Visual Python?
Your support will help us continue to actively develop and improve Visual Python.☕
-[](https://github.com/sponsors/visualpython?frequency=recurring)
\ No newline at end of file
+[](https://github.com/sponsors/visualpython?frequency=recurring)
diff --git a/jupyterlab/Untitled.ipynb b/jupyterlab/Untitled.ipynb
new file mode 100644
index 00000000..f7fc91e8
--- /dev/null
+++ b/jupyterlab/Untitled.ipynb
@@ -0,0 +1,365 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "a891a0cd-ae74-4eaf-84fe-8072d65c83b2",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "id": "db6f55ff-9ddc-4ec1-909b-9582d84f8186",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Visual Python: Data Analysis > Import\n",
+ "import numpy as np\n",
+ "import pandas as pd\n",
+ "import matplotlib.pyplot as plt\n",
+ "%matplotlib inline\n",
+ "import seaborn as sns"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "id": "e6648223-bd7a-4fcc-8beb-536030401ef6",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
@@ -599,22 +621,93 @@ define([
switch (dataType) {
case 'DataFrame':
- // render option page
- $(this.wrapSelector('.vp-ds-option-inner-box')).html(this.templateForMultiSelector());
// column selecting
- this._columnSelector = new MultiSelector(this.wrapSelector('.vp-ds-df-multiselector'),
- { mode: 'columns', parent: [data], selectedList: this.state.indexing, allowAdd: true }
- );
-
+ if (this.prop.columnSelection === 'single') {
+ // render option page
+ $(this.wrapSelector('.vp-ds-option-inner-box')).html(this.templateForSingleSelector());
+ // bind column source
+ // com_generator.vp_bindColumnSource(this, 'data', ['singleColumn'], 'select', false, false);
+ // vp_bindColumnSource(pageThis, targetId, columnInputIdList, tagType="input", columnWithEmpty=false, columnWithIndex=false)
+ const columnInputIdList = ['singleColumn'];
+ if (data === '') {
+ // reset with no source
+ columnInputIdList && columnInputIdList.forEach(columnInputId => {
+ let defaultValue = that.state[columnInputId];
+ if (defaultValue === null || defaultValue === undefined) {
+ defaultValue = '';
+ }
+ // option tags
+ var tag = $('
').attr({
+ 'id': columnInputId,
+ 'class': 'vp-select vp-state'
+ });
+ $(that.wrapSelector('#' + columnInputId)).replaceWith(function() {
+ return $(tag);
+ });
+ });
+ return ;
+ }
+ // get result and show on detail box
+ vpKernel.getColumnList(data).then(function(resultObj) {
+ try {
+ let { result, type, msg } = resultObj;
+ var { list } = JSON.parse(result);
+
+ // columns using suggestInput
+ columnInputIdList && columnInputIdList.forEach((columnInputId, idx) => {
+ let defaultValue = that.state[columnInputId];
+ if (defaultValue === null || defaultValue === undefined) {
+ defaultValue = '';
+ }
+ // create tag
+ var tag = $('
').attr({
+ 'id': columnInputId,
+ 'class': 'vp-select vp-state w150'
+ });
+ // make tag
+ list.forEach((listVar, idx) => {
+ var option = document.createElement('option');
+ $(option).attr({
+ 'value':listVar.value,
+ 'text':listVar.label,
+ 'data-type':listVar.dtype
+ });
+ // cell metadata test : defaultValue as selected
+ if (listVar.value === defaultValue) {
+ $(option).prop('selected', true);
+ }
+ option.append(document.createTextNode(listVar.label));
+ $(tag).append(option);
+ });
+ $(that.wrapSelector('#' + columnInputId)).replaceWith(function() {
+ return $(tag);
+ });
+ $(that.wrapSelector('#' + columnInputId)).trigger('change');
+ }).catch(function(err) {
+ vpLog.display(VP_LOG_TYPE.ERROR, 'com_generator - bindColumnSource error ', err)
+ });
+ } catch (e) {
+ vpLog.display(VP_LOG_TYPE.ERROR, 'com_generator - bindColumnSource: not supported data type. ', e);
+ }
+ });
+ } else {
+ // render option page
+ $(this.wrapSelector('.vp-ds-option-inner-box')).html(this.templateForMultiSelector());
+ this._columnSelector = new MultiSelector(this.wrapSelector('.vp-ds-df-multiselector'),
+ { mode: 'columns', parent: [data], selectedList: this.state.indexing, allowAdd: true }
+ );
+ }
// bind event
$(this.wrapSelector('#useIndex')).on('change', function() {
let checked = $(this).prop('checked');
that.state.useIndex = checked;
if (checked === true) {
$(that.wrapSelector('.vp-ds-df-multiselector')).hide();
+ $(that.wrapSelector('.vp-ds-df-singleselector')).hide();
$(that.wrapSelector('.vp-ds-df-index-box')).show();
} else {
$(that.wrapSelector('.vp-ds-df-multiselector')).show();
+ $(that.wrapSelector('.vp-ds-df-singleselector')).show();
$(that.wrapSelector('.vp-ds-df-index-box')).hide();
}
});
@@ -728,6 +821,7 @@ define([
let {
data, dataType,
useIndex,
+ singleColumn,
slicingStart1, slicingEnd1,
slicingStart2, slicingEnd2,
ndRowType, ndColType
@@ -742,21 +836,39 @@ define([
code.append('.index');
} else {
// use column selector
- if (this._columnSelector != null) {
- let result = this._columnSelector.getDataList();
- this.state.indexing = result.map(obj => obj.code); // save state
- let columnList = [];
- result && result.forEach(obj => {
- columnList.push(obj.code);
- });
- if (columnList.length > 0) {
- if (columnList.length == 1) {
- // return as Series
- code.appendFormat('[{0}]', columnList.join(', '));
- // change datatype to Series
- this.state.returnDataType = 'Series';
- } else {
- code.appendFormat('[[{0}]]', columnList.join(', '));
+ if (this.prop.columnSelection === 'single') {
+ // single selector
+ if (this.prop.returnFrameType === 'DataFrame') {
+ // return as DataFrame
+ code.appendFormat('[[{0}]]', singleColumn);
+ } else {
+ // return as Series
+ code.appendFormat('[{0}]', singleColumn);
+ this.state.returnDataType = 'Series';
+ }
+ } else {
+ // multiple selector
+ if (this._columnSelector != null) {
+ let result = this._columnSelector.getDataList();
+ this.state.indexing = result.map(obj => obj.code); // save state
+ let columnList = [];
+ result && result.forEach(obj => {
+ columnList.push(obj.code);
+ });
+ if (columnList.length > 0) {
+ if (columnList.length == 1) {
+ if (this.prop.returnFrameType === 'DataFrame') {
+ // return as DataFrame
+ code.appendFormat('[[{0}]]', columnList.join(', '));
+ } else {
+ // return as Series
+ code.appendFormat('[{0}]', columnList.join(', '));
+ // change datatype to Series
+ this.state.returnDataType = 'Series';
+ }
+ } else {
+ code.appendFormat('[[{0}]]', columnList.join(', '));
+ }
}
}
}
diff --git a/visualpython/js/com/component/ModelEditor.js b/visualpython/js/com/component/ModelEditor.js
index da24a5d0..c2fab057 100644
--- a/visualpython/js/com/component/ModelEditor.js
+++ b/visualpython/js/com/component/ModelEditor.js
@@ -125,7 +125,7 @@ define([
code: '${model}.fit(${fit_featureData})',
description: 'Fit Encoder/Scaler to X.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' }
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' }
]
},
'fit_transform': {
@@ -134,13 +134,19 @@ define([
code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
description: 'Fit Encoder/Scaler to X, then transform X.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
},
'transform': {
- ...defaultActions['transform'],
- description: 'Transform labels to normalized encoding.'
+ name: 'transform',
+ label: 'Transform',
+ code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
+ description: 'Transform labels to normalized encoding.',
+ options: [
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
+ { name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
+ ]
}
}
if (modelType != 'ColumnTransformer') {
@@ -152,12 +158,49 @@ define([
code: '${inverse_allocate} = ${model}.inverse_transform(${inverse_featureData})',
description: 'Transform binary labels back to multi-class labels.',
options: [
- { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'inverse_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'inv_trans' }
]
}
}
}
+ if (modelType == 'LabelEncoder') {
+ actions = {
+ ...actions,
+ 'fit': {
+ name: 'fit',
+ label: 'Fit',
+ code: '${model}.fit(${fit_featureData})',
+ description: 'Fit Encoder/Scaler to X.',
+ options: [
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X',
+ columnSelection: 'single', returnFrameType: 'Series' }
+ ]
+ },
+ 'fit_transform': {
+ name: 'fit_transform',
+ label: 'Fit and transform',
+ code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
+ description: 'Fit Encoder/Scaler to X, then transform X.',
+ options: [
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X',
+ columnSelection: 'single', returnFrameType: 'Series' },
+ { name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
+ ]
+ },
+ 'transform': {
+ name: 'transform',
+ label: 'Transform',
+ code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
+ description: 'Transform labels to normalized encoding.',
+ options: [
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X',
+ columnSelection: 'single', returnFrameType: 'Series' },
+ { name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
+ ]
+ }
+ }
+ }
if (modelType === 'SMOTE') {
actions = {
'fit': {
@@ -322,7 +365,7 @@ define([
code: '${model}.fit(${fit_featureData})',
description: 'Fit X into an embedded space.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' }
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' }
]
},
'fit_transform': {
@@ -331,7 +374,7 @@ define([
code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
description: 'Fit X into an embedded space and return that transformed output.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
}
@@ -346,17 +389,17 @@ define([
code: '${model}.fit(${fit_featureData}, ${fit_targetData})',
description: 'Fit the Linear Discriminant Analysis model.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_targetData', label: 'Target Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'y' }
]
},
'fit_transform': {
name: 'fit_transform',
label: 'Fit and transform',
- code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData}${fit_trans_targetData})',
+ code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData}, ${fit_trans_targetData})',
description: 'Fit to data, then transform it.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_targetData', label: 'Target Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'y' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
@@ -367,7 +410,7 @@ define([
code: '${pred_allocate} = ${model}.predict(${pred_featureData})',
description: 'Predict class labels for samples in X.',
options: [
- { name: 'pred_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'pred_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'pred_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'pred' }
]
},
@@ -377,7 +420,7 @@ define([
code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
description: 'Project data to maximize class separation.',
options: [
- { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
}
@@ -391,7 +434,7 @@ define([
code: '${model}.fit(${fit_featureData})',
description: 'Fit X into an embedded space.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' }
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' }
]
},
'fit_transform': {
@@ -400,7 +443,7 @@ define([
code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
description: 'Fit the model with X and apply the dimensionality reduction on X.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
},
@@ -410,7 +453,7 @@ define([
code: '${inverse_allocate} = ${model}.inverse_transform(${inverse_featureData})',
description: 'Transform data back to its original space.',
options: [
- { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'inverse_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'inv_trans' }
]
},
@@ -420,7 +463,7 @@ define([
code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
description: 'Apply dimensionality reduction to X.',
options: [
- { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
}
diff --git a/visualpython/js/com/component/MultiSelector.js b/visualpython/js/com/component/MultiSelector.js
index 33546d79..d9d3d9fa 100644
--- a/visualpython/js/com/component/MultiSelector.js
+++ b/visualpython/js/com/component/MultiSelector.js
@@ -443,62 +443,6 @@ define([
that._bindItemClickEvent();
});
- // item indexing
- $(this.wrapSelector('.' + APP_SELECT_ITEM)).on('click', function(event) {
- var dataIdx = $(this).attr('data-idx');
- var idx = $(this).index();
- var added = $(this).hasClass('added'); // right side added item?
- var selector = '';
-
- // remove selection for select box on the other side
- if (added) {
- // remove selection for left side
- $(that.wrapSelector('.' + APP_SELECT_ITEM + ':not(.added)')).removeClass('selected');
- // set selector
- selector = '.added';
- } else {
- // remove selection for right(added) side
- $(that.wrapSelector('.' + APP_SELECT_ITEM + '.added')).removeClass('selected');
- // set selector
- selector = ':not(.added)';
- }
-
- if (vpEvent.keyManager.keyCheck.ctrlKey) {
- // multi-select
- that.pointer = { start: idx, end: -1 };
- $(this).toggleClass('selected');
- } else if (vpEvent.keyManager.keyCheck.shiftKey) {
- // slicing
- var startIdx = that.pointer.start;
-
- if (startIdx == -1) {
- // no selection
- that.pointer = { start: idx, end: -1 };
- } else if (startIdx > idx) {
- // add selection from idx to startIdx
- var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector));
- for (var i = idx; i <= startIdx; i++) {
- $(tags[i]).addClass('selected');
- }
- that.pointer = { start: startIdx, end: idx };
- } else if (startIdx <= idx) {
- // add selection from startIdx to idx
- var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector));
- for (var i = startIdx; i <= idx; i++) {
- $(tags[i]).addClass('selected');
- }
- that.pointer = { start: startIdx, end: idx };
- }
- } else {
- // single-select
- that.pointer = { start: idx, end: -1 };
- // un-select others
- $(that.wrapSelector('.' + APP_SELECT_ITEM + selector)).removeClass('selected');
- // select this
- $(this).addClass('selected');
- }
- });
-
// item indexing - add all
$(this.wrapSelector('.' + APP_SELECT_ADD_ALL_BTN)).on('click', function(event) {
$(that.wrapSelector('.' + APP_SELECT_BOX + '.left .' + APP_SELECT_ITEM)).appendTo(
@@ -702,6 +646,7 @@ define([
let newItemIndex = this.dataList.length;
var targetTag = $(`
`);
$(targetTag).appendTo(
$(this.wrapSelector('.' + APP_SELECT_BOX + '.right'))
@@ -711,6 +656,8 @@ define([
$(this.wrapSelector('.' + APP_SELECT_ITEM)).removeClass('selected');
// clear item input
$(this.wrapSelector('.vp-cs-add-item-name')).val('');
+ // bind click event
+ this._bindItemClickEvent();
// bind draggable
this.bindDraggable();
}
diff --git a/visualpython/js/m_apps/File.js b/visualpython/js/m_apps/File.js
index bd93c4de..7e6bd848 100644
--- a/visualpython/js/m_apps/File.js
+++ b/visualpython/js/m_apps/File.js
@@ -498,15 +498,15 @@ define([
return suggestInput.toTagString();
});
- // seperator suggest input
+ // separator suggest input
$(this.wrapSelector('#sep')).replaceWith(function() {
- // seperator list :
+ // separator list :
var sepList = [',', '|', '\\t', '\\n', ':', ';', '-', '_', '&', '/', '\\'];
var suggestInput = new SuggestInput();
suggestInput.setComponentID('sep');
suggestInput.addClass('vp-input vp-state');
suggestInput.setSuggestList(function() { return sepList; });
- suggestInput.setPlaceholder('Input seperator');
+ suggestInput.setPlaceholder('Input separator');
return suggestInput.toTagString();
});
}
diff --git a/visualpython/js/m_apps/Frame.js b/visualpython/js/m_apps/Frame.js
index fd786ad0..4e91083d 100644
--- a/visualpython/js/m_apps/Frame.js
+++ b/visualpython/js/m_apps/Frame.js
@@ -3620,7 +3620,12 @@ define([
code.appendFormat(", limit={0}", content['limit']);
}
} else {
- code.appendFormat("{0}.{1}()", subsetObjStr, content['method']);
+ if (content['method'] === 'mode') {
+ // get mode()'s first element (mode returns Series)
+ code.appendFormat("{0}.{1}()[0]", subsetObjStr, content['method']);
+ } else {
+ code.appendFormat("{0}.{1}()", subsetObjStr, content['method']);
+ }
}
code.append(')');
break;
diff --git a/visualpython/js/m_apps/Subset.js b/visualpython/js/m_apps/Subset.js
index 7c7c74c8..41af3ef4 100644
--- a/visualpython/js/m_apps/Subset.js
+++ b/visualpython/js/m_apps/Subset.js
@@ -343,10 +343,13 @@ define([
$(this.wrapSelector('.select-row .vp-ds-select-box.left')).on('scroll', function() {
if ($(this).scrollTop() + $(this).innerHeight() >= ($(this)[0].scrollHeight - 2)) {
let scrollPos = $(this).scrollTop();
+ if (that.state.rowLimit > that.state.rowList.length){
+ return; // Prevents scroll from being fixed downwards
+ }
let start = that.state.rowLimit;
let end = start + 10;
let subsetVariable = com_util.formatString('{0}.iloc[{1}:{2}]', that.state.pandasObject, start, end);
- vpKernel.getRowList(subsetVariable).then(function (resultObj) {
+ vpKernel.getRowList(subsetVariable, start).then(function (resultObj) {
let { result } = resultObj;
var { list:rowList } = JSON.parse(result);
rowList = rowList.map(function (x) {
@@ -361,9 +364,9 @@ define([
rowList = rowList.map(function (x) {
return {
...x,
- label: x.location + '',
- value: x.location + '',
- code: x.location + '',
+ label: x.label + '',
+ value: x.value + '',
+ code: x.code + '',
};
});
}
diff --git a/visualpython/js/m_ml/Classification.js b/visualpython/js/m_ml/Classification.js
index f487be39..f327b611 100644
--- a/visualpython/js/m_ml/Classification.js
+++ b/visualpython/js/m_ml/Classification.js
@@ -50,7 +50,7 @@ define([
this.modelConfig = ML_LIBRARIES;
this.modelTypeList = {
- 'Classfication': ['lg-rgs', 'bern-nb', 'mulnom-nb', 'gaus-nb', 'sv-clf', 'dt-clf', 'rf-clf', 'gbm-clf', 'xgb-clf', 'lgbm-clf', 'cb-clf'],
+ 'Classification': ['lg-rgs', 'bern-nb', 'mulnom-nb', 'gaus-nb', 'sv-clf', 'dt-clf', 'rf-clf', 'gbm-clf', 'xgb-clf', 'lgbm-clf', 'cb-clf'],
}
diff --git a/visualpython/js/m_ml/Clustering.js b/visualpython/js/m_ml/Clustering.js
index c3781201..95ee735c 100644
--- a/visualpython/js/m_ml/Clustering.js
+++ b/visualpython/js/m_ml/Clustering.js
@@ -51,7 +51,7 @@ define([
this.modelTypeList = {
// 'Regression': ['ln-rgs', 'sv-rgs', 'dt-rgs', 'rf-rgs', 'gbm-rgs', 'xgb-rgs', 'lgbm-rgs', 'cb-rgs'],
- // 'Classfication': ['lg-rgs', 'sv-clf', 'dt-clf', 'rf-clf', 'gbm-clf', 'xgb-clf', 'lgbm-clf', 'cb-clf'],
+ // 'Classification': ['lg-rgs', 'sv-clf', 'dt-clf', 'rf-clf', 'gbm-clf', 'xgb-clf', 'lgbm-clf', 'cb-clf'],
// 'Auto ML': ['tpot-rgs', 'tpot-clf'],
'Clustering': ['k-means', 'agg-cls', 'gaus-mix', 'dbscan'],
// 'Dimension Reduction': ['pca', 'lda', 'svd', 'nmf']
diff --git a/visualpython/js/m_ml/FitPredict.js b/visualpython/js/m_ml/FitPredict.js
index cdd979b9..d48c20c5 100644
--- a/visualpython/js/m_ml/FitPredict.js
+++ b/visualpython/js/m_ml/FitPredict.js
@@ -41,6 +41,8 @@ define([
method: '',
action: {},
optionConfig: {},
+ modelEditorType: '',
+ modelEditorName: '',
userOption: '',
...this.state
}
@@ -315,7 +317,7 @@ define([
}
generateCode() {
- let { model } = this.state;
+ let { model, modelType, modelEditorName } = this.state;
let code = new com_String();
let replaceDict = {'${model}': model};
@@ -336,6 +338,31 @@ define([
code.appendLine();
code.append(allocateCode);
}
+ // Data Preparation > Scaling
+ const scalingTypeList = ['StandardScaler', 'RobustScaler', 'MinMaxScaler', 'Normalizer'];
+ // Dimension Reduction
+ const dimensionTypeList = ['PCA', 'NMF'];
+ if (scalingTypeList.includes(modelType) || dimensionTypeList.includes(modelType)) {
+ // fit_transform, transform returns df_trans also
+ switch (modelEditorName) {
+ case 'fit_transform':
+ const allocatedFitTrans = this.state.fit_trans_allocate || 'trans';
+ code.appendLine();
+ code.appendLine();
+ code.appendFormatLine("df_{0} = pd.DataFrame({1}, columns=[{2}])", allocatedFitTrans, allocatedFitTrans, this.state.fit_trans_featureData);
+ code.append("df_" + allocatedFitTrans);
+ break;
+ case 'transform':
+ const allocatedTrans = this.state.trans_allocate || 'trans';
+ code.appendLine();
+ code.appendLine();
+ code.appendFormatLine("df_{0} = pd.DataFrame({1}, columns=[{2}])", allocatedTrans, allocatedTrans, this.state.trans_featureData);
+ code.append("df_" + allocatedTrans);
+ break;
+ default:
+ break;
+ }
+ }
}
return code.toString();
@@ -409,7 +436,7 @@ define([
code: '${model}.fit(${fit_featureData})',
description: 'Fit Encoder/Scaler to X.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' }
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' }
]
},
'fit_transform': {
@@ -418,13 +445,19 @@ define([
code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
description: 'Fit Encoder/Scaler to X, then transform X.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
},
'transform': {
- ...defaultActions['transform'],
- description: 'Transform labels to normalized encoding.'
+ name: 'transform',
+ label: 'Transform',
+ code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
+ description: 'Transform labels to normalized encoding.',
+ options: [
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
+ { name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
+ ]
}
}
if (modelType != 'ColumnTransformer') {
@@ -436,12 +469,49 @@ define([
code: '${inverse_allocate} = ${model}.inverse_transform(${inverse_featureData})',
description: 'Transform binary labels back to multi-class labels.',
options: [
- { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'inverse_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'inv_trans' }
]
}
}
}
+ if (modelType == 'LabelEncoder') {
+ actions = {
+ ...actions,
+ 'fit': {
+ name: 'fit',
+ label: 'Fit',
+ code: '${model}.fit(${fit_featureData})',
+ description: 'Fit Encoder/Scaler to X.',
+ options: [
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X',
+ columnSelection: 'single', returnFrameType: 'Series' }
+ ]
+ },
+ 'fit_transform': {
+ name: 'fit_transform',
+ label: 'Fit and transform',
+ code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
+ description: 'Fit Encoder/Scaler to X, then transform X.',
+ options: [
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X',
+ columnSelection: 'single', returnFrameType: 'Series' },
+ { name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
+ ]
+ },
+ 'transform': {
+ name: 'transform',
+ label: 'Transform',
+ code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
+ description: 'Transform labels to normalized encoding.',
+ options: [
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X',
+ columnSelection: 'single', returnFrameType: 'Series' },
+ { name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
+ ]
+ }
+ }
+ }
if (modelType === 'SMOTE') {
actions = {
'fit': {
@@ -606,7 +676,7 @@ define([
code: '${model}.fit(${fit_featureData})',
description: 'Fit X into an embedded space.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' }
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' }
]
},
'fit_transform': {
@@ -615,7 +685,7 @@ define([
code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
description: 'Fit X into an embedded space and return that transformed output.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
}
@@ -630,7 +700,7 @@ define([
code: '${model}.fit(${fit_featureData}, ${fit_targetData})',
description: 'Fit the Linear Discriminant Analysis model.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_targetData', label: 'Target Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'y' }
]
},
@@ -640,7 +710,7 @@ define([
code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData}${fit_trans_targetData})',
description: 'Fit to data, then transform it.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_targetData', label: 'Target Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'y' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
@@ -651,7 +721,7 @@ define([
code: '${pred_allocate} = ${model}.predict(${pred_featureData})',
description: 'Predict class labels for samples in X.',
options: [
- { name: 'pred_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'pred_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'pred_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'pred' }
]
},
@@ -661,7 +731,7 @@ define([
code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
description: 'Project data to maximize class separation.',
options: [
- { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
}
@@ -675,7 +745,7 @@ define([
code: '${model}.fit(${fit_featureData})',
description: 'Fit X into an embedded space.',
options: [
- { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' }
+ { name: 'fit_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' }
]
},
'fit_transform': {
@@ -684,7 +754,7 @@ define([
code: '${fit_trans_allocate} = ${model}.fit_transform(${fit_trans_featureData})',
description: 'Fit the model with X and apply the dimensionality reduction on X.',
options: [
- { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'fit_trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'fit_trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
},
@@ -694,7 +764,7 @@ define([
code: '${inverse_allocate} = ${model}.inverse_transform(${inverse_featureData})',
description: 'Transform data back to its original space.',
options: [
- { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'inverse_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'inverse_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'inv_trans' }
]
},
@@ -704,7 +774,7 @@ define([
code: '${trans_allocate} = ${model}.transform(${trans_featureData})',
description: 'Apply dimensionality reduction to X.',
options: [
- { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X' },
+ { name: 'trans_featureData', label: 'Feature Data', component: ['data_select'], var_type: ['DataFrame', 'Series', 'ndarray', 'list', 'dict'], value: 'X', returnFrameType: 'DataFrame' },
{ name: 'trans_allocate', label: 'Allocate to', component: ['input'], placeholder: 'New variable', value: 'trans' }
]
}
diff --git a/visualpython/js/m_ml/GridSearch.js b/visualpython/js/m_ml/GridSearch.js
index 32dbc967..1dfdbaa4 100644
--- a/visualpython/js/m_ml/GridSearch.js
+++ b/visualpython/js/m_ml/GridSearch.js
@@ -49,7 +49,7 @@ define([
this.modelTypeList = {
'Regression': ['ln-rgs', 'ridge', 'lasso', 'elasticnet', 'sv-rgs', 'dt-rgs', 'rf-rgs', 'gbm-rgs', 'xgb-rgs', 'lgbm-rgs', 'cb-rgs'],
- 'Classfication': ['lg-rgs', 'bern-nb', 'mulnom-nb', 'gaus-nb', 'sv-clf', 'dt-clf', 'rf-clf', 'gbm-clf', 'xgb-clf', 'lgbm-clf', 'cb-clf']
+ 'Classification': ['lg-rgs', 'bern-nb', 'mulnom-nb', 'gaus-nb', 'sv-clf', 'dt-clf', 'rf-clf', 'gbm-clf', 'xgb-clf', 'lgbm-clf', 'cb-clf']
}
diff --git a/visualpython/js/m_ml/Pipeline.js b/visualpython/js/m_ml/Pipeline.js
index 6dfc1989..856c33db 100644
--- a/visualpython/js/m_ml/Pipeline.js
+++ b/visualpython/js/m_ml/Pipeline.js
@@ -210,6 +210,7 @@ define([
$(that.wrapSelector(`.vp-pp-step-page:not([data-name="${name}"])`)).hide();
$(that.wrapSelector(`.vp-pp-step-page[data-name="${name}"]`)).show();
if (ppObj.useApp === true) {
+ ppObj.app && that.handleAppView(name, ppObj.app);
ppObj.app && ppObj.app.open($(that.wrapSelector(`.vp-pp-step-page[data-name="${name}"]`)));
} else {
that.renderApp(name);
@@ -372,7 +373,7 @@ define([
// click next button
$(this.wrapSelector('.vp-pp-step-next:not(.disabled)')).on('click', function() {
let selectedTag = $(that.wrapSelector('.vp-pp-item.selected'));
- let nextTagList = $(selectedTag).nextAll('.vp-pp-item[data-flag="enabled"]:visible')
+ let nextTagList = $(selectedTag).nextAll('.vp-pp-item[data-flag="enabled"]:visible');
$(nextTagList[0]).trigger('click');
});
}
@@ -562,6 +563,32 @@ define([
case 'ml_dataSplit':
$(mlApp.wrapSelector('#inputData')).parent().hide();
break;
+ case 'ml_evaluation':
+ // for pipeline
+ $(mlApp.wrapSelector('.vp-upper-box')).hide();
+ $(mlApp.wrapSelector('.vp-upper-box.' + mlApp.state.modelType)).show();
+
+ $(mlApp.wrapSelector('.vp-eval-box')).hide();
+ $(mlApp.wrapSelector('.vp-eval-' + mlApp.state.modelType)).show();
+
+ if (mlApp.state.modelType == 'rgs') {
+ // Regression
+
+ } else if (mlApp.state.modelType == 'clf') {
+ // Classification
+ // if (this.state.roc_curve == false && this.state.auc == false) {
+ // $(page).find('.vp-ev-model.roc-auc').prop('disabled', true);
+ // }
+ } else {
+ // Clustering
+ if (mlApp.state.silhouetteScore == false) {
+ $(mlApp.wrapSelector('.vp-ev-model.silhouette')).prop('disabled', true);
+ }
+ if (mlApp.state.ari == false && mlApp.state.nmi == false) {
+ $(mlApp.wrapSelector('.vp-ev-model.ari-nmi')).prop('disabled', true);
+ }
+ }
+ break;
}
}
diff --git a/visualpython/js/m_ml/evaluation.js b/visualpython/js/m_ml/evaluation.js
index 1cf1552d..ed63120c 100644
--- a/visualpython/js/m_ml/evaluation.js
+++ b/visualpython/js/m_ml/evaluation.js
@@ -158,6 +158,9 @@ define([
$(page).find('.vp-upper-box').hide();
$(page).find('.vp-upper-box.' + this.state.modelType).show();
+
+ $(page).find('.vp-eval-box').hide();
+ $(page).find('.vp-eval-' + this.state.modelType).show();
if (this.state.modelType == 'rgs') {
// Regression
@@ -204,7 +207,7 @@ define([
let needMarkdown = false;
//====================================================================
- // Classfication
+ // Classification
//====================================================================
if (modelType == 'clf') {
if (confusion_matrix) {
@@ -351,7 +354,7 @@ define([
...codeCells
];
}
- // return as seperated cells
+ // return as separated cells
return codeCells;
}
diff --git a/visualpython/js/m_stats/Regression.js b/visualpython/js/m_stats/Regression.js
index 89b0738d..a38c811b 100644
--- a/visualpython/js/m_stats/Regression.js
+++ b/visualpython/js/m_stats/Regression.js
@@ -58,6 +58,7 @@ define([
normTest: true,
histogram: true,
scatterplot: true,
+ rmse: false,
...this.state
};
@@ -259,7 +260,7 @@ define([
// Multi-collinearity
multiCollinearity,
// Residual option
- statistics, normTest, histogram, scatterplot
+ statistics, normTest, histogram, scatterplot, rmse,
} = this.state;
let codeList = [];
let code = new com_String();
@@ -697,7 +698,7 @@ define([
}
// Residual option
- if (statistics === true || normTest === true || histogram === true || scatterplot === true) {
+ if (statistics === true || normTest === true || histogram === true || scatterplot === true || rmse === true) {
let residualTitle = 'Residual'
if (lastModelNum > 0) {
residualTitle += ' - Model ' + lastModelNum;
@@ -768,6 +769,14 @@ define([
code.appendLine(" plt.tight_layout()");
code.append(" plt.show()");
}
+ if (rmse === true) {
+ code.appendLine();
+ code.appendLine();
+ code.appendLine("# RMSE (Root Mean Squared Error)");
+ code.appendLine("_rmse = np.sqrt(_result.mse_resid)");
+ code.appendLine("display(Markdown('### RMSE (Root Mean Squared Error)'))");
+ code.append("display(Markdown(f'RMSE: {_rmse}'))");
+ }
}
codeList.push(code.toString());
diff --git a/visualpython/js/menu/MenuFrame.js b/visualpython/js/menu/MenuFrame.js
index 05813295..386916a3 100644
--- a/visualpython/js/menu/MenuFrame.js
+++ b/visualpython/js/menu/MenuFrame.js
@@ -205,19 +205,19 @@ define([
return {};
}
- getMenuLibrary(menuId, libraries=this.menuLibraries) {
+ getMenuLibrary(menuId, libraries=this.menuLibrariesFlatten) {
for (var i=0; i < libraries.length; i++) {
var item = libraries[i];
if (item) {
if (item.id === menuId) {
return item;
}
- if (item.type === 'package') {
- var result = this.getMenuLibrary(menuId, item.item);
- if (result) {
- return result;
- }
- }
+ // if (item.type === 'package') {
+ // var result = this.getMenuLibrary(menuId, item.item);
+ // if (result) {
+ // return result;
+ // }
+ // }
}
}
return null;
@@ -252,7 +252,12 @@ define([
var that = this;
var body = group.getBody();
var item = group.getItem();
+ var state = group.getState();
item && item.forEach(child => {
+ // remember parent to navigate its parent menu
+ var category = state.category?(state.category + ' > ' + state.name):state.name;
+ child['category'] = category;
+
if (child.type == 'package') {
// packages : MenuGroup
var menuGroup = new MenuGroup($(body), child);
@@ -298,7 +303,7 @@ define([
});
let functionList = this.menuLibrariesFlatten.map(menu => {
- return { label: menu.name, value: menu.name, ...menu }
+ return { label: menu.name, value: menu.name, dtype: menu.category, ...menu }
});
// render searchbox
let searchBox = new SuggestInput();
diff --git a/visualpython/python/pandasCommand.py b/visualpython/python/pandasCommand.py
index aee1338d..4f8301c6 100644
--- a/visualpython/python/pandasCommand.py
+++ b/visualpython/python/pandasCommand.py
@@ -11,7 +11,7 @@
# from IPython.core.display is deprecated since IPython 7.14
from IPython.display import display
-def _vp_get_rows_list(df):
+def _vp_get_rows_list(df, start_idx=0):
"""
Get Rows List with Detail Information
"""
@@ -19,7 +19,8 @@ def _vp_get_rows_list(df):
indexType = str(df.index.dtype)
# make dict for rows info
for i, r in enumerate(df.index):
- rInfo = { 'label': r, 'value': r, 'location': i }
+ rInfo = { 'label': r, 'value': r, 'location': start_idx + i }
+
# value
if type(r).__name__ == 'str':
rInfo['value'] = "'{}'".format(r)