From 74dbb3df5ecde080c3784a3da35206e55a9912cc Mon Sep 17 00:00:00 2001 From: Felipe Olmos <92923444+folmos-at-orange@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:25:27 +0100 Subject: [PATCH] Replace os_open with kh.visualize_report --- ...in, Evaluate and Deploy a Classifier.ipynb | 16 ++------- ...sifier on a Star Multi-Table Dataset.ipynb | 30 ++-------------- ...r on a Snowflake Multi-Table Dataset.ipynb | 12 +------ Core Basics 4 - Train a Coclustering.ipynb | 14 ++------ ...in, Evaluate and Deploy a Classifier.ipynb | 36 +++++++++++++++++++ ...sifier on a Star Multi-Table Dataset.ipynb | 34 ++++++++++++++++-- Sklearn Basics 4 - Train a Coclustering.ipynb | 16 ++------- 7 files changed, 79 insertions(+), 79 deletions(-) diff --git a/Core Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb b/Core Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb index 8d73c85..4adebd2 100644 --- a/Core Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb +++ b/Core Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb @@ -23,7 +23,7 @@ "import subprocess\n", "from khiops import core as kh\n", "\n", - "# Define helper functions\n", + "# Define peek helper function\n", "def peek(file_path, n=10):\n", " \"\"\"Shows the first n lines of a file\"\"\"\n", " with open(file_path, encoding=\"utf8\", errors=\"replace\") as file:\n", @@ -32,16 +32,6 @@ " print(\"\")\n", "\n", "\n", - "def os_open(path):\n", - " \"\"\"Opens a file or directory with its default application\"\"\"\n", - " if platform.system() == \"Windows\":\n", - " os.startfile(path)\n", - " elif platform.system() == \"Darwin\":\n", - " subprocess.call([\"open\", path])\n", - " else:\n", - " subprocess.call([\"xdg-open\", path])\n", - "\n", - "\n", "# If there are any issues you may Khiops status with the following command\n", "# kh.get_runner().print_status()" ] @@ -134,7 +124,7 @@ "outputs": [], "source": [ "# To visualize uncomment the line below\n", - "# os_open(iris_report)" + "# kh.visualize_report(iris_report)" ] }, { @@ -240,7 +230,7 @@ "outputs": [], "source": [ "# To visualize uncomment the line below\n", - "# os_open(adult_report)" + "# kh.visualize_report(adult_report)" ] }, { diff --git a/Core Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb b/Core Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb index 05343ac..430c05e 100644 --- a/Core Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb +++ b/Core Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb @@ -24,7 +24,7 @@ "import subprocess\n", "from khiops import core as kh\n", "\n", - "# Define helper functions\n", + "# Define peek helper function\n", "def peek(file_path, n=10):\n", " \"\"\"Shows the first n lines of a file\"\"\"\n", " with open(file_path, encoding=\"utf8\", errors=\"replace\") as file:\n", @@ -33,16 +33,6 @@ " print(\"\")\n", "\n", "\n", - "def os_open(path):\n", - " \"\"\"Opens a file or directory with its default application\"\"\"\n", - " if platform.system() == \"Windows\":\n", - " os.startfile(path)\n", - " elif platform.system() == \"Darwin\":\n", - " subprocess.call([\"open\", path])\n", - " else:\n", - " subprocess.call([\"xdg-open\", path])\n", - "\n", - "\n", "# If there are any issues you may Khiops status with the following command\n", "# kh.get_runner().print_status()" ] @@ -195,7 +185,7 @@ "outputs": [], "source": [ "# To visualize uncomment the line below\n", - "# os_open(sarcasm_report)" + "# kh.visualize_report(sarcasm_report)" ] }, { @@ -350,22 +340,8 @@ "outputs": [], "source": [ "# To visualize uncomment the line below\n", - "# os_open(accidents_report)" + "# kh.visualize_report(accidents_report)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/Core Basics 3 - Train a Classifier on a Snowflake Multi-Table Dataset.ipynb b/Core Basics 3 - Train a Classifier on a Snowflake Multi-Table Dataset.ipynb index 7066da6..accf3d2 100644 --- a/Core Basics 3 - Train a Classifier on a Snowflake Multi-Table Dataset.ipynb +++ b/Core Basics 3 - Train a Classifier on a Snowflake Multi-Table Dataset.ipynb @@ -33,16 +33,6 @@ " print(\"\")\n", "\n", "\n", - "def os_open(path):\n", - " \"\"\"Opens a file or directory with its default application\"\"\"\n", - " if platform.system() == \"Windows\":\n", - " os.startfile(path)\n", - " elif platform.system() == \"Darwin\":\n", - " subprocess.call([\"open\", path])\n", - " else:\n", - " subprocess.call([\"xdg-open\", path])\n", - "\n", - "\n", "# If there are any issues you may Khiops status with the following command\n", "# kh.get_runner().print_status()" ] @@ -184,7 +174,7 @@ "outputs": [], "source": [ "# To visualize uncomment the line below\n", - "# os_open(accidents_report)" + "# kh.visualize_report(accidents_report)" ] } ], diff --git a/Core Basics 4 - Train a Coclustering.ipynb b/Core Basics 4 - Train a Coclustering.ipynb index 7c18627..90ea629 100644 --- a/Core Basics 4 - Train a Coclustering.ipynb +++ b/Core Basics 4 - Train a Coclustering.ipynb @@ -33,16 +33,6 @@ " print(\"\")\n", "\n", "\n", - "def os_open(path):\n", - " \"\"\"Opens a file or directory with its default application\"\"\"\n", - " if platform.system() == \"Windows\":\n", - " os.startfile(path)\n", - " elif platform.system() == \"Darwin\":\n", - " subprocess.call([\"open\", path])\n", - " else:\n", - " subprocess.call([\"xdg-open\", path])\n", - "\n", - "\n", "# If there are any issues you may Khiops status with the following command\n", "# kh.get_runner().print_status()" ] @@ -115,7 +105,7 @@ "outputs": [], "source": [ "# To visualize uncomment the line below\n", - "# os_open(countries_cc_report)" + "# kh.visualize_report(countries_cc_report)" ] }, { @@ -230,7 +220,7 @@ "outputs": [], "source": [ "# To visualize uncomment the line below\n", - "# os_open(tokyo_cc_report)" + "# kh.visualize_report(tokyo_cc_report)" ] }, { diff --git a/Sklearn Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb b/Sklearn Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb index 61f107c..5b5b0a5 100644 --- a/Sklearn Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb +++ b/Sklearn Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb @@ -279,6 +279,24 @@ "iris_confusion_matrix" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To further explore the results we can see the report with the Khiops Visualization app:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# To visualize uncomment the lines below\n", + "# khc_iris.export_report_file(\"./iris_report.khj\")\n", + "# kh.visualize_report(\"./iris_report.khj\")" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -418,6 +436,24 @@ "print(\"Adult model predictions for each class (first 10 rows):\")\n", "display(adult_probas[:10])" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Open the training report with the Khiops Visualization app" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# To visualize uncomment the lines below\n", + "# khc_adult.export_report_file(\"./adult_report.khj\")\n", + "# kh.visualize_report(\"./adult_report.khj\")" + ] } ], "metadata": { diff --git a/Sklearn Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb b/Sklearn Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb index 6bbfb4c..f6ca53d 100644 --- a/Sklearn Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb +++ b/Sklearn Basics 2 - Train a Classifier on a Star Multi-Table Dataset.ipynb @@ -257,6 +257,24 @@ "print(f\"Sarcasm test auc : {sarcasm_test_auc}\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To further explore the results we can see the report with the Khiops Visualization app:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# To visualize uncomment the lines below\n", + "khc_sarcasm.export_report_file(\"./sarcasm_report.khj\")\n", + "kh.visualize_report(\"./sarcasm_report.khj\")" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -449,8 +467,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### Obtain the accuracy and AUC on the test dataset\n", - "\n" + "#### Obtain the accuracy and AUC on the test dataset" ] }, { @@ -472,12 +489,23 @@ "print(f\"Accidents test auc : {accidents_test_auc}\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Explore the report with the Khiops Visualization App" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# To visualize uncomment the lines below\n", + "# khc_accidents.export_report_file(\"./accidents_report.khj\")\n", + "# kh.visualize_report(\"./accidents_report.khj\")" + ] } ], "metadata": { diff --git a/Sklearn Basics 4 - Train a Coclustering.ipynb b/Sklearn Basics 4 - Train a Coclustering.ipynb index f0f3ba2..e7f94e9 100644 --- a/Sklearn Basics 4 - Train a Coclustering.ipynb +++ b/Sklearn Basics 4 - Train a Coclustering.ipynb @@ -23,17 +23,6 @@ "from khiops import core as kh\n", "from khiops.sklearn import KhiopsCoclustering\n", "\n", - "\n", - "def os_open(path):\n", - " \"\"\"Opens a file or directory with its default application\"\"\"\n", - " if platform.system() == \"Windows\":\n", - " os.startfile(path)\n", - " elif platform.system() == \"Darwin\":\n", - " subprocess.call([\"open\", path])\n", - " else:\n", - " subprocess.call([\"xdg-open\", path])\n", - "\n", - "\n", "# If there are any issues you may Khiops status with the following command\n", "# kh.get_runner().print_status()" ] @@ -273,8 +262,9 @@ "tokyo_report = os.path.join(\"exercises\", \"tokyo.khcj\")\n", "khcc_tokyo.export_report_file(tokyo_report)\n", "\n", - "# To visualize uncomment the line below\n", - "# os_open(tokyo_report)" + "# To visualize uncomment the lines below\n", + "# khcc_tokyo.export_report_file(\"./tokyo_report.khcj\")\n", + "# kh.export_report_file(\"./tokyo_report.khcj\")" ] }, {