From 89e2c355b18a0c4b4b3d7dace5319625bcc87fe3 Mon Sep 17 00:00:00 2001 From: Visual Python <83543209+visualpython@users.noreply.github.com> Date: Wed, 6 Jul 2022 21:26:20 +0900 Subject: [PATCH 1/7] Update README.md --- README.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8f5976fa..8466f66b 100644 --- a/README.md +++ b/README.md @@ -28,31 +28,24 @@ Try Visual Python if you would like to:
### 1. Requirements Visual Python is a Jupyter Notebook extension.
-We recommend installing Anaconda (virtual environment). - - Python version 3.x - Jupyter notebook or Anaconda env ### 2. How to Install -**1) Open Anaconda prompt** - -* Windows : Click Start > Search or Select 'Anaconda Prompt'
-* Mac : Open Launchpad > Select 'Terminal' - -**2) Install package from** +**1) Install package from** ``` pip install visualpython ``` -**3) Enable the package** +**2) Enable the package** ``` visualpy install ``` -**4) Activate Visual Python on Jupyter Notebook** +**3) Activate Visual Python on Jupyter Notebook** -Click orange square button on the right side of the Jupyter Notebook menu. +Click orange square button on the right side of the Jupyter Notebook menu bar. ### 3. Package Control Info * Usage: visualpy **[option]**
From 71ccbe3a5a33b6a1d73cba9605cd7c2b12cc8f5b Mon Sep 17 00:00:00 2001 From: Visual Python <83543209+visualpython@users.noreply.github.com> Date: Wed, 6 Jul 2022 21:40:49 +0900 Subject: [PATCH 2/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8466f66b..54777548 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ Try Visual Python if you would like to:
### 1. Requirements -Visual Python is a Jupyter Notebook extension.
+Visual Python is an extension to Jupyter Notebook, so you must have Jupyter Notebook installed already.
- Python version 3.x -- Jupyter notebook or Anaconda env +- Jupyter notebook environment ### 2. How to Install From f8999ad7992a561e1bd4f5cc08598674a2458970 Mon Sep 17 00:00:00 2001 From: gani0325 Date: Mon, 19 Sep 2022 23:41:27 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=E2=9E=95[Feat]=20Added=20help=20codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 19 +- Untitled.ipynb | 32 ++ css/component/popupComponent.css | 12 +- html/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 201 bytes html/__pycache__/__init__.cpython-39.pyc | Bin 0 -> 199 bytes html/component/popupComponent.html | 10 + html/m_ml/OrderInfo.html | 67 ++++ js/board/HelpView.js | 46 +++ js/com/component/PopupComponent.js | 94 ++++- js/m_apps/SampleApp2.js | 60 +++ js/m_ml/OrderInfo.js | 435 ++++++++++++++++++++++ js/m_ml/Regression.js | 17 + 12 files changed, 780 insertions(+), 12 deletions(-) create mode 100644 Untitled.ipynb create mode 100644 html/__pycache__/__init__.cpython-310.pyc create mode 100644 html/__pycache__/__init__.cpython-39.pyc create mode 100644 html/m_ml/OrderInfo.html create mode 100644 js/board/HelpView.js create mode 100644 js/m_apps/SampleApp2.js create mode 100644 js/m_ml/OrderInfo.js diff --git a/README.md b/README.md index 54777548..8f5976fa 100644 --- a/README.md +++ b/README.md @@ -27,25 +27,32 @@ Try Visual Python if you would like to:
### 1. Requirements -Visual Python is an extension to Jupyter Notebook, so you must have Jupyter Notebook installed already.
+Visual Python is a Jupyter Notebook extension.
+We recommend installing Anaconda (virtual environment). + - Python version 3.x -- Jupyter notebook environment +- Jupyter notebook or Anaconda env ### 2. How to Install -**1) Install package from** +**1) Open Anaconda prompt** + +* Windows : Click Start > Search or Select 'Anaconda Prompt'
+* Mac : Open Launchpad > Select 'Terminal' + +**2) Install package from** ``` pip install visualpython ``` -**2) Enable the package** +**3) Enable the package** ``` visualpy install ``` -**3) Activate Visual Python on Jupyter Notebook** +**4) Activate Visual Python on Jupyter Notebook** -Click orange square button on the right side of the Jupyter Notebook menu bar. +Click orange square button on the right side of the Jupyter Notebook menu. ### 3. Package Control Info * Usage: visualpy **[option]**
diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 00000000..ac84707e --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "0da90d57", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "vp": { + "vp_config_version": "1.0.0", + "vp_menu_width": 273, + "vp_note_display": false, + "vp_note_width": 0, + "vp_position": { + "width": 278 + }, + "vp_section_display": true, + "vp_signature": "VisualPython" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/css/component/popupComponent.css b/css/component/popupComponent.css index 962f0b82..981195cd 100644 --- a/css/component/popupComponent.css +++ b/css/component/popupComponent.css @@ -129,8 +129,11 @@ height: 50px; border-top: 0.25px solid var(--border-gray-color); } + +/* 220919 */ .vp-popup-codeview-box, -.vp-popup-dataview-box { +.vp-popup-dataview-box, +.vp-popup-helpview-box { display: none; width: 100%; height: 100px; @@ -155,6 +158,13 @@ margin-top: 9px; margin-left: 10px; } + +/* 220919 */ +.vp-popup-button[data-type="help"] { + float: left; + margin-top: 9px; + margin-left: 10px; +} .vp-popup-button[data-type="cancel"] { float: right; background-color: #E4E4E4; diff --git a/html/__pycache__/__init__.cpython-310.pyc b/html/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a77c4f8f7f83ce337517c20983ade5c1fe58966c GIT binary patch literal 201 zcmd1j<>g`kf}WsXN#a2IF^GcGEnfZCeF=b$bff7J-V=_u|b7JD-GxIV_;^XxSDsOSv Tg`kf}WsXN#a2IF^GcGEnfZCeF=b$bff7J-V=_u|b7JD-GxIV_;^XxSDsOSv S + + + +
+ +
+ + + +
diff --git a/html/m_ml/OrderInfo.html b/html/m_ml/OrderInfo.html new file mode 100644 index 00000000..7e5dd013 --- /dev/null +++ b/html/m_ml/OrderInfo.html @@ -0,0 +1,67 @@ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ + + + + +
+
+ + + + + + + + + + +
+
+ +
+ + +
+
+ + +
+ + +
+
+
+
+ \ No newline at end of file diff --git a/js/board/HelpView.js b/js/board/HelpView.js new file mode 100644 index 00000000..7eddca6b --- /dev/null +++ b/js/board/HelpView.js @@ -0,0 +1,46 @@ +/* + * Project Name : Visual Python + * Description : GUI-based Python code generator + * File Name : HelpView.js + * Author : Black Logic + * Note : Render Help view + * License : GNU GPLv3 with Visual Python special exception + * Date : 2021. 09. 13 + * Change Date : + */ + +//============================================================================ +// [CLASS] HelpView +//============================================================================ +define([ + '../com/component/PopupComponent' +], function(PopupComponent) { + 'use strict'; + + /** + * @class HelpView + * @constructor + */ + class HelpView extends PopupComponent { + _init() { + super._init(); + + this.config.footer = false; + this.config.sizeLevel = 1; + + this.state = { + helpview: '', + ...this.state + } + + this._addCodemirror('helpview', this.wrapSelector('#helpview'), "readonly"); + } + + templateForBody() { + return ``; + } + } + + return HelpView; + +}); \ No newline at end of file diff --git a/js/com/component/PopupComponent.js b/js/com/component/PopupComponent.js index 012baf34..7f75a59a 100644 --- a/js/com/component/PopupComponent.js +++ b/js/com/component/PopupComponent.js @@ -8,7 +8,7 @@ * Date : 2021. 11. 18 * Change Date : */ - + //============================================================================ // [CLASS] PopupComponent //============================================================================ @@ -22,6 +22,8 @@ define([ './Component', './DataSelector', + + /** codemirror */ 'codemirror/lib/codemirror', 'codemirror/mode/python/python', @@ -146,7 +148,26 @@ define([ } } - // code view + // // code view + // if (this.config.codeview) { + // if (!this.cmCodeview) { + // // codemirror setting + // let selector = this.wrapSelector('.vp-popup-codeview-box textarea'); + // let textarea = $(selector); + // if (textarea && textarea.length > 0) { + // this.cmCodeview = codemirror.fromTextArea(textarea[0], this.cmReadonlyConfig); + // } else { + // vpLog.display(VP_LOG_TYPE.ERROR, 'No text area to create codemirror. (selector: '+selector+')'); + // } + // } else { + // this.cmCodeview.refresh(); + // } + + + + // 220919 + // 220912 + // code view + helpview if (this.config.codeview) { if (!this.cmCodeview) { // codemirror setting @@ -160,7 +181,23 @@ define([ } else { this.cmCodeview.refresh(); } - } + } else { + if (!this.cmCodeview) { + // codemirror setting + let selector = this.wrapSelector('.vp-popup-helpview-box textarea'); + let textarea = $(selector); + if (textarea && textarea.length > 0) { + this.cmCodeview = codemirror.fromTextArea(textarea[0], this.cmReadonlyConfig); + } else { + vpLog.display(VP_LOG_TYPE.ERROR, 'No text area to create codemirror. (selector: '+selector+')'); + } + } else { + this.cmCodeview.refresh(); + } + + + + } } /** @@ -346,6 +383,26 @@ define([ $(this.wrapSelector('.vp-popup-button')).on('click', function(evt) { var btnType = $(this).data('type'); switch(btnType) { + + // 220919 + case 'help' : + + // $(".vp-popup-help").attr("title", "바뀐 후"); + + // if ($(that.wrapSelector('.vp-popup-run-detailbox')).is(':hidden')) { + // $(".vp-popup-help").attr("title", "바뀐 후"); + + // } else { + // $(".vp-popup-help").attr("title", "바뀐 후"); + // } + if ($(that.wrapSelector('.vp-popup-helpview-box')).is(':hidden')) { + that.openView('help'); + } else { + that.closeView('help'); + } + evt.stopPropagation(); + break; + case 'code': if ($(that.wrapSelector('.vp-popup-codeview-box')).is(':hidden')) { that.openView('code'); @@ -498,7 +555,7 @@ define([ let { installButton, importButton, packageButton, - codeview, dataview, runButton, footer, + codeview, dataview, helpview, runButton, footer, sizeLevel, position } = this.config; @@ -530,6 +587,11 @@ define([ if (!dataview) { $(this.wrapSelector('.vp-popup-button[data-type="data"]')).hide(); } + // 220919 + if (!helpview) { + $(this.wrapSelector('.vp-popup-button[data-type="help"]')).hide(); + } + // run button if (!runButton) { @@ -627,6 +689,11 @@ define([ /** Implementation needed */ return ''; } + + generateHelp() { + /** Implementation needed */ + return ''; + } load() { @@ -900,7 +967,24 @@ define([ that.cmCodeview.refresh(); }, 1); $(this.wrapSelector('.vp-popup-dataview-box')).hide(); - } else { + } else if (viewType == 'help') { // 220919 + this.saveState(); + var code = this.generateHelp(); + let codeText = ''; + if (Array.isArray(code)) { + codeText = code.join('\n'); + } else { + codeText = code; + } + this.cmCodeview.setValue(codeText); + this.cmCodeview.save(); + + var that = this; + setTimeout(function() { + that.cmCodeview.refresh(); + }, 1); + $(this.wrapSelector('.vp-popup-helpview-box')).hide(); + } else { this.renderDataView(); $(this.wrapSelector('.vp-popup-codeview-box')).hide(); } diff --git a/js/m_apps/SampleApp2.js b/js/m_apps/SampleApp2.js new file mode 100644 index 00000000..8d1bfb38 --- /dev/null +++ b/js/m_apps/SampleApp2.js @@ -0,0 +1,60 @@ +/* + * Project Name : Visual Python + * Description : GUI-based Python code generator + * File Name : SampleApp.js + * Author : Black Logic + * Note : [앱 설명] + * License : GNU GPLv3 with Visual Python special exception + * Date : YYYY. MM. dd + * Change Date : + */ + +//============================================================================ +// [CLASS] SampleApp +//============================================================================ +define([ + 'vp_base/js/com/com_util', + 'vp_base/js/com/com_Const', + 'vp_base/js/com/com_String', + 'vp_base/js/com/component/PopupComponent' +], function(com_util, com_Const, com_String, PopupComponent) { + + /** + * SampleApp + */ + class SampleApp extends PopupComponent { + _init() { + super._init(); + /** Write codes executed before rendering */ + } + + _bindEvent() { + super._bindEvent(); + /** Implement binding events */ + var that = this; + + // $(this.wrapSelector('#sample')).on('click', function() { + // ; + // }); + } + + templateForBody() { + /** Implement generating template */ + return `This is sample. + `; + } + + render() { + super.render(); + + /** Write codes executed after rendering */ + } + + generateCode() { + return "print('sample code')"; + } + + } + + return SampleApp; +}); \ No newline at end of file diff --git a/js/m_ml/OrderInfo.js b/js/m_ml/OrderInfo.js new file mode 100644 index 00000000..e69e9635 --- /dev/null +++ b/js/m_ml/OrderInfo.js @@ -0,0 +1,435 @@ +/* + * Project Name : Visual Python + * Description : GUI-based Python code generator + * File Name : SampleApp2.js + * Author : Black Logic + * Note : [앱 설명] + * License : GNU GPLv3 with Visual Python special exception + * Date : YYYY. MM. dd + * Change Date : + */ + +//============================================================================ +// [CLASS] SampleApp 2 +//============================================================================ +// define([ +// 'vp_base/js/com/com_util', +// 'vp_base/js/com/com_Const', +// 'vp_base/js/com/com_String', +// 'vp_base/js/com/component/PopupComponent' +// ], function(com_util, com_Const, com_String, PopupComponent) { + +// /** +// * SampleApp2 +// */ +// class SampleApp2 extends PopupComponent { +// _init() { +// super._init(); +// /** Write codes executed before rendering */ +// } + +// _bindEvent() { +// super._bindEvent(); +// /** Implement binding events */ +// var that = this; + +// // $(this.wrapSelector('#sample')).on('click', function() { +// // ; +// // }); +// } + +// templateForBody() { +// /** Implement generating template */ +// return `This is sample. +// `; +// } + +// render() { +// super.render(); + +// /** Write codes executed after rendering */ +// } + +// generateCode() { +// return "print('sample code')"; +// } + +// } + +// return SampleApp2; +// }); + + + +/* + * Project Name : Visual Python + * Description : GUI-based Python code generator + * File Name : evaluation.js + * Author : Black Logic + * Note : OrderInfo + * License : GNU GPLv3 with Visual Python special exception + * Date : 2022. 02. 07 + * Change Date : + */ + +//============================================================================ +// [CLASS] OrderInfo +//============================================================================ +define([ + 'text!vp_base/html/m_ml/OrderInfo.html!strip', + 'vp_base/js/com/com_util', + 'vp_base/js/com/com_interface', + 'vp_base/js/com/com_Const', + 'vp_base/js/com/com_String', + 'vp_base/js/com/component/PopupComponent', + 'vp_base/js/com/component/DataSelector' +], function(evalHTML, com_util, com_interface, com_Const, com_String, PopupComponent, DataSelector) { + + /** + * OrderInfo + */ + class OrderInfo extends PopupComponent { + _init() { + super._init(); + this.config.importButton = true; + this.config.dataview = false; + this.config.checkModules = ['metrics']; + + this.state = { + modelType: 'rgs', + predictData: 'pred', + targetData: 'y_test', + // regression + r_squared: true, mae: true, mape: false, rmse: true, scatter_plot: false, + // classification + confusion_matrix: true, report: true, + accuracy: false, precision: false, recall: false, f1_score: false, + // clustering + clusteredIndex: 'clusters', + silhouetteScore: true, ari: false, nmi: false, + featureData2: 'X', + targetData2: 'y', + ...this.state + } + } + + _bindEvent() { + super._bindEvent(); + /** Implement binding events */ + var that = this; + + // import library + $(this.wrapSelector('#vp_importLibrary')).on('click', function() { + com_interface.insertCell('code', 'from sklearn import metrics', true, 'Machine Learning > Evaluation'); + }); + + // model type change + $(this.wrapSelector('#modelType')).on('change', function() { + let modelType = $(this).val(); + that.state.modelType = modelType; + + $(that.wrapSelector('.vp-upper-box')).hide(); + $(that.wrapSelector('.vp-upper-box.' + modelType)).show(); + + $(that.wrapSelector('.vp-eval-box')).hide(); + $(that.wrapSelector('.vp-eval-'+modelType)).show(); + + if (modelType == 'rgs') { + // Regression + + } else if (modelType == 'clf') { + // Classification - model selection + // if (that.checkToShowSelector('roc-auc') == true) { + // $(that.wrapSelector('.vp-ev-model.roc-auc')).prop('disabled', false); + // } else { + // $(that.wrapSelector('.vp-ev-model.roc-auc')).prop('disabled', true); + // } + } else { + // Clustering + if (that.checkToShowSelector('silhouette') == true) { + $(that.wrapSelector('.vp-ev-model.silhouette')).prop('disabled', false); + } else { + $(that.wrapSelector('.vp-ev-model.silhouette')).prop('disabled', true); + } + if (that.checkToShowSelector('ari-nmi') == true) { + $(that.wrapSelector('.vp-ev-model.ari-nmi')).prop('disabled', false); + } else { + $(that.wrapSelector('.vp-ev-model.ari-nmi')).prop('disabled', true); + } + } + }); + + // check to enable/disable selector + $(this.wrapSelector('.vp-eval-check')).on('change', function() { + let checked = $(this).prop('checked'); + let type = $(this).data('type'); + + if (checked) { + $(that.wrapSelector('.vp-ev-model.' + type)).prop('disabled', false); + } else { + if (that.checkToShowSelector(type) == false) { + $(that.wrapSelector('.vp-ev-model.' + type)).prop('disabled', true); + } + } + }); + } + + /** + * Check if anything checked available ( > 0) + * @returns + */ + checkToShowSelector(type) { + let checked = $(this.wrapSelector('.vp-eval-check[data-type="' + type + '"]:checked')).length; + if (checked > 0) { + return true; + } + return false; + } + + templateForBody() { + let page = $(evalHTML); + + $(page).find('.vp-eval-box').hide(); + $(page).find('.vp-eval-'+this.state.modelType).show(); + + // data selector + let predDataSelector = new DataSelector({ + pageThis: this, id: 'predictData', value: this.state.predictData, required: true + }); + $(page).find('#predictData').replaceWith(predDataSelector.toTagString()); + + let targetDataSelector = new DataSelector({ + pageThis: this, id: 'targetData', value: this.state.targetData, required: true + }); + $(page).find('#targetData').replaceWith(targetDataSelector.toTagString()); + + // Clustering - data selection + let clusteredIdxSelector = new DataSelector({ + pageThis: this, id: 'clusteredIndex', value: this.state.clusteredIndex, required: true + }); + $(page).find('#clusteredIndex').replaceWith(clusteredIdxSelector.toTagString()); + + let featureData2Selector = new DataSelector({ + pageThis: this, id: 'featureData2', value: this.state.featureData2, classes: 'vp-ev-model silhouette', required: true + }); + $(page).find('#featureData2').replaceWith(featureData2Selector.toTagString()); + + let targetData2Selector = new DataSelector({ + pageThis: this, id: 'targetData2', value: this.state.targetData2, classes: 'vp-ev-model ari-nmi', required: true + }); + $(page).find('#targetData2').replaceWith(targetData2Selector.toTagString()); + + // load state + let that = this; + Object.keys(this.state).forEach(key => { + let tag = $(page).find('#' + key); + let tagName = $(tag).prop('tagName'); // returns with UpperCase + let value = that.state[key]; + if (value == undefined) { + return; + } + switch(tagName) { + case 'INPUT': + let inputType = $(tag).prop('type'); + if (inputType == 'text' || inputType == 'number' || inputType == 'hidden') { + $(tag).val(value); + break; + } + if (inputType == 'checkbox') { + $(tag).prop('checked', value); + break; + } + break; + case 'TEXTAREA': + case 'SELECT': + default: + $(tag).val(value); + break; + } + }); + + $(page).find('.vp-upper-box').hide(); + $(page).find('.vp-upper-box.' + this.state.modelType).show(); + + if (this.state.modelType == 'rgs') { + // Regression + + } else if (this.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 (this.state.silhouetteScore == false) { + $(page).find('.vp-ev-model.silhouette').prop('disabled', true); + } + if (this.state.ari == false && this.state.nmi == false) { + $(page).find('.vp-ev-model.ari-nmi').prop('disabled', true); + } + } + + return page; + } + + generateImportCode() { + return ['from sklearn import metrics']; + } + + generateCode() { + let codeCells = [ + ...this.generateImportCode() // run import codes + ]; + let code = new com_String(); + let { + modelType, predictData, targetData, + // classification + confusion_matrix, report, accuracy, precision, recall, f1_score, + // regression + coefficient, intercept, r_squared, mae, mape, rmse, scatter_plot, + // clustering + sizeOfClusters, silhouetteScore, ari, nmi, + clusteredIndex, featureData2, targetData2 + } = this.state; + + //==================================================================== + // Classfication + //==================================================================== + if (modelType == 'clf') { + if (confusion_matrix) { + code = new com_String(); + code.appendLine("# Confusion Matrix"); + code.appendFormat('pd.crosstab({0}, {1}, margins=True)', targetData, predictData); + codeCells.push(code.toString()); + } + if (report) { + code = new com_String(); + code.appendLine("# Classification report"); + code.appendFormat('print(metrics.classification_report({0}, {1}))', targetData, predictData); + codeCells.push(code.toString()); + } + if (accuracy) { + code = new com_String(); + code.appendLine("# Accuracy"); + code.appendFormat('metrics.accuracy_score({0}, {1})', targetData, predictData); + codeCells.push(code.toString()); + } + if (precision) { + code = new com_String(); + code.appendLine("# Precision"); + code.appendFormat("metrics.precision_score({0}, {1}, average='weighted')", targetData, predictData); + codeCells.push(code.toString()); + } + if (recall) { + code = new com_String(); + code.appendLine("# Recall"); + code.appendFormat("metrics.recall_score({0}, {1}, average='weighted')", targetData, predictData); + codeCells.push(code.toString()); + } + if (f1_score) { + code = new com_String(); + code.appendLine("# F1-score"); + code.appendFormat("metrics.f1_score({0}, {1}, average='weighted')", targetData, predictData); + codeCells.push(code.toString()); + } + // if (roc_curve) { + // code = new com_String(); + // code.appendLine("# ROC Curve"); + // code.appendFormatLine("fpr, tpr, thresholds = metrics.roc_curve({0}, {1}.decision_function({2}))", predictData, model, targetData); + // code.appendLine("plt.plot(fpr, tpr, label='ROC Curve')"); + // code.appendLine("plt.xlabel('Sensitivity') "); + // code.append("plt.ylabel('Specificity') ") + // codeCells.push(code.toString()); + // } + // if (auc) { + // code = new com_String(); + // code.appendLine("# AUC"); + // code.appendFormat("metrics.roc_auc_score({0}, {1}.decision_function({2}))", predictData, model, targetData); + // codeCells.push(code.toString()); + // } + } + + //==================================================================== + // Regression + //==================================================================== + if (modelType == 'rgs') { + // if (coefficient) { + // code.appendLine("# Coefficient (scikit-learn only)"); + // code.appendFormatLine('model.coef_'); + // } + // if (intercept) { + // code.appendLine("# Intercept (scikit-learn only)"); + // code.appendFormatLine('model.intercept_'); + // } + if (r_squared) { + code = new com_String(); + code.appendLine("# R square"); + code.appendFormat('metrics.r2_score({0}, {1})', targetData, predictData); + codeCells.push(code.toString()); + } + if (mae) { + code = new com_String(); + code.appendLine("# MAE(Mean Absolute Error)"); + code.appendFormat('metrics.mean_absolute_error({0}, {1})', targetData, predictData); + codeCells.push(code.toString()); + } + if (mape) { + code = new com_String(); + code.appendLine("# MAPE(Mean Absolute Percentage Error)"); + code.appendLine('def MAPE(y_test, y_pred):'); + code.appendLine(' return np.mean(np.abs((y_test - pred) / y_test)) * 100'); + code.appendLine(); + code.appendFormat('MAPE({0}, {1})', targetData, predictData); + codeCells.push(code.toString()); + } + if (rmse) { + code = new com_String(); + code.appendLine("# RMSE(Root Mean Squared Error)"); + code.appendFormat('metrics.mean_squared_error({0}, {1})**0.5', targetData, predictData); + codeCells.push(code.toString()); + } + if (scatter_plot) { + code = new com_String(); + code.appendLine('# Regression plot'); + code.appendFormatLine('plt.scatter({0}, {1})', targetData, predictData); + code.appendFormatLine("plt.xlabel('{0}')", targetData); + code.appendFormatLine("plt.ylabel('{0}')", predictData); + code.append('plt.show()'); + codeCells.push(code.toString()); + } + } + //==================================================================== + // Clustering + //==================================================================== + if (modelType == 'cls') { + // if (sizeOfClusters) { + // code.appendLine("# Size of clusters"); + // code.appendFormatLine("print(f'Size of clusters: {np.bincount({0})}')", predictData); + // } + if (silhouetteScore) { + code = new com_String(); + code.appendLine("# Silhouette score"); + code.appendFormat("print(f'Silhouette score: {metrics.cluster.silhouette_score({0}, {1})}')", featureData2, clusteredIndex); + codeCells.push(code.toString()); + } + if (ari) { + code = new com_String(); + code.appendLine("# ARI(Adjusted Rand score)"); + code.appendFormat("print(f'ARI: {metrics.cluster.adjusted_rand_score({0}, {1})}')", targetData2, clusteredIndex); + codeCells.push(code.toString()); + } + if (nmi) { + code = new com_String(); + code.appendLine("# NMI(Normalized Mutual Info Score)"); + code.appendFormat("print(f'NM: {metrics.cluster.normalized_mutual_info_score({0}, {1})}')", targetData2, clusteredIndex); + codeCells.push(code.toString()); + } + } + // return as seperated cells + return codeCells; + } + + } + + return OrderInfo; +}); \ No newline at end of file diff --git a/js/m_ml/Regression.js b/js/m_ml/Regression.js index 68cec34b..4c64ab34 100644 --- a/js/m_ml/Regression.js +++ b/js/m_ml/Regression.js @@ -44,6 +44,8 @@ define([ // model selection model: '', method: '', + + help : "도움말 테스트", ...this.state } @@ -323,6 +325,21 @@ define([ return code.toString(); } + // 220906 + generateHelp() { + let { help } = this.state; + + let test = new com_String(); + + test.appendLine(help); + test.appendLine(); + test.appendLine("도움말 추가 완료(?)"); + + return test.toString(); + } + + + } return Regression; From f0c5cb1afdd6066fc5655f3f9077e1dcb2425828 Mon Sep 17 00:00:00 2001 From: gani0325 Date: Tue, 20 Sep 2022 00:03:43 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=E2=9E=95[Feat]=20Added=20help=20codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/FUNDING.yml | 1 + .github/ISSUE_TEMPLATE/content-contribution.md | 16 ++++++++++++++++ .github/ISSUE_TEMPLATE/design-fix.md | 18 ++++++++++++++++++ .ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 ++++++ 4 files changed, 41 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/content-contribution.md create mode 100644 .github/ISSUE_TEMPLATE/design-fix.md create mode 100644 .ipynb_checkpoints/Untitled-checkpoint.ipynb diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..1b6525f0 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: visualpython diff --git a/.github/ISSUE_TEMPLATE/content-contribution.md b/.github/ISSUE_TEMPLATE/content-contribution.md new file mode 100644 index 00000000..e8f3a92e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/content-contribution.md @@ -0,0 +1,16 @@ +--- +name: Content contribution +about: Share contents to encourage using visualpython (e.g. gitbook, Youtube, blog, + ...) +title: '' +labels: documentation +assignees: '' + +--- + +**Share created contents** +Write and share your contents to encourage using visualpython. +Use external links to share your contents. + +**Need help** +If you need help for creating contents, you can request other contributors to join. diff --git a/.github/ISSUE_TEMPLATE/design-fix.md b/.github/ISSUE_TEMPLATE/design-fix.md new file mode 100644 index 00000000..a3eb3813 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/design-fix.md @@ -0,0 +1,18 @@ +--- +name: Design fix +about: Suggest an idea for design and ui +title: '' +labels: design fix +assignees: '' + +--- + +**Is your suggestion related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the design/style you'd like** +A clear and concise description of what you want to happen. +Design images needed to clearly understand + +**Additional context** +Add any other context or screenshots about the design suggestion here. diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 00000000..363fcab7 --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} From ec271adf81221ab6f2e24f5c91505df0427cbf9b Mon Sep 17 00:00:00 2001 From: gani0325 Date: Tue, 20 Sep 2022 00:05:56 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=E2=9E=95[Feat]=20Alter=20help=20codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/libraries.json | 14 ++++++++++++++ html/component/popupComponent.html | 5 +++-- js/com/component/PopupComponent.js | 4 ++++ js/m_apps/SampleApp2.js | 10 +++++----- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/data/libraries.json b/data/libraries.json index 5cd63821..17275438 100644 --- a/data/libraries.json +++ b/data/libraries.json @@ -3063,6 +3063,20 @@ "color": 4, "icon": "apps/apps_profiling.svg" } + }, + { + "id" : "apps_sample", + "type" : "function", + "level": 1, + "name" : "Sample App", + "tag" : "SAMPLE,OSSCA,APPS", + "path" : "visualpython - apps - sample", + "desc" : "Sample app for OSSCA", + "file" : "m_apps/SampleApp2.js", + "apps" : { + "color": 4, + "icon": "apps/apps_white.svg" + } } ] }, diff --git a/html/component/popupComponent.html b/html/component/popupComponent.html index 23fa65be..b7784927 100644 --- a/html/component/popupComponent.html +++ b/html/component/popupComponent.html @@ -83,14 +83,15 @@ -
+
+ +
- diff --git a/js/com/component/PopupComponent.js b/js/com/component/PopupComponent.js index 7f75a59a..8e5b6ba7 100644 --- a/js/com/component/PopupComponent.js +++ b/js/com/component/PopupComponent.js @@ -63,6 +63,10 @@ define([ // show view box codeview: true, dataview: true, + + // 220919 + helpview: true, + // show footer runButton: true, footer: true, diff --git a/js/m_apps/SampleApp2.js b/js/m_apps/SampleApp2.js index 8d1bfb38..526d3683 100644 --- a/js/m_apps/SampleApp2.js +++ b/js/m_apps/SampleApp2.js @@ -1,7 +1,7 @@ /* * Project Name : Visual Python * Description : GUI-based Python code generator - * File Name : SampleApp.js + * File Name : SampleApp2.js * Author : Black Logic * Note : [앱 설명] * License : GNU GPLv3 with Visual Python special exception @@ -10,7 +10,7 @@ */ //============================================================================ -// [CLASS] SampleApp +// [CLASS] SampleApp 2 //============================================================================ define([ 'vp_base/js/com/com_util', @@ -20,9 +20,9 @@ define([ ], function(com_util, com_Const, com_String, PopupComponent) { /** - * SampleApp + * SampleApp2 */ - class SampleApp extends PopupComponent { + class SampleApp2 extends PopupComponent { _init() { super._init(); /** Write codes executed before rendering */ @@ -56,5 +56,5 @@ define([ } - return SampleApp; + return SampleApp2; }); \ No newline at end of file From 207c863f0af1bce8ef79149b3673aff70ee09dca Mon Sep 17 00:00:00 2001 From: gani0325 Date: Sun, 25 Sep 2022 00:22:14 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=E2=9E=95[Feat]=20Help=20botton=20completes?= =?UTF-8?q?!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/help_data.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 data/help_data.json diff --git a/data/help_data.json b/data/help_data.json new file mode 100644 index 00000000..caf27239 --- /dev/null +++ b/data/help_data.json @@ -0,0 +1,7 @@ +{ + "Import" : "this is import help", + "File" : "this is file help", + "Bind" : "this is bind help", + "try" : "this is try help", + "Subset" : "this is subset help" +} \ No newline at end of file From c23a56dd80c111d22f9472e38471c98162edc396 Mon Sep 17 00:00:00 2001 From: gani0325 Date: Sun, 25 Sep 2022 00:43:55 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=E2=9E=95[Feat]=20Help=20button=20complete?= =?UTF-8?q?=20!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/component/popupComponent.html | 4 +- js/com/component/PopupComponent.js | 73 ++++++++++++++----- popupComponent.html | 112 +++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 18 deletions(-) create mode 100644 popupComponent.html diff --git a/html/component/popupComponent.html b/html/component/popupComponent.html index b7784927..04c73e43 100644 --- a/html/component/popupComponent.html +++ b/html/component/popupComponent.html @@ -6,7 +6,7 @@ Note : popup component License : GNU GPLv3 with Visual Python special exception Date : 2021. 12. 01 - Change Date : + Change Date : 2021. 09. 25 --> @@ -84,7 +84,7 @@
- +
diff --git a/js/com/component/PopupComponent.js b/js/com/component/PopupComponent.js index 8e5b6ba7..bd8c4081 100644 --- a/js/com/component/PopupComponent.js +++ b/js/com/component/PopupComponent.js @@ -6,7 +6,7 @@ * Note : Popup Components for rendering objects * License : GNU GPLv3 with Visual Python special exception * Date : 2021. 11. 18 - * Change Date : + * Change Date : 2022. 09. 24 */ //============================================================================ @@ -21,7 +21,9 @@ define([ '../com_interface', './Component', './DataSelector', - + + // helpview boolean 판단 + 'json!vp_base/data/help_data.json', /** codemirror */ @@ -31,7 +33,7 @@ define([ 'codemirror/addon/display/placeholder', 'codemirror/addon/display/autorefresh' ], function(popupComponentHtml, popupComponentCss - , com_util, com_Const, com_String, com_interface, Component, DataSelector, codemirror + , com_util, com_Const, com_String, com_interface, Component, DataSelector, helpData, codemirror ) { 'use strict'; @@ -52,7 +54,7 @@ define([ this.name = this.state.config.name; this.path = this.state.config.path; - + this.config = { sizeLevel: 0, // 0: 400x400 / 1: 500x500 / 2: 600x500 / 3: 750x500 executeMode: 'code', // cell execute mode @@ -65,7 +67,7 @@ define([ dataview: true, // 220919 - helpview: true, + helpview: helpData[this.name], // show footer runButton: true, @@ -95,6 +97,24 @@ define([ theme: "ipython", extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"} } + + // makrdown codemirror 위한 config 추가 + this.cmMarkdownConfig = { + mode: { + name: 'markdown', + version: 3, + singleLineStringErrors: false + }, + height: '100%', + width: '100%', + indentUnit: 4, + lineNumbers: true, + matchBrackets: true, + autoRefresh: true, + theme: "markdown", + extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"} + } + this.cmReadonlyConfig = { ...this.cmPythonConfig, readOnly: true, @@ -102,7 +122,15 @@ define([ scrollbarStyle: "null" } + this.cmReadonlyHelpConfig = { + ...this.cmMarkdownConfig, + readOnly: true, + lineNumbers: false, + scrollbarStyle: "null" + } + this.cmCodeview = null; + this.helpViewText = null; this.cmCodeList = []; } @@ -185,18 +213,20 @@ define([ } else { this.cmCodeview.refresh(); } - } else { - if (!this.cmCodeview) { + } + + if(this.config.helpview) { + if (!this.helpViewText) { // codemirror setting let selector = this.wrapSelector('.vp-popup-helpview-box textarea'); let textarea = $(selector); if (textarea && textarea.length > 0) { - this.cmCodeview = codemirror.fromTextArea(textarea[0], this.cmReadonlyConfig); + this.helpViewText = codemirror.fromTextArea(textarea[0], this.cmReadonlyHelpConfig); } else { vpLog.display(VP_LOG_TYPE.ERROR, 'No text area to create codemirror. (selector: '+selector+')'); } } else { - this.cmCodeview.refresh(); + this.helpViewText.refresh(); } @@ -695,9 +725,12 @@ define([ } generateHelp() { - /** Implementation needed */ - return ''; - } + var helpTextObj = new com_String(); + var helpComment = helpData[this.name]; + helpTextObj.append(helpComment); + + return helpTextObj.toString(); + } load() { @@ -971,6 +1004,8 @@ define([ that.cmCodeview.refresh(); }, 1); $(this.wrapSelector('.vp-popup-dataview-box')).hide(); + $(this.wrapSelector('.vp-popup-helpview-box')).hide(); + } else if (viewType == 'help') { // 220919 this.saveState(); var code = this.generateHelp(); @@ -980,17 +1015,23 @@ define([ } else { codeText = code; } - this.cmCodeview.setValue(codeText); - this.cmCodeview.save(); + + this.helpViewText.setValue(codeText); + this.helpViewText.save(); var that = this; setTimeout(function() { - that.cmCodeview.refresh(); + that.helpViewText.refresh(); }, 1); - $(this.wrapSelector('.vp-popup-helpview-box')).hide(); + + // button 클릭 시, 하나의 팝업만 나타나도록 + $(this.wrapSelector('.vp-popup-dataview-box')).hide(); + $(this.wrapSelector('.vp-popup-codeview-box')).hide(); + } else { this.renderDataView(); $(this.wrapSelector('.vp-popup-codeview-box')).hide(); + $(this.wrapSelector('.vp-popup-helpview-box')).hide(); } $(this.wrapSelector('.vp-popup-'+viewType+'view-box')).show(); diff --git a/popupComponent.html b/popupComponent.html new file mode 100644 index 00000000..feabff98 --- /dev/null +++ b/popupComponent.html @@ -0,0 +1,112 @@ + + + +
+ + +
+ + + + + +
+
+
+ + Install Package + + + + Import Library + + + + Package Manager + + +
+ +
+ +
+
+ +
+ \ No newline at end of file