Skip to content

Commit

Permalink
[ci] [python-package] [R-package] adapt to scikit-learn check_sample_…
Browse files Browse the repository at this point in the history
…weight_equivalence changes, stop testing against R 3.6 on Linux (#6733)
  • Loading branch information
jameslamb authored Nov 30, 2024
1 parent 83c0ff3 commit 27b00d7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 119 deletions.
79 changes: 0 additions & 79 deletions .ci/install-old-r-packages.R

This file was deleted.

21 changes: 5 additions & 16 deletions .ci/test-r-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ fi

# Get details needed for installing R components
R_MAJOR_VERSION="${R_VERSION%.*}"
if [[ "${R_MAJOR_VERSION}" == "3" ]]; then
export R_MAC_VERSION=3.6.3
export R_MAC_PKG_URL=${CRAN_MIRROR}/bin/macosx/R-${R_MAC_VERSION}.nn.pkg
export R_LINUX_VERSION="3.6.3-1bionic"
export R_APT_REPO="bionic-cran35/"
elif [[ "${R_MAJOR_VERSION}" == "4" ]]; then
if [[ "${R_MAJOR_VERSION}" == "4" ]]; then
export R_MAC_VERSION=4.3.1
export R_MAC_PKG_URL=${CRAN_MIRROR}/bin/macosx/big-sur-${ARCH}/base/R-${R_MAC_VERSION}-${ARCH}.pkg
export R_LINUX_VERSION="4.3.1-1.2204.0"
Expand Down Expand Up @@ -108,16 +103,10 @@ if [[ $OS_NAME == "macos" ]]; then
export R_TIDYCMD=/usr/local/bin/tidy
fi

# fix for issue where CRAN was not returning {evaluate}, {lattice}, or {waldo} when using R 3.6
# "Warning: dependency ‘lattice’ is not available"
if [[ "${R_MAJOR_VERSION}" == "3" ]]; then
Rscript --vanilla ./.ci/install-old-r-packages.R
else
# {Matrix} needs {lattice}, so this needs to run before manually installing {Matrix}.
# This should be unnecessary on R >=4.4.0
# ref: https://github.com/microsoft/LightGBM/issues/6433
Rscript --vanilla -e "install.packages('lattice', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}')"
fi
# {Matrix} needs {lattice}, so this needs to run before manually installing {Matrix}.
# This should be unnecessary on R >=4.4.0
# ref: https://github.com/microsoft/LightGBM/issues/6433
Rscript --vanilla -e "install.packages('lattice', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}')"

# manually install {Matrix}, as {Matrix}=1.7-0 raised its R floor all the way to R 4.4.0
# ref: https://github.com/microsoft/LightGBM/issues/6433
Expand Down
19 changes: 1 addition & 18 deletions .github/workflows/r_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ concurrency:
cancel-in-progress: true

env:
# https://github.com/actions/checkout/issues/1590#issuecomment-2207052044
#
# this could be removed (hopefully) when R 3.6 support is removed
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
# in CMake-driven builds, parallelize compilation
CMAKE_BUILD_PARALLEL_LEVEL: 4
# on Debian-based images, avoid interactive prompts
Expand Down Expand Up @@ -48,12 +44,6 @@ jobs:
################
# CMake builds #
################
- os: ubuntu-latest
task: r-package
compiler: gcc
r_version: 3.6
build_type: cmake
container: 'ubuntu:18.04'
- os: ubuntu-latest
task: r-package
compiler: gcc
Expand Down Expand Up @@ -174,19 +164,12 @@ jobs:
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: true
- name: Install pandoc
uses: r-lib/actions/setup-pandoc@v2
if: matrix.container != 'ubuntu:18.04'
# R 3.6 binary isn't easily available on Ubuntu 18.04,
# but setup-pandoc>=2.7.1 is uses a too-new glibc for it.
# ref: https://github.com/microsoft/LightGBM/issues/6298
- name: Install pandoc
uses: r-lib/actions/[email protected]
if: matrix.container == 'ubuntu:18.04'
- name: Install tinytex
if: startsWith(matrix.os, 'windows')
uses: r-lib/actions/setup-tinytex@v2
Expand Down
18 changes: 12 additions & 6 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,19 +673,25 @@ def __init__(
# is >=1.6.
# ref: https://github.com/microsoft/LightGBM/pull/6651
def _more_tags(self) -> Dict[str, Any]:
check_sample_weight_str = (
"In LightGBM, setting a sample's weight to 0 can produce a different result than omitting the sample. "
"Such samples intentionally still affect count-based measures like 'min_data_in_leaf' "
"(https://github.com/microsoft/LightGBM/issues/5626#issuecomment-1712706678) and the estimated distribution "
"of features for Dataset construction (see https://github.com/microsoft/LightGBM/issues/5553)."
)
# "check_sample_weight_equivalence" can be removed when lightgbm's
# minimum supported scikit-learn version is at least 1.6
# ref: https://github.com/scikit-learn/scikit-learn/pull/30137
return {
"allow_nan": True,
"X_types": ["2darray", "sparse", "1dlabels"],
"_xfail_checks": {
"check_no_attributes_set_in_init": "scikit-learn incorrectly asserts that private attributes "
"cannot be set in __init__: "
"(see https://github.com/microsoft/LightGBM/issues/2628)",
"check_sample_weight_equivalence": (
"In LightGBM, setting a sample's weight to 0 can produce a different result than omitting the sample. "
"Such samples intentionally still affect count-based measures like 'min_data_in_leaf' "
"(https://github.com/microsoft/LightGBM/issues/5626#issuecomment-1712706678) and the estimated distribution "
"of features for Dataset construction (see https://github.com/microsoft/LightGBM/issues/5553)."
),
"check_sample_weight_equivalence": check_sample_weight_str,
"check_sample_weight_equivalence_on_dense_data": check_sample_weight_str,
"check_sample_weight_equivalence_on_sparse_data": check_sample_weight_str,
},
}

Expand Down

0 comments on commit 27b00d7

Please sign in to comment.