From ea2a64003f2a2d6836c0aec825157b48d41e178c Mon Sep 17 00:00:00 2001 From: Felipe Olmos <92923444+folmos-at-orange@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:28:47 +0100 Subject: [PATCH 1/3] Move modules in khiops.utils to khiops.sklearn --- doc/internal/index.rst | 2 +- doc/samples/samples_sklearn.rst | 6 ++---- doc/tools/index.rst | 1 - khiops/samples/samples_sklearn.ipynb | 6 ++---- khiops/samples/samples_sklearn.py | 6 ++---- khiops/sklearn/__init__.py | 1 + khiops/{utils => sklearn}/dataset.py | 0 khiops/sklearn/estimators.py | 2 +- khiops/{utils => sklearn}/helpers.py | 2 +- khiops/utils/__init__.py | 0 tests/test_dataset_class.py | 2 +- tests/test_dataset_errors.py | 2 +- tests/test_helper_functions.py | 2 +- 13 files changed, 13 insertions(+), 19 deletions(-) rename khiops/{utils => sklearn}/dataset.py (100%) rename khiops/{utils => sklearn}/helpers.py (98%) delete mode 100644 khiops/utils/__init__.py diff --git a/doc/internal/index.rst b/doc/internal/index.rst index db8301e0..1531433b 100644 --- a/doc/internal/index.rst +++ b/doc/internal/index.rst @@ -3,7 +3,7 @@ Internals These are internal modules with no "data science" functionality. Their documentation is available for completeness. -.. currentmodule:: khiops.utils +.. currentmodule:: khiops.sklearn .. autosummary:: :nosignatures: :toctree: generated diff --git a/doc/samples/samples_sklearn.rst b/doc/samples/samples_sklearn.rst index f5ce17b8..9693ba27 100644 --- a/doc/samples/samples_sklearn.rst +++ b/doc/samples/samples_sklearn.rst @@ -155,8 +155,7 @@ Samples import os import pandas as pd from khiops import core as kh - from khiops.sklearn import KhiopsClassifier - from khiops.utils.helpers import train_test_split_dataset + from khiops.sklearn import KhiopsClassifier, train_test_split_dataset from sklearn import metrics # Load the dataset into pandas dataframes @@ -211,8 +210,7 @@ Samples import os import pandas as pd from khiops import core as kh - from khiops.sklearn import KhiopsClassifier - from khiops.utils.helpers import train_test_split_dataset + from khiops.sklearn import KhiopsClassifier, train_test_split_dataset from sklearn import metrics # Load the dataset tables into dataframes diff --git a/doc/tools/index.rst b/doc/tools/index.rst index 162cc3be..f6c1a7cf 100644 --- a/doc/tools/index.rst +++ b/doc/tools/index.rst @@ -7,5 +7,4 @@ These are auxiliary tools for the Khiops Python library. :toctree: generated :nosignatures: - utils.helpers tools diff --git a/khiops/samples/samples_sklearn.ipynb b/khiops/samples/samples_sklearn.ipynb index c79fe141..66bab90b 100644 --- a/khiops/samples/samples_sklearn.ipynb +++ b/khiops/samples/samples_sklearn.ipynb @@ -167,8 +167,7 @@ "import os\n", "import pandas as pd\n", "from khiops import core as kh\n", - "from khiops.sklearn import KhiopsClassifier\n", - "from khiops.utils.helpers import train_test_split_dataset\n", + "from khiops.sklearn import KhiopsClassifier, train_test_split_dataset\n", "from sklearn import metrics\n", "\n", "# Load the dataset into pandas dataframes\n", @@ -236,8 +235,7 @@ "import os\n", "import pandas as pd\n", "from khiops import core as kh\n", - "from khiops.sklearn import KhiopsClassifier\n", - "from khiops.utils.helpers import train_test_split_dataset\n", + "from khiops.sklearn import KhiopsClassifier, train_test_split_dataset\n", "from sklearn import metrics\n", "\n", "# Load the dataset tables into dataframes\n", diff --git a/khiops/samples/samples_sklearn.py b/khiops/samples/samples_sklearn.py index afca3259..b6fa0bee 100644 --- a/khiops/samples/samples_sklearn.py +++ b/khiops/samples/samples_sklearn.py @@ -148,8 +148,7 @@ def khiops_classifier_multitable_star(): import os import pandas as pd from khiops import core as kh - from khiops.sklearn import KhiopsClassifier - from khiops.utils.helpers import train_test_split_dataset + from khiops.sklearn import KhiopsClassifier, train_test_split_dataset from sklearn import metrics # Load the dataset into pandas dataframes @@ -207,8 +206,7 @@ def khiops_classifier_multitable_snowflake(): import os import pandas as pd from khiops import core as kh - from khiops.sklearn import KhiopsClassifier - from khiops.utils.helpers import train_test_split_dataset + from khiops.sklearn import KhiopsClassifier, train_test_split_dataset from sklearn import metrics # Load the dataset tables into dataframes diff --git a/khiops/sklearn/__init__.py b/khiops/sklearn/__init__.py index 10159e2f..e1b7f33b 100644 --- a/khiops/sklearn/__init__.py +++ b/khiops/sklearn/__init__.py @@ -11,3 +11,4 @@ KhiopsEncoder, KhiopsRegressor, ) +from khiops.sklearn.helpers import train_test_split_dataset diff --git a/khiops/utils/dataset.py b/khiops/sklearn/dataset.py similarity index 100% rename from khiops/utils/dataset.py rename to khiops/sklearn/dataset.py diff --git a/khiops/sklearn/estimators.py b/khiops/sklearn/estimators.py index 79176f3a..127cde5f 100644 --- a/khiops/sklearn/estimators.py +++ b/khiops/sklearn/estimators.py @@ -50,7 +50,7 @@ is_list_like, type_error_message, ) -from khiops.utils.dataset import ( +from khiops.sklearn.dataset import ( Dataset, FileTable, get_khiops_variable_name, diff --git a/khiops/utils/helpers.py b/khiops/sklearn/helpers.py similarity index 98% rename from khiops/utils/helpers.py rename to khiops/sklearn/helpers.py index 2b16c5e8..c390693d 100644 --- a/khiops/utils/helpers.py +++ b/khiops/sklearn/helpers.py @@ -5,7 +5,7 @@ from sklearn.model_selection import train_test_split from khiops.core.internals.common import is_dict_like, type_error_message -from khiops.utils.dataset import Dataset, FileTable +from khiops.sklearn.dataset import Dataset, FileTable # Note: We build the splits with lists and itertools.chain avoid pylint warning about # unbalanced-tuple-unpacking. See issue https://github.com/pylint-dev/pylint/issues/5671 diff --git a/khiops/utils/__init__.py b/khiops/utils/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/test_dataset_class.py b/tests/test_dataset_class.py index be0034c6..d626428d 100644 --- a/tests/test_dataset_class.py +++ b/tests/test_dataset_class.py @@ -17,7 +17,7 @@ from pandas.testing import assert_frame_equal from sklearn import datasets -from khiops.utils.dataset import Dataset +from khiops.sklearn.dataset import Dataset class DatasetInputOutputConsistencyTests(unittest.TestCase): diff --git a/tests/test_dataset_errors.py b/tests/test_dataset_errors.py index 457d6529..d00a6660 100644 --- a/tests/test_dataset_errors.py +++ b/tests/test_dataset_errors.py @@ -14,7 +14,7 @@ import pandas as pd from khiops.core.internals.common import type_error_message -from khiops.utils.dataset import Dataset, FileTable, PandasTable +from khiops.sklearn.dataset import Dataset, FileTable, PandasTable # Disable PEP8 variable names because of scikit-learn X,y conventions diff --git a/tests/test_helper_functions.py b/tests/test_helper_functions.py index 34f4a9d4..e63cbf4c 100644 --- a/tests/test_helper_functions.py +++ b/tests/test_helper_functions.py @@ -16,7 +16,7 @@ from khiops.core.dictionary import DictionaryDomain from khiops.core.helpers import build_multi_table_dictionary_domain, visualize_report -from khiops.utils.helpers import train_test_split_dataset +from khiops.sklearn.helpers import train_test_split_dataset class KhiopsHelperFunctions(unittest.TestCase): From 31df562501d63daba892348c845ebede946c60ae Mon Sep 17 00:00:00 2001 From: Felipe Olmos <92923444+folmos-at-orange@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:33:57 +0100 Subject: [PATCH 2/3] Fix relative path bug in create-doc script --- doc/create-doc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/create-doc b/doc/create-doc index 1de0c1ac..f1eb14d6 100755 --- a/doc/create-doc +++ b/doc/create-doc @@ -79,6 +79,7 @@ fi # Convert tutorials to reST tutorials_dir="./tutorials" +tutorials_dir="$(realpath $tutorials_dir)" mkdir -p "$tutorials_dir" if [[ $TRANSFORM_NOTEBOOKS ]] then @@ -100,8 +101,8 @@ python create-coursework.py cd coursework mkdir -p exercises touch exercises/.dummy # Create a dummy so the "exercises" directory is created on unzip -zip "../../$tutorials_dir/core_tutorials.zip" Core*.ipynb data/*/* exercises/.dummy -zip "../../$tutorials_dir/sklearn_tutorials.zip" Sklearn*.ipynb data/*/* exercises/.dummy +zip "$tutorials_dir/core_tutorials.zip" Core*.ipynb data/*/* exercises/.dummy +zip "$tutorials_dir/sklearn_tutorials.zip" Sklearn*.ipynb data/*/* exercises/.dummy cd "../.." # Create the documentation with Sphinx From aede15b76331be6bf490d3960a4d0a2f9d6cb422 Mon Sep 17 00:00:00 2001 From: Felipe Olmos <92923444+folmos-at-orange@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:52:34 +0100 Subject: [PATCH 3/3] TMP checkout tutos from dev branch --- .github/workflows/api-docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/api-docs.yml b/.github/workflows/api-docs.yml index 62e7aafd..2fc0038d 100644 --- a/.github/workflows/api-docs.yml +++ b/.github/workflows/api-docs.yml @@ -53,6 +53,7 @@ jobs: with: repository: khiopsml/khiops-python-tutorial path: doc/khiops-python-tutorial + ref: shorten-helpers-path - name: Add pip scripts directory to path run: echo PATH="$PATH:/github/home/.local/bin" >> "$GITHUB_ENV" - name: Install doc build requirements