Skip to content

restore forest deselection from normalize sample weights#3292

Open
ethanglaser wants to merge 6 commits into
uxlfoundation:mainfrom
ethanglaser:dev/eglaser-restore-forest-deselection
Open

restore forest deselection from normalize sample weights#3292
ethanglaser wants to merge 6 commits into
uxlfoundation:mainfrom
ethanglaser:dev/eglaser-restore-forest-deselection

Conversation

@ethanglaser

@ethanglaser ethanglaser commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes to forest sample weight handling to undo recent forest deselection (#3231). Also addresses older extratrees deselected test.


Checklist:

Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.
  • I have extended testing suite if new functionality was introduced in this PR.

Performance

  • I have measured performance for affected algorithms using scikit-learn_bench and provided at least a summary table with measured data, if performance change is expected.
  • I have provided justification why performance and/or quality metrics have changed or why changes are not expected.
  • I have extended the benchmarking suite and provided a corresponding scikit-learn_bench PR if new measurable functionality was introduced in this PR.

Copilot AI review requested due to automatic review settings June 24, 2026 16:25
@ethanglaser

Copy link
Copy Markdown
Contributor Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores scikit-learn test coverage for oneDAL-backed forests by fixing sample-weight handling in onedal decision forests so that feature-importance tests for ExtraTrees are no longer deselected.

Changes:

  • Normalize sample_weight before forest training to improve invariance under weight scaling.
  • Re-enable previously deselected ExtraTreesRegressor feature-importance tests (float32/float64) by removing them from deselected_tests.yaml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
onedal/ensemble/forest.py Adds pre-fit sample-weight normalization intended to prevent weight-scale sensitivity in oneDAL forest training.
deselected_tests.yaml Removes deselections for ExtraTreesRegressor feature-importance tests so they run again in CI.

Comment thread onedal/ensemble/forest.py Outdated
Comment on lines +154 to +160
_, xp, _ = _get_sycl_namespace(sample_weight)
# float() keeps the divisor a Python scalar so the division is valid
# across array namespaces (e.g. array_api_strict rejects a foreign
# numpy scalar) and preserves sample_weight's dtype.
max_weight = float(xp.max(sample_weight))
if max_weight > 0:
sample_weight = sample_weight / max_weight
@david-cortes-intel

Copy link
Copy Markdown
Contributor

@ethanglaser @Alexandr-Solovev This should be done on the oneDAL side, together with other obvious tricks like standardizing 'y', for both CPU and GPU.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
azure 77.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread deselected_tests.yaml
- model_selection/tests/test_classification_threshold.py::test_tuned_threshold_classifier_cv_zeros_sample_weights_equivalence >=1.5

# Deselections for 2025.0
- ensemble/tests/test_forest.py::test_importances[ExtraTreesRegressor-squared_error-float64]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethanglaser This test shouldn't even be getting patched in sklearn1.9 onwards:
https://github.com/scikit-learn/scikit-learn/blob/fa7eddec61a9f336a27e1519161c23b357af138c/sklearn/ensemble/tests/test_forest.py#L339

See the conditions:

- ``bootstrap`` = ``True`` and/or ``max_samples`` != ``None`` are not supported when there are sample weights

In which job is this failure observed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, this would have been deselected over a year ago

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But these are the same test aside from fp type

@ethanglaser

Copy link
Copy Markdown
Contributor Author

@ethanglaser ethanglaser changed the title Dev/eglaser restore forest deselection restore forest deselection from normalize sample weights Jun 25, 2026
@ethanglaser

Copy link
Copy Markdown
Contributor Author

Would merge this after the changes from uxlfoundation/oneDAL#3674 are incorporated into the oneDAL build that github actions fetches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants