Skip to content

Commit

Permalink
Replace os_open with kh.visualize_report
Browse files Browse the repository at this point in the history
  • Loading branch information
folmos-at-orange committed Dec 9, 2024
1 parent 3cc5bad commit 74dbb3d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 79 deletions.
16 changes: 3 additions & 13 deletions Core Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()"
]
Expand Down Expand Up @@ -134,7 +124,7 @@
"outputs": [],
"source": [
"# To visualize uncomment the line below\n",
"# os_open(iris_report)"
"# kh.visualize_report(iris_report)"
]
},
{
Expand Down Expand Up @@ -240,7 +230,7 @@
"outputs": [],
"source": [
"# To visualize uncomment the line below\n",
"# os_open(adult_report)"
"# kh.visualize_report(adult_report)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()"
]
Expand Down Expand Up @@ -195,7 +185,7 @@
"outputs": [],
"source": [
"# To visualize uncomment the line below\n",
"# os_open(sarcasm_report)"
"# kh.visualize_report(sarcasm_report)"
]
},
{
Expand Down Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
]
Expand Down Expand Up @@ -184,7 +174,7 @@
"outputs": [],
"source": [
"# To visualize uncomment the line below\n",
"# os_open(accidents_report)"
"# kh.visualize_report(accidents_report)"
]
}
],
Expand Down
14 changes: 2 additions & 12 deletions Core Basics 4 - Train a Coclustering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
]
Expand Down Expand Up @@ -115,7 +105,7 @@
"outputs": [],
"source": [
"# To visualize uncomment the line below\n",
"# os_open(countries_cc_report)"
"# kh.visualize_report(countries_cc_report)"
]
},
{
Expand Down Expand Up @@ -230,7 +220,7 @@
"outputs": [],
"source": [
"# To visualize uncomment the line below\n",
"# os_open(tokyo_cc_report)"
"# kh.visualize_report(tokyo_cc_report)"
]
},
{
Expand Down
36 changes: 36 additions & 0 deletions Sklearn Basics 1 - Train, Evaluate and Deploy a Classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down Expand Up @@ -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"
]
},
{
Expand All @@ -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": {
Expand Down
16 changes: 3 additions & 13 deletions Sklearn Basics 4 - Train a Coclustering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
]
Expand Down Expand Up @@ -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\")"
]
},
{
Expand Down

0 comments on commit 74dbb3d

Please sign in to comment.