Skip to content

Add scikit-learn metadata routing support to BaseRegressor - #77

Closed
yousefkhedr777 wants to merge 1 commit into
pysal:mainfrom
yousefkhedr777:feature/metadata-routing-geometry
Closed

Add scikit-learn metadata routing support to BaseRegressor#77
yousefkhedr777 wants to merge 1 commit into
pysal:mainfrom
yousefkhedr777:feature/metadata-routing-geometry

Conversation

@yousefkhedr777

Copy link
Copy Markdown

//notes
-i think metadata is the best way because implements metadata routing for the geometry parameter within the BaseRegressor class because no existing public APIs were changed and users not relying on Pipeline or GridSearchCV are unaffected and existing workflows continue to work as before
-This change is designed for scikit-learn ≥ 1.3, where metadata routing is supported.
Older versions of scikit-learn are not affected by this change.

Key changes:

  • add get_metadata_routing() to BaseRegressor to explicitly declare geometry as required metadatas.
  • Declared geometry as a required metadata input to be only keyword to avoids misuse in preprocessing steps for:
    • fit
    • predict
    • score
  • Ensured compatibility with Scikit-Learn's Pipeline and GridSearchCV when enable_metadata_routing=True is configured.

Verified the logic using a mock estimator to ensure metadata is correctly routed through a Pipeline.

@yousefkhedr777
yousefkhedr777 force-pushed the feature/metadata-routing-geometry branch 8 times, most recently from d9c7ce4 to 40668e1 Compare January 28, 2026 01:27
@theralavineela

Copy link
Copy Markdown

Just a heads-up based on earlier discussions: this relies on scikit-learn’s metadata routing (MetadataRequest, _fit_context), which is still experimental/private .It might be safer to avoid this for now and stick to explicit geometry handling until the API stabilises :)

@yousefkhedr777
yousefkhedr777 force-pushed the feature/metadata-routing-geometry branch 2 times, most recently from 8cc2ae9 to 2d492e7 Compare January 31, 2026 19:40
@codecov

codecov Bot commented Jan 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.22%. Comparing base (7f5a1c7) to head (f1f00fd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
gwlearn/base.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
- Coverage   91.36%   91.22%   -0.15%     
==========================================
  Files           6        6              
  Lines         799      809      +10     
==========================================
+ Hits          730      738       +8     
- Misses         69       71       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@yousefkhedr777
yousefkhedr777 force-pushed the feature/metadata-routing-geometry branch from 2d492e7 to f1f00fd Compare January 31, 2026 20:47
@martinfleis

Copy link
Copy Markdown
Member

What is it you're actually doing here, besides polluting the PR with your .idea folder?

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