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 +} 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/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 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/__pycache__/__init__.cpython-310.pyc b/html/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 00000000..a77c4f8f Binary files /dev/null and b/html/__pycache__/__init__.cpython-310.pyc differ diff --git a/html/__pycache__/__init__.cpython-39.pyc b/html/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 00000000..d4a34dd5 Binary files /dev/null and b/html/__pycache__/__init__.cpython-39.pyc differ diff --git a/html/component/popupComponent.html b/html/component/popupComponent.html index a29fe11e..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 --> @@ -80,10 +80,21 @@
+ + + +
+ +
+ +
+ + +
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..bd8c4081 100644 --- a/js/com/component/PopupComponent.js +++ b/js/com/component/PopupComponent.js @@ -6,9 +6,9 @@ * 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 */ - + //============================================================================ // [CLASS] PopupComponent //============================================================================ @@ -21,7 +21,11 @@ define([ '../com_interface', './Component', './DataSelector', + + // helpview boolean 판단 + 'json!vp_base/data/help_data.json', + /** codemirror */ 'codemirror/lib/codemirror', 'codemirror/mode/python/python', @@ -29,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'; @@ -50,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 @@ -61,6 +65,10 @@ define([ // show view box codeview: true, dataview: true, + + // 220919 + helpview: helpData[this.name], + // show footer runButton: true, footer: true, @@ -89,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, @@ -96,7 +122,15 @@ define([ scrollbarStyle: "null" } + this.cmReadonlyHelpConfig = { + ...this.cmMarkdownConfig, + readOnly: true, + lineNumbers: false, + scrollbarStyle: "null" + } + this.cmCodeview = null; + this.helpViewText = null; this.cmCodeList = []; } @@ -146,7 +180,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 @@ -161,6 +214,24 @@ define([ this.cmCodeview.refresh(); } } + + 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.helpViewText = codemirror.fromTextArea(textarea[0], this.cmReadonlyHelpConfig); + } else { + vpLog.display(VP_LOG_TYPE.ERROR, 'No text area to create codemirror. (selector: '+selector+')'); + } + } else { + this.helpViewText.refresh(); + } + + + + } } /** @@ -346,6 +417,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 +589,7 @@ define([ let { installButton, importButton, packageButton, - codeview, dataview, runButton, footer, + codeview, dataview, helpview, runButton, footer, sizeLevel, position } = this.config; @@ -530,6 +621,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 +723,14 @@ define([ /** Implementation needed */ return ''; } + + generateHelp() { + var helpTextObj = new com_String(); + var helpComment = helpData[this.name]; + helpTextObj.append(helpComment); + + return helpTextObj.toString(); + } load() { @@ -900,9 +1004,34 @@ define([ that.cmCodeview.refresh(); }, 1); $(this.wrapSelector('.vp-popup-dataview-box')).hide(); - } else { + $(this.wrapSelector('.vp-popup-helpview-box')).hide(); + + } 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.helpViewText.setValue(codeText); + this.helpViewText.save(); + + var that = this; + setTimeout(function() { + that.helpViewText.refresh(); + }, 1); + + // 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/js/m_apps/SampleApp2.js b/js/m_apps/SampleApp2.js new file mode 100644 index 00000000..526d3683 --- /dev/null +++ b/js/m_apps/SampleApp2.js @@ -0,0 +1,60 @@ +/* + * 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; +}); \ 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; 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