From 8a5414897f8233d71811bb7f78e46ff48af46915 Mon Sep 17 00:00:00 2001 From: Thierry RAMORASOAVINA Date: Mon, 16 Feb 2026 14:08:02 +0100 Subject: [PATCH] Adapt to scikit-learn 1.8.0 - Since version 1.7.2 the new parameters or functions are already available so no deprecated calls should remain - For python 3.10, 1.7.2 is still used - For python 3.11+, the later 1.8.0+ versions are used - The khiopspydev dev image for rocky is updated to get rid of obsolete python versions --- .github/workflows/pip.yml | 2 +- .github/workflows/tests.yml | 4 ++-- doc/requirements.txt | 2 +- khiops/sklearn/dataset.py | 2 +- packaging/conda/meta.yaml | 2 +- packaging/docker/khiopspydev/Dockerfile.rocky | 22 +++++++------------ pyproject.toml | 2 +- tests/test_sklearn.py | 6 ++--- 8 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index a76758f6..8440644d 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -71,7 +71,7 @@ jobs: # because the `env` context is only accessible at the step level; # hence, it is hard-coded image: |- - ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || 'latest' }} + ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || '11.0.0.3' }} steps: - name: Set parameters as env run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b92fdc5f..35cb2ee8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,7 +42,7 @@ jobs: # because the `env` context is only accessible at the step level; # hence, it is hard-coded image: |- - ghcr.io/khiopsml/khiops-python/khiopspydev-ubuntu22.04:${{ inputs.image-tag || 'latest' }} + ghcr.io/khiopsml/khiops-python/khiopspydev-ubuntu22.04:${{ inputs.image-tag || '11.0.0.3' }} credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -361,7 +361,7 @@ jobs: # because the `env` context is only accessible at the step level; # hence, it is hard-coded image: |- - ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || 'latest' }} + ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || '11.0.0.3' }} credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} diff --git a/doc/requirements.txt b/doc/requirements.txt index 62accbdd..68b7011a 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -5,5 +5,5 @@ nbconvert==6.4.4 nbformat==5.3.0 numpydoc>=1.5.0 pandas>=0.25.3,<=2.3.3 -scikit-learn>=0.22.2,<=1.7.2 +scikit-learn>=1.7.2,<1.9.0 sphinx-copybutton>=0.5.0 diff --git a/khiops/sklearn/dataset.py b/khiops/sklearn/dataset.py index 989f45a7..de1b46e1 100644 --- a/khiops/sklearn/dataset.py +++ b/khiops/sklearn/dataset.py @@ -1077,7 +1077,7 @@ def __init__(self, name, array, key=None): raise TypeError(type_error_message("array", array, np.ndarray, Sequence)) # Initialize the members - self.data_source = check_array(array, ensure_2d=True, force_all_finite=False) + self.data_source = check_array(array, ensure_2d=True, ensure_all_finite=False) self.column_ids = column_or_1d(range(self.data_source.shape[1])) self.khiops_types = { column_id: get_khiops_type(self.data_source.dtype) diff --git a/packaging/conda/meta.yaml b/packaging/conda/meta.yaml index 101efa79..b81c7656 100644 --- a/packaging/conda/meta.yaml +++ b/packaging/conda/meta.yaml @@ -25,7 +25,7 @@ requirements: - python - khiops-core =11.0.0 - pandas >=0.25.3,<=2.3.3 - - scikit-learn >=0.22.2 + - scikit-learn>=1.7.2,<1.9.0 run_constrained: # do not necessary use the latest version # to avoid undesired breaking changes diff --git a/packaging/docker/khiopspydev/Dockerfile.rocky b/packaging/docker/khiopspydev/Dockerfile.rocky index 9d925a9c..ea3683b8 100644 --- a/packaging/docker/khiopspydev/Dockerfile.rocky +++ b/packaging/docker/khiopspydev/Dockerfile.rocky @@ -21,16 +21,12 @@ RUN true \ git \ pandoc \ wget \ - # Install Python 3.11 if on Rocky 8 \ - && if [ "$KHIOPSDEV_OS" = "rocky8" ]; then \ + # Install Python 3.11 on Rocky 8 or 9 as they come with obsolete versions (<= 3.9) \ + && if [ "$KHIOPSDEV_OS" = "rocky8" -o "$KHIOPSDEV_OS" = "rocky9" ]; then \ dnf install -y \ python3.11 \ python3.11-pip \ python3.11-setuptools ; \ - else \ - dnf install -y \ - python3-setuptools \ - python3-pip ; \ fi \ # Get Linux distribution codename \ && if [ -f /etc/os-release ]; then . /etc/os-release; fi \ @@ -47,14 +43,12 @@ RUN true \ && module unload mpi \ # Hard-code OpenMPI module name \ && module load mpi/openmpi-x86_64 \ - # Set python to python3.11 and pip to Pip 3.11 on Rocky 8 \ - # Set python to python3 on Rocky 9 \ - && if [ "$KHIOPSDEV_OS" = "rocky8" ]; then \ - alternatives --set python /usr/bin/python3.11 \ - && alternatives --install /usr/bin/pip pip /usr/bin/pip3.11 1 ; \ - else \ - alternatives --install /usr/bin/python python /usr/bin/python3 1 \ - && alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 ; \ + # Set python to python3.11 and pip to Pip 3.11 on Rocky 8 and 9 \ + && if [ "$KHIOPSDEV_OS" = "rocky8" -o "$KHIOPSDEV_OS" = "rocky9" ]; then \ + alternatives --install /usr/bin/python python /usr/bin/python3.11 2; \ + alternatives --set python /usr/bin/python3.11; \ + alternatives --install /usr/bin/pip pip /usr/bin/pip3.11 2; \ + alternatives --set pip /usr/bin/pip3.11; \ fi \ # Install miniforge to have multiple Python versions via Conda \ && mkdir -p /root/miniforge3 && cd /root/miniforge3 \ diff --git a/pyproject.toml b/pyproject.toml index 8b2da47b..fd34aa0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,7 +106,7 @@ requires-python = ">=3.8" dependencies = [ # do not use the latest versions, to avoid undesired breaking changes "pandas>=0.25.3,<=2.3.3", - "scikit-learn>=0.22.2,<=1.7.2", + "scikit-learn>=1.7.2,<1.9.0", ] [project.urls] diff --git a/tests/test_sklearn.py b/tests/test_sklearn.py index c06a35f2..ffeee06c 100644 --- a/tests/test_sklearn.py +++ b/tests/test_sklearn.py @@ -18,7 +18,7 @@ import numpy as np import pandas as pd from sklearn.exceptions import NotFittedError -from sklearn.utils.estimator_checks import check_estimator +from sklearn.utils.estimator_checks import estimator_checks_generator from sklearn.utils.validation import check_is_fitted import khiops.core as kh @@ -1784,9 +1784,7 @@ def test_sklearn_check_estimator(self): # Execute sklearn's estimator test battery print("") for khiops_estimator in khiops_estimators: - for estimator, check in check_estimator( - khiops_estimator, generate_only=True - ): + for estimator, check in estimator_checks_generator(khiops_estimator): check_name = check.func.__name__ if check_name == "check_n_features_in_after_fitting": continue