From 82cf1e499b23327be4800986dc5488e1729fa3b0 Mon Sep 17 00:00:00 2001
From: minjk-bl
Date: Mon, 7 Feb 2022 13:51:34 +0900
Subject: [PATCH 01/82] MenuItem added - Machine Learning group & item
---
data/libraries.json | 483 ++++++++++++++++++++++++-------------------
js/menu/MenuGroup.js | 10 +-
2 files changed, 281 insertions(+), 212 deletions(-)
diff --git a/data/libraries.json b/data/libraries.json
index eab79fa2..6ffe443d 100644
--- a/data/libraries.json
+++ b/data/libraries.json
@@ -22,213 +22,6 @@
"desc" : "Settings for visual python",
"file" : "file_io/pip"
},
- {
- "id" : "pkg_apps",
- "type" : "package",
- "level": 0,
- "name" : "Apps",
- "path" : "visualpython - apps",
- "desc" : "Application modules",
- "open" : true,
- "item" : [
- {
- "id" : "apps_import",
- "type" : "function",
- "level": 1,
- "name" : "Import",
- "tag" : "IMPORT,APPS",
- "path" : "visualpython - apps - import",
- "desc" : "Import",
- "file" : "m_apps/Import",
- "apps" : {
- "color": 1,
- "icon": "apps/apps_import.svg"
- }
- },
- {
- "id" : "apps_file",
- "type" : "function",
- "level": 1,
- "name" : "File",
- "tag" : "FILE,APPS",
- "path" : "visualpython - apps - file",
- "desc" : "File",
- "file" : "m_apps/File",
- "apps" : {
- "color": 1,
- "icon": "apps/apps_file.svg"
- }
- },
- {
- "id" : "apps_variable",
- "type" : "function",
- "level": 1,
- "name" : "Variable",
- "tag" : "VARIABLE,APPS",
- "path" : "visualpython - apps - variable",
- "desc" : "Variable",
- "file" : "m_apps/Variable",
- "apps" : {
- "color": 1,
- "icon": "apps/apps_variable.svg"
- }
- },
- {
- "id" : "apps_snippets",
- "type" : "function",
- "level": 1,
- "name" : "Snippets",
- "tag" : "SNIPPETS,APPS",
- "path" : "visualpython - apps - snippets",
- "desc" : "Snippets",
- "file" : "m_apps/Snippets",
- "apps" : {
- "color": 1,
- "icon": "apps/apps_snippets.svg"
- }
- },
- {
- "id" : "apps_frame",
- "type" : "function",
- "level": 1,
- "name" : "Frame",
- "tag" : "FRAME,APPS",
- "path" : "visualpython - apps - frame",
- "desc" : "Frame",
- "file" : "m_apps/Frame",
- "apps" : {
- "color": 2,
- "icon": "apps/apps_frame.svg"
- }
- },
- {
- "id" : "apps_subset",
- "type" : "function",
- "level": 1,
- "name" : "Subset",
- "tag" : "SUBSET,APPS",
- "path" : "visualpython - apps - subset",
- "desc" : "Subset",
- "file" : "m_apps/Subset",
- "apps" : {
- "color": 2,
- "icon": "apps/apps_subset.svg"
- }
- },
- {
- "id" : "apps_instance",
- "type" : "function",
- "level": 1,
- "name" : "Instance",
- "tag" : "INSTANCE,APPS",
- "path" : "visualpython - apps - instance",
- "desc" : "Instance",
- "file" : "m_apps/Instance",
- "apps" : {
- "color": 2,
- "icon": "apps/apps_instance.svg"
- }
- },
- {
- "id" : "apps_groupby",
- "type" : "function",
- "level": 1,
- "name" : "Groupby",
- "tag" : "GROUPBY,APPS",
- "path" : "visualpython - apps - groupby",
- "desc" : "Groupby",
- "file" : "m_apps/Groupby",
- "apps" : {
- "color": 2,
- "icon": "apps/apps_groupby.svg"
- }
- },
- {
- "id" : "apps_bind",
- "type" : "function",
- "level": 1,
- "name" : "Bind",
- "tag" : "BIND,APPS",
- "path" : "visualpython - apps - bind",
- "desc" : "Concat & Merge",
- "file" : "m_apps/Bind",
- "apps" : {
- "color": 3,
- "icon": "apps/apps_bind.svg"
- }
- },
- {
- "id" : "apps_reshape",
- "type" : "function",
- "level": 1,
- "name" : "Reshape",
- "tag" : "RESHAPE,APPS",
- "path" : "visualpython - apps - reshape",
- "desc" : "Reshape",
- "file" : "m_apps/Reshape",
- "apps" : {
- "color": 3,
- "icon": "apps/apps_reshape.svg"
- }
- },
- {
- "id" : "apps_chart",
- "type" : "function",
- "level": 1,
- "name" : "Chart",
- "tag" : "CHART,APPS",
- "path" : "visualpython - apps - chart",
- "desc" : "Chart",
- "file" : "m_apps/Chart",
- "apps" : {
- "color": 3,
- "icon": "apps/apps_chart.svg"
- }
- },
- {
- "id" : "apps_markdown",
- "type" : "function",
- "level": 1,
- "name" : "Markdown",
- "tag" : "MARKDOWN,APPS",
- "path" : "visualpython - apps - markdown",
- "desc" : "Markdown",
- "file" : "m_apps/Markdown",
- "apps" : {
- "color": 3,
- "icon": "apps/apps_markdown.svg"
- }
- },
- {
- "id" : "apps_pdf",
- "type" : "function",
- "level": 1,
- "name" : "PDF",
- "tag" : "PDF,PYMUPDF,APPS",
- "path" : "visualpython - apps - pdf",
- "desc" : "PDF",
- "file" : "m_apps/PDF",
- "apps" : {
- "color": 4,
- "icon": "apps/apps_pymupdf.svg"
- }
- },
- {
- "id" : "apps_profiling",
- "type" : "function",
- "level": 1,
- "name" : "Profiling",
- "tag" : "PROFILING,PANDAS PROFILING,APPS",
- "path" : "visualpython - apps - profiling",
- "desc" : "Pandas Profiling",
- "file" : "m_apps/Profiling",
- "apps" : {
- "color": 4,
- "icon": "apps/apps_profiling.svg"
- }
- }
- ]
- },
{
"id" : "pkg_logic",
"type" : "package",
@@ -3089,6 +2882,282 @@
]
}
]
+ },
+ {
+ "id" : "pkg_apps",
+ "type" : "package",
+ "level": 0,
+ "name" : "Application",
+ "path" : "visualpython - apps",
+ "desc" : "Application modules",
+ "open" : true,
+ "grid" : true,
+ "item" : [
+ {
+ "id" : "apps_import",
+ "type" : "function",
+ "level": 1,
+ "name" : "Import",
+ "tag" : "IMPORT,APPS",
+ "path" : "visualpython - apps - import",
+ "desc" : "Import",
+ "file" : "m_apps/Import",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_import.svg"
+ }
+ },
+ {
+ "id" : "apps_file",
+ "type" : "function",
+ "level": 1,
+ "name" : "File",
+ "tag" : "FILE,APPS",
+ "path" : "visualpython - apps - file",
+ "desc" : "File",
+ "file" : "m_apps/File",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_file.svg"
+ }
+ },
+ {
+ "id" : "apps_variable",
+ "type" : "function",
+ "level": 1,
+ "name" : "Variable",
+ "tag" : "VARIABLE,APPS",
+ "path" : "visualpython - apps - variable",
+ "desc" : "Variable",
+ "file" : "m_apps/Variable",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_variable.svg"
+ }
+ },
+ {
+ "id" : "apps_snippets",
+ "type" : "function",
+ "level": 1,
+ "name" : "Snippets",
+ "tag" : "SNIPPETS,APPS",
+ "path" : "visualpython - apps - snippets",
+ "desc" : "Snippets",
+ "file" : "m_apps/Snippets",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_snippets.svg"
+ }
+ },
+ {
+ "id" : "apps_frame",
+ "type" : "function",
+ "level": 1,
+ "name" : "Frame",
+ "tag" : "FRAME,APPS",
+ "path" : "visualpython - apps - frame",
+ "desc" : "Frame",
+ "file" : "m_apps/Frame",
+ "apps" : {
+ "color": 2,
+ "icon": "apps/apps_frame.svg"
+ }
+ },
+ {
+ "id" : "apps_subset",
+ "type" : "function",
+ "level": 1,
+ "name" : "Subset",
+ "tag" : "SUBSET,APPS",
+ "path" : "visualpython - apps - subset",
+ "desc" : "Subset",
+ "file" : "m_apps/Subset",
+ "apps" : {
+ "color": 2,
+ "icon": "apps/apps_subset.svg"
+ }
+ },
+ {
+ "id" : "apps_instance",
+ "type" : "function",
+ "level": 1,
+ "name" : "Instance",
+ "tag" : "INSTANCE,APPS",
+ "path" : "visualpython - apps - instance",
+ "desc" : "Instance",
+ "file" : "m_apps/Instance",
+ "apps" : {
+ "color": 2,
+ "icon": "apps/apps_instance.svg"
+ }
+ },
+ {
+ "id" : "apps_groupby",
+ "type" : "function",
+ "level": 1,
+ "name" : "Groupby",
+ "tag" : "GROUPBY,APPS",
+ "path" : "visualpython - apps - groupby",
+ "desc" : "Groupby",
+ "file" : "m_apps/Groupby",
+ "apps" : {
+ "color": 2,
+ "icon": "apps/apps_groupby.svg"
+ }
+ },
+ {
+ "id" : "apps_bind",
+ "type" : "function",
+ "level": 1,
+ "name" : "Bind",
+ "tag" : "BIND,APPS",
+ "path" : "visualpython - apps - bind",
+ "desc" : "Concat & Merge",
+ "file" : "m_apps/Bind",
+ "apps" : {
+ "color": 3,
+ "icon": "apps/apps_bind.svg"
+ }
+ },
+ {
+ "id" : "apps_reshape",
+ "type" : "function",
+ "level": 1,
+ "name" : "Reshape",
+ "tag" : "RESHAPE,APPS",
+ "path" : "visualpython - apps - reshape",
+ "desc" : "Reshape",
+ "file" : "m_apps/Reshape",
+ "apps" : {
+ "color": 3,
+ "icon": "apps/apps_reshape.svg"
+ }
+ },
+ {
+ "id" : "apps_chart",
+ "type" : "function",
+ "level": 1,
+ "name" : "Chart",
+ "tag" : "CHART,APPS",
+ "path" : "visualpython - apps - chart",
+ "desc" : "Chart",
+ "file" : "m_apps/Chart",
+ "apps" : {
+ "color": 3,
+ "icon": "apps/apps_chart.svg"
+ }
+ },
+ {
+ "id" : "apps_markdown",
+ "type" : "function",
+ "level": 1,
+ "name" : "Markdown",
+ "tag" : "MARKDOWN,APPS",
+ "path" : "visualpython - apps - markdown",
+ "desc" : "Markdown",
+ "file" : "m_apps/Markdown",
+ "apps" : {
+ "color": 3,
+ "icon": "apps/apps_markdown.svg"
+ }
+ },
+ {
+ "id" : "apps_pdf",
+ "type" : "function",
+ "level": 1,
+ "name" : "PDF",
+ "tag" : "PDF,PYMUPDF,APPS",
+ "path" : "visualpython - apps - pdf",
+ "desc" : "PDF",
+ "file" : "m_apps/PDF",
+ "apps" : {
+ "color": 4,
+ "icon": "apps/apps_pymupdf.svg"
+ }
+ },
+ {
+ "id" : "apps_profiling",
+ "type" : "function",
+ "level": 1,
+ "name" : "Profiling",
+ "tag" : "PROFILING,PANDAS PROFILING,APPS",
+ "path" : "visualpython - apps - profiling",
+ "desc" : "Pandas Profiling",
+ "file" : "m_apps/Profiling",
+ "apps" : {
+ "color": 4,
+ "icon": "apps/apps_profiling.svg"
+ }
+ }
+ ]
+ },
+ {
+ "id" : "pkg_ml",
+ "type" : "package",
+ "level": 0,
+ "name" : "Machine Learning",
+ "path" : "visualpython - machine learning",
+ "desc" : "Machine learning modules",
+ "open" : true,
+ "grid" : true,
+ "item" : [
+ {
+ "id" : "ml_split",
+ "type" : "function",
+ "level": 1,
+ "name" : "Data Split",
+ "tag" : "DATA SPLIT,MACHINE LEARNING,ML",
+ "path" : "visualpython - machine learning - data split",
+ "desc" : "Data split for machine learning",
+ "file" : "m_ml/dataSplit",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_white.svg"
+ }
+ },
+ {
+ "id" : "ml_modelSelection",
+ "type" : "function",
+ "level": 1,
+ "name" : "Model Creating & Fitting",
+ "tag" : "MODEL CREATE,FIT,MACHINE LEARNING,ML",
+ "path" : "visualpython - machine learning - model selection",
+ "desc" : "Model creating & fitting for machine learning",
+ "file" : "m_ml/modelSelection",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_white.svg"
+ }
+ },
+ {
+ "id" : "ml_prediction",
+ "type" : "function",
+ "level": 1,
+ "name" : "Prediction",
+ "tag" : "PREDICTION,MACHINE LEARNING,ML",
+ "path" : "visualpython - machine learning - prediction",
+ "desc" : "Prediction for machine learning",
+ "file" : "m_ml/prediction",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_white.svg"
+ }
+ },
+ {
+ "id" : "ml_evaluation",
+ "type" : "function",
+ "level": 1,
+ "name" : "Evaluation",
+ "tag" : "PERFORMANCE EVALUATION,MACHINE LEARNING,ML",
+ "path" : "visualpython - machine learning - evaluation",
+ "desc" : "Performance evaluation for machine learning",
+ "file" : "m_ml/evaluation",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_white.svg"
+ }
+ }
+ ]
}
]
}
diff --git a/js/menu/MenuGroup.js b/js/menu/MenuGroup.js
index cbd8cf5f..e9fee744 100644
--- a/js/menu/MenuGroup.js
+++ b/js/menu/MenuGroup.js
@@ -46,19 +46,19 @@ define([
}
template() {
- var { id, name, desc, level, open } = this.state;
+ var { id, name, desc, level, open, grid } = this.state;
// open menu group on default?
var openItemsAttribute = open && open==true? '': 'style="display:none;"'
- var isApps = (id == 'pkg_apps');
+ var isGrid = (grid == true);
var page = new com_String();
- page.appendFormatLine('', this.uuid, isApps?'apps':'');
+ page.appendFormatLine('
', this.uuid, isGrid?'apps':'');
if (level == 0) {
// render root group
page.appendFormatLine('
{3}
'
, 'vp-menugroup-root vp-no-selection', id, desc, name);
page.appendFormatLine('
', 'vp-menugroup-box', openItemsAttribute);
- if (isApps) {
+ if (isGrid) {
// add grid template if it's apps
page.appendFormatLine('
', 'vp-menugroup-grid');
}
@@ -92,7 +92,7 @@ define([
*/
getBody() {
var queryString = '.' + this.uuid;
- if (this.state.id == 'pkg_apps') {
+ if (this.state.grid == true) {
return this.$target.find(queryString + ' .vp-menugroup-grid');
}
return this.$target.find(queryString + ' .vp-menugroup-box');
From 2c9eea034581f0c96f3a5439ced82b7c2761ebc9 Mon Sep 17 00:00:00 2001
From: minjk-bl
Date: Mon, 7 Feb 2022 13:59:35 +0900
Subject: [PATCH 02/82] Machine Learning applications form added
---
css/boardFrame.css | 7 +++++
data/libraries.json | 10 +++----
js/m_ml/dataSplit.js | 60 +++++++++++++++++++++++++++++++++++++++
js/m_ml/evaluation.js | 60 +++++++++++++++++++++++++++++++++++++++
js/m_ml/modelSelection.js | 60 +++++++++++++++++++++++++++++++++++++++
js/m_ml/prediction.js | 60 +++++++++++++++++++++++++++++++++++++++
6 files changed, 252 insertions(+), 5 deletions(-)
create mode 100644 js/m_ml/dataSplit.js
create mode 100644 js/m_ml/evaluation.js
create mode 100644 js/m_ml/modelSelection.js
create mode 100644 js/m_ml/prediction.js
diff --git a/css/boardFrame.css b/css/boardFrame.css
index a53875fe..0aad342f 100644
--- a/css/boardFrame.css
+++ b/css/boardFrame.css
@@ -234,6 +234,13 @@
.vp-block.apps.vp-focus-child .vp-block-header {
background-color: rgb(253, 177, 133);
}
+.vp-block.machine_learning .vp-block-header {
+ background-color: rgb(249, 227, 214);
+}
+.vp-block.machine_learning.vp-focus .vp-block-header,
+.vp-block.machine_learning.vp-focus-child .vp-block-header {
+ background-color: rgb(253, 177, 133);
+}
.vp-block.logic-define .vp-block-header {
background-color: rgb(213, 231, 222);
}
diff --git a/data/libraries.json b/data/libraries.json
index 6ffe443d..99eb06d5 100644
--- a/data/libraries.json
+++ b/data/libraries.json
@@ -3096,7 +3096,7 @@
"type" : "package",
"level": 0,
"name" : "Machine Learning",
- "path" : "visualpython - machine learning",
+ "path" : "visualpython - machine_learning",
"desc" : "Machine learning modules",
"open" : true,
"grid" : true,
@@ -3107,7 +3107,7 @@
"level": 1,
"name" : "Data Split",
"tag" : "DATA SPLIT,MACHINE LEARNING,ML",
- "path" : "visualpython - machine learning - data split",
+ "path" : "visualpython - machine_learning - data split",
"desc" : "Data split for machine learning",
"file" : "m_ml/dataSplit",
"apps" : {
@@ -3121,7 +3121,7 @@
"level": 1,
"name" : "Model Creating & Fitting",
"tag" : "MODEL CREATE,FIT,MACHINE LEARNING,ML",
- "path" : "visualpython - machine learning - model selection",
+ "path" : "visualpython - machine_learning - model selection",
"desc" : "Model creating & fitting for machine learning",
"file" : "m_ml/modelSelection",
"apps" : {
@@ -3135,7 +3135,7 @@
"level": 1,
"name" : "Prediction",
"tag" : "PREDICTION,MACHINE LEARNING,ML",
- "path" : "visualpython - machine learning - prediction",
+ "path" : "visualpython - machine_learning - prediction",
"desc" : "Prediction for machine learning",
"file" : "m_ml/prediction",
"apps" : {
@@ -3149,7 +3149,7 @@
"level": 1,
"name" : "Evaluation",
"tag" : "PERFORMANCE EVALUATION,MACHINE LEARNING,ML",
- "path" : "visualpython - machine learning - evaluation",
+ "path" : "visualpython - machine_learning - evaluation",
"desc" : "Performance evaluation for machine learning",
"file" : "m_ml/evaluation",
"apps" : {
diff --git a/js/m_ml/dataSplit.js b/js/m_ml/dataSplit.js
new file mode 100644
index 00000000..08de93df
--- /dev/null
+++ b/js/m_ml/dataSplit.js
@@ -0,0 +1,60 @@
+/*
+ * Project Name : Visual Python
+ * Description : GUI-based Python code generator
+ * File Name : dataSplit.js
+ * Author : Black Logic
+ * Note : Data split
+ * License : GNU GPLv3 with Visual Python special exception
+ * Date : 2022. 02. 07
+ * Change Date :
+ */
+
+//============================================================================
+// [CLASS] Data split
+//============================================================================
+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) {
+
+ /**
+ * Data split
+ */
+ class DataSplit extends PopupComponent {
+ _init() {
+ super._init();
+ /** Write codes executed before rendering */
+ }
+
+ _bindEvent() {
+ super._bindEvent();
+ /** Implement binding events */
+ var that = this;
+ this.$target.on('click', function(evt) {
+ var target = evt.target;
+ if ($(that.wrapSelector()).find(target).length > 0) {
+ // Sample : getDataList from Kernel
+ vpKernel.getDataList().then(function(resultObj) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, resultObj);
+ }).catch(function(err) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, err);
+ });
+ }
+ });
+ }
+
+ templateForBody() {
+ /** Implement generating template */
+ return 'This is sample.';
+ }
+
+ generateCode() {
+ return "print('sample code')";
+ }
+
+ }
+
+ return DataSplit;
+});
\ No newline at end of file
diff --git a/js/m_ml/evaluation.js b/js/m_ml/evaluation.js
new file mode 100644
index 00000000..0692bafa
--- /dev/null
+++ b/js/m_ml/evaluation.js
@@ -0,0 +1,60 @@
+/*
+ * Project Name : Visual Python
+ * Description : GUI-based Python code generator
+ * File Name : evaluation.js
+ * Author : Black Logic
+ * Note : Evaluation
+ * License : GNU GPLv3 with Visual Python special exception
+ * Date : 2022. 02. 07
+ * Change Date :
+ */
+
+//============================================================================
+// [CLASS] Evaluation
+//============================================================================
+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) {
+
+ /**
+ * Evaluation
+ */
+ class Evaluation extends PopupComponent {
+ _init() {
+ super._init();
+ /** Write codes executed before rendering */
+ }
+
+ _bindEvent() {
+ super._bindEvent();
+ /** Implement binding events */
+ var that = this;
+ this.$target.on('click', function(evt) {
+ var target = evt.target;
+ if ($(that.wrapSelector()).find(target).length > 0) {
+ // Sample : getDataList from Kernel
+ vpKernel.getDataList().then(function(resultObj) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, resultObj);
+ }).catch(function(err) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, err);
+ });
+ }
+ });
+ }
+
+ templateForBody() {
+ /** Implement generating template */
+ return 'This is sample.';
+ }
+
+ generateCode() {
+ return "print('sample code')";
+ }
+
+ }
+
+ return Evaluation;
+});
\ No newline at end of file
diff --git a/js/m_ml/modelSelection.js b/js/m_ml/modelSelection.js
new file mode 100644
index 00000000..bfbf062e
--- /dev/null
+++ b/js/m_ml/modelSelection.js
@@ -0,0 +1,60 @@
+/*
+ * Project Name : Visual Python
+ * Description : GUI-based Python code generator
+ * File Name : modelSelection.js
+ * Author : Black Logic
+ * Note : Model selection and fitting
+ * License : GNU GPLv3 with Visual Python special exception
+ * Date : 2022. 02. 07
+ * Change Date :
+ */
+
+//============================================================================
+// [CLASS] Model selection
+//============================================================================
+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) {
+
+ /**
+ * Model selection
+ */
+ class ModelSelection extends PopupComponent {
+ _init() {
+ super._init();
+ /** Write codes executed before rendering */
+ }
+
+ _bindEvent() {
+ super._bindEvent();
+ /** Implement binding events */
+ var that = this;
+ this.$target.on('click', function(evt) {
+ var target = evt.target;
+ if ($(that.wrapSelector()).find(target).length > 0) {
+ // Sample : getDataList from Kernel
+ vpKernel.getDataList().then(function(resultObj) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, resultObj);
+ }).catch(function(err) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, err);
+ });
+ }
+ });
+ }
+
+ templateForBody() {
+ /** Implement generating template */
+ return 'This is sample.';
+ }
+
+ generateCode() {
+ return "print('sample code')";
+ }
+
+ }
+
+ return ModelSelection;
+});
\ No newline at end of file
diff --git a/js/m_ml/prediction.js b/js/m_ml/prediction.js
new file mode 100644
index 00000000..46326c16
--- /dev/null
+++ b/js/m_ml/prediction.js
@@ -0,0 +1,60 @@
+/*
+ * Project Name : Visual Python
+ * Description : GUI-based Python code generator
+ * File Name : prediction.js
+ * Author : Black Logic
+ * Note : Prediction
+ * License : GNU GPLv3 with Visual Python special exception
+ * Date : 2022. 02. 07
+ * Change Date :
+ */
+
+//============================================================================
+// [CLASS] Prediction
+//============================================================================
+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) {
+
+ /**
+ * Prediction
+ */
+ class Prediction extends PopupComponent {
+ _init() {
+ super._init();
+ /** Write codes executed before rendering */
+ }
+
+ _bindEvent() {
+ super._bindEvent();
+ /** Implement binding events */
+ var that = this;
+ this.$target.on('click', function(evt) {
+ var target = evt.target;
+ if ($(that.wrapSelector()).find(target).length > 0) {
+ // Sample : getDataList from Kernel
+ vpKernel.getDataList().then(function(resultObj) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, resultObj);
+ }).catch(function(err) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, err);
+ });
+ }
+ });
+ }
+
+ templateForBody() {
+ /** Implement generating template */
+ return 'This is sample.';
+ }
+
+ generateCode() {
+ return "print('sample code')";
+ }
+
+ }
+
+ return Prediction;
+});
\ No newline at end of file
From 9c913137ed15d5c5193a1c3da7679e24f4ed0853 Mon Sep 17 00:00:00 2001
From: minjk-bl
Date: Mon, 7 Feb 2022 15:05:50 +0900
Subject: [PATCH 03/82] prevent menu appearing on empty space of block
---
js/board/Block.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/js/board/Block.js b/js/board/Block.js
index ad06e034..24d4c2d0 100644
--- a/js/board/Block.js
+++ b/js/board/Block.js
@@ -95,7 +95,7 @@ define([
}
});
// right click event - blockMenu
- $(this.wrapSelector()).on('contextmenu', function(evt) {
+ $(this.wrapSelector('.vp-block-header')).on('contextmenu', function(evt) {
that.prop.parent.showMenu(that, evt.pageX, evt.pageY);
evt.preventDefault();
});
From a21e4734941bc9337f6f60e263baa2aa5134e9b9 Mon Sep 17 00:00:00 2001
From: minjk-bl
Date: Thu, 10 Feb 2022 17:57:21 +0900
Subject: [PATCH 04/82] Update Apps > Import
---
css/m_apps/import.css | 10 ++
css/popupComponent.css | 22 ++---
css/root.css | 9 ++
data/libraries.json | 14 +++
js/m_apps/Import.js | 206 +++++++++++++++++++++++++++++++++--------
js/m_ml/addData.js | 60 ++++++++++++
6 files changed, 270 insertions(+), 51 deletions(-)
create mode 100644 css/m_apps/import.css
create mode 100644 js/m_ml/addData.js
diff --git a/css/m_apps/import.css b/css/m_apps/import.css
new file mode 100644
index 00000000..dc38cd49
--- /dev/null
+++ b/css/m_apps/import.css
@@ -0,0 +1,10 @@
+.vp-tab-button {
+ display: inline-block;
+ border: 0.24px solid var(--border-gray-color);
+ padding: 5px;
+ cursor: pointer;
+}
+.vp-tab-button.vp-tab-selected {
+ color: var(--highlight-color);
+ border-bottom: 2px solid var(--highlight-color);
+}
\ No newline at end of file
diff --git a/css/popupComponent.css b/css/popupComponent.css
index e7043155..d4ba85ec 100644
--- a/css/popupComponent.css
+++ b/css/popupComponent.css
@@ -200,7 +200,7 @@
padding: 1px 8px 0 5px;
}
/* checkbox */
-.vp-popup-frame input[type=checkbox] {
+.vp-popup-frame input[type=checkbox]:not(.vp-checkbox) {
position: absolute;
width: 1px;
height: 1px;
@@ -210,19 +210,19 @@
clip: rect(0, 0, 0, 0);
border: 0;
}
-.vp-popup-frame input[type=checkbox] + label,
-.vp-popup-frame label input[type=checkbox] + span {
+.vp-popup-frame input[type=checkbox]:not(.vp-checkbox) + label,
+.vp-popup-frame label input[type=checkbox]:not(.vp-checkbox) + span {
display: inline-block;
position: relative;
padding-left: 18px;
cursor: pointer;
}
-.vp-popup-frame input[type=checkbox]:disabled + label,
-.vp-popup-frame label input[type=checkbox]:disabled + span {
+.vp-popup-frame input[type=checkbox]:not(.vp-checkbox):disabled + label,
+.vp-popup-frame label input[type=checkbox]:not(.vp-checkbox):disabled + span {
color: var(--gray-color);
}
-.vp-popup-frame input[type=checkbox] + label::before,
-.vp-popup-frame label input[type=checkbox] + span::before {
+.vp-popup-frame input[type=checkbox]:not(.vp-checkbox) + label::before,
+.vp-popup-frame label input[type=checkbox]:not(.vp-checkbox) + span::before {
content: '';
position: absolute;
left: 0;
@@ -236,8 +236,8 @@
border: none;
box-sizing: border-box;
}
-.vp-popup-frame input[type=checkbox]:checked + label::before,
-.vp-popup-frame label input[type=checkbox]:checked + span::before {
+.vp-popup-frame input[type=checkbox]:not(.vp-checkbox):checked + label::before,
+.vp-popup-frame label input[type=checkbox]:not(.vp-checkbox):checked + span::before {
content: '';
position: absolute;
left: 0;
@@ -250,8 +250,8 @@
border: none;
box-sizing: border-box;
}
-.vp-popup-frame input[type=checkbox]:disabled + label::before,
-.vp-popup-frame label input[type=checkbox]:disabled + span::before {
+.vp-popup-frame input[type=checkbox]:not(.vp-checkbox):disabled + label::before,
+.vp-popup-frame label input[type=checkbox]:not(.vp-checkbox):disabled + span::before {
content: '';
position: absolute;
left: 0;
diff --git a/css/root.css b/css/root.css
index c05a218e..00f6dc18 100644
--- a/css/root.css
+++ b/css/root.css
@@ -192,6 +192,15 @@ body {
cursor: not-allowed;
}
+.vp-checkbox {
+ display: inline-block;
+ position: relative !important;
+ width: 13px;
+ height: 13px;
+ border: 1px solid #828282;
+ margin: 0px 15px;
+}
+
/* Scrollbar */
.vp-scrollbar {
overflow-y: auto;
diff --git a/data/libraries.json b/data/libraries.json
index 99eb06d5..3e43943f 100644
--- a/data/libraries.json
+++ b/data/libraries.json
@@ -3156,6 +3156,20 @@
"color": 1,
"icon": "apps/apps_white.svg"
}
+ },
+ {
+ "id" : "ml_addData",
+ "type" : "function",
+ "level": 1,
+ "name" : "Add data",
+ "tag" : "ADD PREDICTED DATA,MACHINE LEARNING,ML",
+ "path" : "visualpython - machine_learning - add data",
+ "desc" : "Add predicted data for machine learning",
+ "file" : "m_ml/addData",
+ "apps" : {
+ "color": 1,
+ "icon": "apps/apps_white.svg"
+ }
}
]
}
diff --git a/js/m_apps/Import.js b/js/m_apps/Import.js
index 3d3b63fe..04cda203 100644
--- a/js/m_apps/Import.js
+++ b/js/m_apps/Import.js
@@ -13,11 +13,30 @@
// [CLASS] Import
//============================================================================
define([
+ 'css!vp_base/css/m_apps/import.css',
'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) {
+], function(importCss, com_util, com_Const, com_String, PopupComponent) {
+
+ const importTemplates = {
+ 'pre-processing': [
+ { i0: 'numpy', i1: 'np', type: 'module'},
+ { i0: 'pandas', i1: 'pd', type: 'module'},
+ {
+ i0: 'matplotlib.pyplot', i1: 'plt', type: 'module'
+ , include: [
+ '%matplotlib inline'
+ ]
+ },
+ { i0: 'seaborn', i1: 'sns', type: 'module'}
+ ],
+ 'machine-learning': [
+ { i0: 'sklearn.model_selection', i1: 'train_test_split', type: 'function' },
+ { i0: 'sklearn', i1: 'metrics', type: 'function' }
+ ]
+ }
/**
* Import
@@ -29,78 +48,175 @@ define([
this.config.dataview = false;
this.config.sizeLevel = 1;
- this.packageList = [
- { library: 'numpy', alias:'np'}
- , { library: 'pandas', alias:'pd'}
- , {
- library: 'matplotlib.pyplot', alias:'plt'
- , include: [
- '%matplotlib inline'
- ]
- }
- , { library: 'seaborn', alias:'sns'}
- ];
+ let savedData = vpConfig.getDataSimple('', 'vpimport');
+ // Reset abnormal data
+ if (savedData.tabType == undefined) {
+ savedData = {};
+ vpConfig.setData(null, 'vpimport');
+ }
this.state = {
- importMeta: vpConfig.getDataSimple('', 'vpimport'),
+ tabType: 'pre-processing',
+ importMeta: [],
+ ...savedData,
...this.state
}
if (!this.state.importMeta || this.state.importMeta.length <= 0) {
- this.state.importMeta = this.packageList;
+ this.state.importMeta = JSON.parse(JSON.stringify(importTemplates[this.state.tabType]));
}
}
_bindEvent() {
super._bindEvent();
- /** Implement binding events */
let that = this;
+
+ // select tab
+ $(this.wrapSelector('.vp-tab-button')).on('click', function() {
+ let tabType = $(this).data('tab');
+ // set button selected
+ that.state.tabType = tabType;
+ $(that.wrapSelector('.vp-tab-button')).removeClass('vp-tab-selected');
+ $(this).addClass('vp-tab-selected');
+ // replace libraries
+ that.state.importMeta = importTemplates[tabType];
+ $(that.wrapSelector('#vp_tblImport')).replaceWith(function() {
+ return that.templateTable(that.state.importMeta);
+ });
+ });
+
// delete lib
- $(document).on("click", this.wrapSelector('.vp-remove-option'), function() {
+ $(this.wrapSelector()).on("click", '.vp-remove-option', function() {
$(this).closest('tr').remove();
+
+ that.checkAll();
+ });
+ // check/uncheck all
+ $(this.wrapSelector()).on('change', '#vp_libraryCheckAll', function() {
+ var checked = $(this).prop('checked');
+ $(that.wrapSelector('.vp-item-check')).prop('checked', checked);
+ });
+ // check item
+ $(this.wrapSelector()).on('change', '.vp-item-check', function() {
+ var checked = $(this).prop('checked');
+ // if unchecked at least one item, uncheck check-all
+ if (!checked) {
+ $(that.wrapSelector('.vp-check-all')).prop('checked', false);
+ } else {
+ // if all checked, check check-all
+ that.checkAll();
+ }
});
- // add lib
- $(this.wrapSelector('#vp_addLibrary')).click(function() {
+ // add module
+ $(this.wrapSelector('#vp_addModule')).click(function() {
+ var libsLength = $(that.wrapSelector("#vp_tblImport tbody tr")).length;
+ var tagTr = $(that.templateForModule(libsLength, '', ''));
+
+ $(that.wrapSelector("#vp_tblImport tr:last")).after(tagTr);
+ });
+ // add function
+ $(this.wrapSelector('#vp_addFunction')).click(function() {
var libsLength = $(that.wrapSelector("#vp_tblImport tbody tr")).length;
- var tagTr = $(that.templateForLibrary(libsLength, '', ''));
+ var tagTr = $(that.templateForFunction(libsLength, '', ''));
$(that.wrapSelector("#vp_tblImport tr:last")).after(tagTr);
});
}
+ checkAll() {
+ // check if all checked
+ // if all checked, check check-all
+ var allLength = $(this.wrapSelector('.vp-item-check')).length;
+ var checkedLength = $(this.wrapSelector('.vp-item-check:checked')).length;
+ if (allLength == checkedLength) {
+ $(this.wrapSelector('.vp-check-all')).prop('checked', true);
+ } else {
+ $(this.wrapSelector('.vp-check-all')).prop('checked', false);
+ }
+ }
+
templateForBody() {
/** Implement generating template */
var page = new com_String();
- page.appendFormatLine('', '');
- page.appendLine('');
- page.appendLine('');
+ // tab buttons
+ page.appendLine('');
+ page.appendFormatLine('
{2}
'
+ , this.state.tabType=='pre-processing'?'vp-tab-selected':'', 'pre-processing', 'Pre-processing');
+ page.appendFormatLine('
{2}
'
+ , this.state.tabType=='machine-learning'?'vp-tab-selected':'', 'machine-learning', 'Machine Learning');
+ page.appendLine('
');
+ // import table
+ page.appendLine(this.templateTable(this.state.importMeta));
+ page.appendLine('');
+ page.appendLine('');
+ return page.toString();
+ }
+
+ templateTable(libraries) {
+ var page = new com_String();
+ page.appendLine('');
+ page.appendLine('');
page.appendLine('');
- page.appendLine('Library Name | Alias | | ');
+ page.appendFormat(' | ', 'vp_libraryCheckAll');
+ page.appendLine(' | | | | | ');
page.appendLine('
');
page.appendLine('');
let that = this;
- this.state.importMeta && this.state.importMeta.forEach((lib, idx) => {
- page.appendLine(that.templateForLibrary(idx, lib.library, lib.alias));
+ libraries && libraries.forEach((lib, idx) => {
+ if (lib.type == 'function') {
+ page.appendLine(that.templateForFunction(idx, lib.i0, lib.i1, lib.checked));
+ } else {
+ page.appendLine(that.templateForModule(idx, lib.i0, lib.i1, lib.checked));
+ }
});
page.appendLine('');
page.appendLine('
');
- page.appendLine('');
return page.toString();
}
- templateForLibrary(idx, libraryName, aliasName) {
+ templateForModule(idx, moduleName, aliasName, checked=true) {
var tag = new com_String();
- tag.append('');
+ tag.append('
');
+ // checkbox
+ tag.appendFormat(' | '
+ , 'vp_libraryCheck' + idx, checked?'checked':'');
+ // inputs
+ tag.appendFormat('import | ', 'text-align="center";');
tag.appendFormat(' | '
- , 'vp_library' + idx, 'vp-input m vp-add-library', 'Type library name', libraryName);
+ , 'vp_i0_' + idx, 'vp-input m vp-add-i0', 'Type module', moduleName);
+ tag.appendFormat('as | ', 'text-align="center";');
tag.appendFormat(' | '
- , 'vp_alias' + idx, 'vp-input m vp-add-alias', 'Type alias', aliasName);
+ , 'vp_i1_' + idx, 'vp-input m vp-add-i1', 'Type alias', aliasName);
tag.appendFormat(' | ', 'vp-remove-option w100 vp-cursor', '/nbextensions/visualpython/img/close_small.svg');
tag.append('
');
return tag.toString();
}
+ templateForFunction(idx, moduleName, functionName, checked=true) {
+ var tag = new com_String();
+ tag.append('');
+ // checkbox
+ tag.appendFormat(' | '
+ , 'vp_libraryCheck' + idx, checked?'checked':'');
+ // inputs
+ tag.appendFormat('from | ', 'text-align="center";');
+ tag.appendFormat(' | '
+ , 'vp_i0_' + idx, 'vp-input m vp-add-i0', 'Type module', moduleName);
+ tag.appendFormat('import | ', 'text-align="center";');
+ tag.appendFormat(' | '
+ , 'vp_i1_' + idx, 'vp-input m vp-add-i1', 'Type function', functionName);
+ tag.appendFormat(' | ', 'vp-remove-option w100 vp-cursor', '/nbextensions/visualpython/img/close_small.svg');
+ tag.append('
');
+ return tag.toString();
+ }
+
+ render() {
+ super.render();
+
+ this.checkAll();
+ }
+
generateCode() {
var sbCode = new com_String();
@@ -108,19 +224,29 @@ define([
var importMeta = [];
var libraryList = $(this.wrapSelector("#vp_tblImport tbody tr"));
for (var idx = 0; idx < libraryList.length; idx++) {
- var pacName = $(libraryList[idx]).find('.vp-add-library').val();
- var pacAlias = $(libraryList[idx]).find('.vp-add-alias').val().trim();
+ var pacType = $(libraryList[idx]).data('type');
+ var pacI0 = $(libraryList[idx]).find('.vp-add-i0').val();
+ var pacI1 = $(libraryList[idx]).find('.vp-add-i1').val().trim();
+ var pacChecked = $(libraryList[idx]).find('.vp-item-check').prop('checked');
- if (pacName == "") {
+ if (pacI0 == "") {
continue;
}
- if (sbCode.toString().trim().length > 0) {
- sbCode.appendLine();
+ if (pacChecked) {
+ if (sbCode.toString().trim().length > 0) {
+ sbCode.appendLine();
+ }
+ if (pacType == 'function') {
+ // function
+ sbCode.appendFormat("from {0} import {1}", pacI0, pacI1);
+ } else {
+ // module
+ sbCode.appendFormat("import {0}{1}", pacI0, ((pacI1 === undefined || pacI1 === "") ? "" : (" as " + pacI1)));
+ }
}
- sbCode.appendFormat("import {0}{1}", pacName, ((pacAlias === undefined || pacAlias === "") ? "" : (" as " + pacAlias)));
- this.packageList.forEach(pack => {
- if (pack.library == pacName) {
+ this.state.importMeta && this.state.importMeta.forEach(pack => {
+ if (pack.i0 == pacI0) {
// if include code exists?
if (pack.include != undefined) {
pack.include.forEach(code => {
@@ -131,12 +257,12 @@ define([
}
})
- importMeta.push({ library: pacName, alias: pacAlias });
+ importMeta.push({ i0: pacI0, i1: pacI1, type: pacType, checked: pacChecked });
}
this.state.importMeta = importMeta;
// save import packages
- vpConfig.setData(importMeta, 'vpimport');
+ vpConfig.setData({ tabType: this.state.tabType, importMeta: importMeta }, 'vpimport');
this.generatedCode = sbCode.toString();
return sbCode.toString();
diff --git a/js/m_ml/addData.js b/js/m_ml/addData.js
new file mode 100644
index 00000000..81e8cad5
--- /dev/null
+++ b/js/m_ml/addData.js
@@ -0,0 +1,60 @@
+/*
+ * Project Name : Visual Python
+ * Description : GUI-based Python code generator
+ * File Name : addData.js
+ * Author : Black Logic
+ * Note : Add data
+ * License : GNU GPLv3 with Visual Python special exception
+ * Date : 2022. 02. 07
+ * Change Date :
+ */
+
+//============================================================================
+// [CLASS] Add data
+//============================================================================
+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) {
+
+ /**
+ * Add data
+ */
+ class AddData extends PopupComponent {
+ _init() {
+ super._init();
+ /** Write codes executed before rendering */
+ }
+
+ _bindEvent() {
+ super._bindEvent();
+ /** Implement binding events */
+ var that = this;
+ this.$target.on('click', function(evt) {
+ var target = evt.target;
+ if ($(that.wrapSelector()).find(target).length > 0) {
+ // Sample : getDataList from Kernel
+ vpKernel.getDataList().then(function(resultObj) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, resultObj);
+ }).catch(function(err) {
+ vpLog.display(VP_LOG_TYPE.DEVELOP, err);
+ });
+ }
+ });
+ }
+
+ templateForBody() {
+ /** Implement generating template */
+ return 'This is sample.';
+ }
+
+ generateCode() {
+ return "print('sample code')";
+ }
+
+ }
+
+ return AddData;
+});
\ No newline at end of file
From f8e8d2bbea5ed38c935b0984c68179f03ac48fa7 Mon Sep 17 00:00:00 2001
From: minjk-bl
Date: Thu, 10 Feb 2022 22:18:56 +0900
Subject: [PATCH 05/82] Add ML > DataSplit
---
css/m_ml/dataSplit.css | 7 ++++
css/popupComponent.css | 6 ++--
css/root.css | 30 +++++++++++++++-
html/m_ml/dataSplit.html | 54 ++++++++++++++++++++++++++++
js/m_ml/dataSplit.js | 76 +++++++++++++++++++++++++++++++---------
5 files changed, 154 insertions(+), 19 deletions(-)
create mode 100644 css/m_ml/dataSplit.css
create mode 100644 html/m_ml/dataSplit.html
diff --git a/css/m_ml/dataSplit.css b/css/m_ml/dataSplit.css
new file mode 100644
index 00000000..2548570d
--- /dev/null
+++ b/css/m_ml/dataSplit.css
@@ -0,0 +1,7 @@
+.vp-ds-grid-box {
+ display: grid;
+ width: 100%;
+ height: 100%;
+ grid-row-gap: 5px;
+ grid-template-rows: 60px 140px auto;
+}
\ No newline at end of file
diff --git a/css/popupComponent.css b/css/popupComponent.css
index d4ba85ec..f5caf2ff 100644
--- a/css/popupComponent.css
+++ b/css/popupComponent.css
@@ -265,7 +265,8 @@
box-sizing: border-box;
}
/* popup frame input, select */
-.vp-popup-frame input[type=text] {
+.vp-popup-frame input[type=text],
+.vp-popup-frame input[type=number] {
width: 160px;
font-size: 13px;
line-height: 16px;
@@ -277,7 +278,8 @@
border: 0.25px solid var(--border-gray-color);
box-sizing: border-box;
}
-.vp-popup-frame input[type=text]::placeholder {
+.vp-popup-frame input[type=text]::placeholder,
+.vp-popup-frame input[type=number]::placeholder {
color: var(--gray-color);
}
diff --git a/css/root.css b/css/root.css
index 00f6dc18..b7b444f8 100644
--- a/css/root.css
+++ b/css/root.css
@@ -325,7 +325,35 @@ hr.vp-extra-menu-line {
.mr5 {
margin-right: 5px;
}
-/* table style */
+/* Layout */
+/* Grid style */
+.vp-grid-box {
+ display: grid;
+}
+.vp-grid-border-box {
+ display: grid;
+ align-items: baseline;
+ align-content: center;
+ border: 1px solid var(--border-gray-color);
+ border-radius: 5px;
+ box-sizing: border-box;
+ padding: 15px;
+}
+.vp-grid-col-p50 {
+ display: grid;
+ grid-template-columns: 50% 50%;
+ grid-row-gap: 3px;
+ align-items: baseline;
+ align-content: center;
+}
+.vp-grid-col-95 {
+ display: grid;
+ grid-template-columns: 95px auto;
+ grid-row-gap: 3px;
+ align-items: baseline;
+ align-content: space-evenly;
+}
+/* Table style */
.vp-tbl-gap5 {
border-spacing: 5px;
border-collapse: separate;
diff --git a/html/m_ml/dataSplit.html b/html/m_ml/dataSplit.html
new file mode 100644
index 00000000..b5504a80
--- /dev/null
+++ b/html/m_ml/dataSplit.html
@@ -0,0 +1,54 @@
+
+
+
\ No newline at end of file
diff --git a/js/m_ml/dataSplit.js b/js/m_ml/dataSplit.js
index 08de93df..8f749c6a 100644
--- a/js/m_ml/dataSplit.js
+++ b/js/m_ml/dataSplit.js
@@ -13,11 +13,14 @@
// [CLASS] Data split
//============================================================================
define([
+ 'text!vp_base/html/m_ml/dataSplit.html!strip',
+ 'css!vp_base/css/m_ml/dataSplit.css',
'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'
-], function(com_util, com_Const, com_String, PopupComponent) {
+], function(dsHtml, dsCss, com_util, com_interface, com_Const, com_String, PopupComponent) {
/**
* Data split
@@ -25,33 +28,74 @@ define([
class DataSplit extends PopupComponent {
_init() {
super._init();
- /** Write codes executed before rendering */
+ this.config.sizeLevel = 2;
+ this.config.dataview = false;
+
+ this.state = {
+ testSize: 0.25,
+ trainFeatures: 'X_train',
+ trainTarget: 'y_train',
+ testFeatures: 'X_test',
+ testTarget: 'y_test',
+ ...this.state
+ }
}
_bindEvent() {
super._bindEvent();
- /** Implement binding events */
var that = this;
- this.$target.on('click', function(evt) {
- var target = evt.target;
- if ($(that.wrapSelector()).find(target).length > 0) {
- // Sample : getDataList from Kernel
- vpKernel.getDataList().then(function(resultObj) {
- vpLog.display(VP_LOG_TYPE.DEVELOP, resultObj);
- }).catch(function(err) {
- vpLog.display(VP_LOG_TYPE.DEVELOP, err);
- });
- }
+
+ // import library
+ $(this.wrapSelector('#vp_libaryImport')).on('click', function() {
+ com_interface.insertCell('code', 'from sklearn.model_selection import train_test_split');
});
}
templateForBody() {
- /** Implement generating template */
- return 'This is sample.';
+ let page = $(dsHtml);
+
+ // test size generating
+ let sizeOptions = '';
+ for (let i=5; i<95; i+=5) {
+ sizeOptions += ``;
+ }
+ $(page).find('#testSize').html(sizeOptions);
+ return page;
+ }
+
+ render() {
+ super.render();
+
+
+
}
generateCode() {
- return "print('sample code')";
+ let {
+ trainFeatures, trainTarget, testFeatures, testTarget,
+ dataType, featureData, targetData,
+ testSize, randomState, shuffle, startify
+ } = this.state;
+
+ let options = new com_String();
+ if (testSize != '0.25') {
+ options.appendFormat(', test_size={0}', testSize);
+ }
+ if (randomState && randomState != '') {
+ options.appendFormat(', random_state={0}', randomState);
+ }
+ if (shuffle && shuffle != '') {
+ options.appendFormat(', shuffle={0}', shuffle);
+ }
+ if (startify && startify != '') {
+ options.appendFormat(', startify={0}', startify);
+ }
+
+ let code = new com_String();
+ code.appendFormat('{0}, {1}, {2}, {3} = train_test_split({4}, {5}{6})',
+ trainFeatures, testFeatures, trainTarget, testTarget,
+ featureData, targetData, options.toString());
+ return code.toString();
}
}
From a5d97087e7653cf9a49d1a45888b675272c5b587 Mon Sep 17 00:00:00 2001
From: minjk-bl
Date: Fri, 11 Feb 2022 13:34:10 +0900
Subject: [PATCH 06/82] ML > Model schema
---
css/root.css | 6 +-
html/m_ml/modelSelection.html | 45 +++++++++++++
html/styleGuide.html | 13 ++++
js/com/com_generatorV2.js | 1 +
js/m_ml/modelSelection.js | 116 +++++++++++++++++++++++++++++-----
5 files changed, 164 insertions(+), 17 deletions(-)
create mode 100644 html/m_ml/modelSelection.html
create mode 100644 html/styleGuide.html
diff --git a/css/root.css b/css/root.css
index b7b444f8..60151709 100644
--- a/css/root.css
+++ b/css/root.css
@@ -329,6 +329,7 @@ hr.vp-extra-menu-line {
/* Grid style */
.vp-grid-box {
display: grid;
+ grid-row-gap: 5px;
}
.vp-grid-border-box {
display: grid;
@@ -338,18 +339,19 @@ hr.vp-extra-menu-line {
border-radius: 5px;
box-sizing: border-box;
padding: 15px;
+ grid-row-gap: 5px;
}
.vp-grid-col-p50 {
display: grid;
grid-template-columns: 50% 50%;
- grid-row-gap: 3px;
+ grid-row-gap: 5px;
align-items: baseline;
align-content: center;
}
.vp-grid-col-95 {
display: grid;
grid-template-columns: 95px auto;
- grid-row-gap: 3px;
+ grid-row-gap: 5px;
align-items: baseline;
align-content: space-evenly;
}
diff --git a/html/m_ml/modelSelection.html b/html/m_ml/modelSelection.html
new file mode 100644
index 00000000..206b52e4
--- /dev/null
+++ b/html/m_ml/modelSelection.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+ RandomForestClassifier
+
+
+ TPOTClassifier
+
+
+ SupportVectorClassifier
+
+
+ LinearRegression
+
+
+ LogisticRegression
+
+
+ RandomForestRegression
+
+
+ TPOTRegression
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/html/styleGuide.html b/html/styleGuide.html
new file mode 100644
index 00000000..81c970a3
--- /dev/null
+++ b/html/styleGuide.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Style Guide
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/js/com/com_generatorV2.js b/js/com/com_generatorV2.js
index 3a753fbf..10993063 100644
--- a/js/com/com_generatorV2.js
+++ b/js/com/com_generatorV2.js
@@ -1246,6 +1246,7 @@ define([
return {
vp_showInterfaceOnPage: vp_showInterfaceOnPage,
+ renderContent: renderContent,
vp_codeGenerator: vp_codeGenerator,
vp_generateVarSelect: vp_generateVarSelect,
vp_getTagValue: vp_getTagValue,
diff --git a/js/m_ml/modelSelection.js b/js/m_ml/modelSelection.js
index bfbf062e..a24dc963 100644
--- a/js/m_ml/modelSelection.js
+++ b/js/m_ml/modelSelection.js
@@ -13,11 +13,13 @@
// [CLASS] Model selection
//============================================================================
define([
+ 'text!vp_base/html/m_ml/modelSelection.html!strip',
'vp_base/js/com/com_util',
'vp_base/js/com/com_Const',
'vp_base/js/com/com_String',
+ 'vp_base/js/com/com_generatorV2',
'vp_base/js/com/component/PopupComponent'
-], function(com_util, com_Const, com_String, PopupComponent) {
+], function(msHtml, com_util, com_Const, com_String, com_generator, PopupComponent) {
/**
* Model selection
@@ -25,33 +27,117 @@ define([
class ModelSelection extends PopupComponent {
_init() {
super._init();
- /** Write codes executed before rendering */
+ this.config.sizeLevel = 2;
+ this.config.dataview = false;
+
+ this.state = {
+ model: 'rf-clf',
+ ...this.state
+ }
+
+ this.modelTypes = {
+ 'Classfication': ['rf-clf', 'tpot-clf', 'sv-clf'],
+ 'Regression': ['ln-rgs', 'lg-rgs', 'rf-rgs', 'tpot-rgs'],
+ 'Clustering': [], //TODO:
+ 'PCA': [] //TODO:
+ }
+
+ this.modelConfig = {
+ /** Classification */
+ 'rf-clf': {
+ name: 'RandomForestClassifier',
+ import: 'from sklearn.ensemble import RandomForestClassifier',
+ code: 'RandomForestClassifier(...)',
+ },
+ 'tpot-clf': {
+ name: 'TPOTClassifier',
+ import: 'from tpot import TPOTClassifier',
+ code: 'TPOTClassifier(...)'
+ },
+ 'sv-clf': {
+ name: 'SupportVectorClassifier',
+ import: 'from sklearn.svm import SVC',
+ code: 'SVC(...)',
+ },
+ /** Regression */
+ 'ln-rgs': {
+ name: 'LinearRegression',
+ import: 'from sklearn.linear_model import LinearRegression',
+ code: 'LinearRegression(...)'
+ },
+ 'lg-rgs': {
+ name: 'LogisticRegression',
+ import: 'from sklearn.linear_model import LogisticRegression',
+ code: 'LogisticRegression(...)'
+ },
+ 'rf-rgs': {
+ name: 'RandomForestRegressor',
+ import: 'from sklearn.ensemble import RandomForestRegressor',
+ code: 'RandomForestRegressor(...)',
+ },
+ 'tpot-rgs': {
+ name: 'TPOTRegressor',
+ import: 'from tpot import TPOTRegressor',
+ code: 'TPOTRegressor(...)',
+ }
+ /** Clustering */
+
+ /** PCA */
+
+ }
}
_bindEvent() {
super._bindEvent();
/** Implement binding events */
var that = this;
- this.$target.on('click', function(evt) {
- var target = evt.target;
- if ($(that.wrapSelector()).find(target).length > 0) {
- // Sample : getDataList from Kernel
- vpKernel.getDataList().then(function(resultObj) {
- vpLog.display(VP_LOG_TYPE.DEVELOP, resultObj);
- }).catch(function(err) {
- vpLog.display(VP_LOG_TYPE.DEVELOP, err);
- });
- }
+ // select model
+ $(this.wrapSelector('#model')).on('click', function() {
+ let model = $(this).val();
+ that.state.model = model;
+ $(that.wrapSelector('.vp-model-option-box')).hide();
+ $(that.wrapSelector('.vp-model-' + model)).show();
});
+
}
templateForBody() {
- /** Implement generating template */
- return 'This is sample.';
+ let page = $(msHtml);
+
+ let that = this;
+ // model types
+ let modelTypeTag = new com_String();
+ Object.keys(this.modelTypes).forEach(modelCategory => {
+ let modelOptionTag = new com_String();
+ that.modelTypes[modelCategory].forEach(opt => {
+ let optConfig = that.modelConfig[opt];
+ let selectedFlag = '';
+ if (opt == that.state.model) {
+ selectedFlag = 'selected';
+ }
+ modelOptionTag.appendFormatLine('',
+ opt, selectedFlag, optConfig.name);
+ })
+ modelTypeTag.appendFormatLine('',
+ modelCategory, modelOptionTag.toString());
+ });
+ $(page).find('#model').html(modelTypeTag.toString());
+
+ // option page
+ $(page).find('.vp-model-option-box').hide();
+ $(page).find('.vp-model-' + this.state.model).show();
+ return page;
}
generateCode() {
- return "print('sample code')";
+ /**
+ * from module import model_function
+ * model = Model(key=value, ...)
+ * ---
+ * %%time
+ * model.fit(X_train, y_train)
+ */
+ return this.modelConfig[this.state.model].code;
}
}
From 6cab157a84af2141a1bcd6d45edecf9b91cea4b3 Mon Sep 17 00:00:00 2001
From: minjk-bl
Date: Fri, 11 Feb 2022 14:10:30 +0900
Subject: [PATCH 07/82] ML > Prediction schema
---
html/m_ml/modelSelection.html | 6 ++--
html/m_ml/prediction.html | 18 +++++++++++
js/com/com_Kernel.js | 19 +++++++++++
js/m_apps/Variable.js | 2 ++
js/m_ml/modelSelection.js | 11 ++++++-
js/m_ml/prediction.js | 61 ++++++++++++++++++++++++++---------
6 files changed, 97 insertions(+), 20 deletions(-)
create mode 100644 html/m_ml/prediction.html
diff --git a/html/m_ml/modelSelection.html b/html/m_ml/modelSelection.html
index 206b52e4..69750e76 100644
--- a/html/m_ml/modelSelection.html
+++ b/html/m_ml/modelSelection.html
@@ -33,13 +33,13 @@
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+