Skip to content

Conversation

csadorf
Copy link
Contributor

@csadorf csadorf commented Oct 8, 2025

Summary

Refactors test_logistic_regression_weighting to use Hypothesis for property-based testing, fixing flakiness in multiclass logistic regression with class weighting.

Closes #7298

Problem

The test_logistic_regression_weighting[multiclass-3-class_weight] test was failing intermittently. The root causes:

  1. Insufficient iterations: Some weight combinations needed more iterations to converge
  2. Fixed tolerances: Didn't account for varying problem difficulty (weights, number of classes)
  3. Normalization bug: Missing keepdims=True in multiclass coefficient normalization

Changes

Converted to Hypothesis-based testing:

  • Uses standard_classification_datasets() with use_sample_weight and class_weight_option parameters
  • Adds 4 explicit @example decorators for critical scenarios (including the original failing case)

Improved robustness:

  • Dynamic max_iter: 500 → 1000 for problems combining sample weights and class weights
  • Adaptive tolerances:
    • Easy problems (no weights, ≤3 classes): unit_tol=0.04, total_tol=0.08
    • Hard problems (with weights or >3 classes): unit_tol=0.25, total_tol=0.40

Copy link

copy-pr-bot bot commented Oct 8, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions bot added Cython / Python Cython or Python issue ci labels Oct 8, 2025
@csadorf csadorf added DO NOT MERGE Hold off on merging; see PR for details and removed Cython / Python Cython or Python issue ci labels Oct 8, 2025
@csadorf csadorf added tests Unit testing for project improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Oct 8, 2025
@csadorf
Copy link
Contributor Author

csadorf commented Oct 8, 2025

/ok to test 557fee1

@github-actions github-actions bot added Cython / Python Cython or Python issue ci labels Oct 13, 2025
@csadorf
Copy link
Contributor Author

csadorf commented Oct 13, 2025

/ok to test d849ced

@csadorf
Copy link
Contributor Author

csadorf commented Oct 15, 2025

/ok to test e86e662

@github-actions github-actions bot removed the ci label Oct 15, 2025
@csadorf csadorf changed the title [DO NOT MERGE] work/issue 7298 Fix flaky test_logistic_regression_weighting test Oct 15, 2025
@csadorf csadorf removed the DO NOT MERGE Hold off on merging; see PR for details label Oct 15, 2025
@csadorf csadorf marked this pull request as ready for review October 15, 2025 21:50
@csadorf csadorf requested a review from a team as a code owner October 15, 2025 21:50
@csadorf csadorf requested a review from divyegala October 15, 2025 21:50
@csadorf
Copy link
Contributor Author

csadorf commented Oct 16, 2025

/merge

@rapids-bot rapids-bot bot merged commit 952456a into rapidsai:branch-25.12 Oct 16, 2025
190 of 192 checks passed
@csadorf csadorf deleted the work/issue-7298 branch October 16, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change tests Unit testing for project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] test_logistic_regression_weighting fails with coefficient mismatch (flaky)

2 participants