Skip to content

Expose fitted attributes for Dask linear models - #8392

Open
nethum529 wants to merge 7 commits into
NVIDIA:mainfrom
nethum529:bug-issue-7460-dask-fitted-attrs
Open

Expose fitted attributes for Dask linear models#8392
nethum529 wants to merge 7 commits into
NVIDIA:mainfrom
nethum529:bug-issue-7460-dask-fitted-attrs

Conversation

@nethum529

Copy link
Copy Markdown
Contributor

Summary

  • Expose coef_, intercept_, and n_iter_ from Dask ElasticNet and Lasso.
  • Let Dask Ridge proxy coef_ and intercept_ from its fitted model.
  • Carry the client output type when a fitted attribute is read from a worker.
  • Add coverage for pre-fit errors, output types, and refits.

Testing

  • Changed-file pre-commit checks pass.
  • The new Dask tests cover ElasticNet, Lasso, and Ridge.

Addresses #7460

Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
@nethum529
nethum529 requested a review from a team as a code owner July 18, 2026 04:22
@nethum529
nethum529 requested a review from dantegd July 18, 2026 04:22
@copy-pr-bot

copy-pr-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Cython / Python Cython or Python issue label Jul 18, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a890f692-4966-4f18-a2e7-f88e086e8193

📥 Commits

Reviewing files that changed from the base of the PR and between af90d6f and b9956ab.

📒 Files selected for processing (6)
  • python/cuml/cuml/dask/common/base.py
  • python/cuml/cuml/dask/linear_model/elastic_net.py
  • python/cuml/cuml/dask/linear_model/lasso.py
  • python/cuml/tests/dask/test_dask_base.py
  • python/cuml/tests/dask/test_dask_coordinate_descent.py
  • python/cuml/tests/dask/test_dask_ridge_regression.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • python/cuml/cuml/dask/common/base.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Distributed ElasticNet and Lasso now expose fitted properties (coefficients, intercept, and iteration count) through their public attribute access.
    • Improved handling of the active output type when retrieving model attributes in distributed estimators.
  • Bug Fixes

    • Pre-fit access to fitted properties now consistently raises an AttributeError indicating the estimator is not fitted.
    • Fitted attributes (including iteration counts) correctly update after refitting for Ridge, ElasticNet, and Lasso.
  • Tests

    • Expanded Dask test coverage for fitted-attribute behavior, output-type scenarios, refit correctness, and iteration-count consistency.
    • Added unit tests to ensure attribute-resolution errors are preserved with their original causes/messages.

Walkthrough

Dask linear models now expose fitted attributes through their underlying solvers. Attribute resolution preserves the configured output type, Ridge fitted attributes remain absent before fitting, and tests cover solver consistency, NumPy output, and refit updates.

Changes

Dask fitted attributes

Layer / File(s) Summary
Output-type-aware attribute lookup
python/cuml/cuml/dask/common/base.py, python/cuml/tests/dask/test_dask_base.py
BaseEstimator preserves the active GlobalSettings().output_type while resolving attributes from the internal model and preserves lookup errors.
Solver-backed fitted properties
python/cuml/cuml/dask/linear_model/elastic_net.py, python/cuml/cuml/dask/linear_model/lasso.py, python/cuml/cuml/dask/linear_model/ridge.py
ElasticNet and Lasso expose coef_, intercept_, and n_iter_ from their solvers; Ridge no longer initializes fitted attributes before fitting.
Fitted attribute validation
python/cuml/tests/dask/test_dask_coordinate_descent.py, python/cuml/tests/dask/test_dask_ridge_regression.py
Tests validate pre-fit absence, solver consistency, output types, iteration counts, and attribute updates after refitting.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • rapidsai/cuml#8378: Both changes modify Dask BaseEstimator attribute-resolution behavior.

Suggested labels: improvement, non-breaking

Suggested reviewers: dantegd

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely describes the main change: exposing fitted attributes for Dask linear models.
Description check ✅ Passed The description clearly matches the changeset by summarizing fitted attributes, output-type handling, and added tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants