API: move geometry back to fit, implement score and backbone for metadata routing#55
API: move geometry back to fit, implement score and backbone for metadata routing#55martinfleis merged 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the API to move the geometry parameter from model initialization to the fit() method, implements score() methods for both classifiers and regressors, and adds metadata routing helpers to support scikit-learn's metadata routing framework. This change aligns with scikit-learn conventions where data-related parameters are passed to fit() rather than __init__().
Key changes:
- Moved
geometryparameter from__init__()tofit()across all model classes - Implemented
score()methods forBaseClassifier(accuracy) andBaseRegressor(R²) - Added metadata routing helper methods (
set_fit_request,set_predict_request,set_predict_proba_request,set_score_request)
Reviewed changes
Copilot reviewed 12 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
gwlearn/base.py |
Core changes - moved geometry to fit(), added score() methods and metadata routing helpers |
gwlearn/linear_model.py |
Updated GWLinearRegression and GWLogisticRegression fit() signatures to accept geometry parameter |
gwlearn/ensemble.py |
Updated ensemble models (GWRandomForestClassifier, GWGradientBoostingClassifier, GWRandomForestRegressor) fit() signatures |
gwlearn/search.py |
Updated BandwidthSearch to accept geometry in fit() instead of init() |
gwlearn/tests/test_base.py |
Updated tests to pass geometry to fit(); added new tests for score() methods |
gwlearn/tests/test_linear_model.py |
Updated tests to pass geometry to fit() instead of init() |
gwlearn/tests/test_ensemble.py |
Updated tests to pass geometry to fit() instead of init() |
gwlearn/tests/test_search.py |
Updated BandwidthSearch tests to pass geometry to fit() |
docs/source/network_graph.ipynb |
Updated examples to use new API |
docs/source/linear.ipynb |
Updated examples to use new API |
docs/source/introduction.ipynb |
Updated examples to use new API |
README.md |
Updated example code to demonstrate new API |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #55 +/- ##
==========================================
- Coverage 86.45% 85.71% -0.75%
==========================================
Files 6 6
Lines 768 798 +30
==========================================
+ Hits 664 684 +20
- Misses 104 114 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Please don't apologize, I'm totally fine with it. If your changes have moved us in a better direction, I’m happy to start fresh with some new ideas on simplifying this for a user. Should I go ahead and close this PR for now to keep things clean, or would you like to keep it open while we decide on the next steps, I’m still learning how sklearn intends this to be used, so I'm happy to follow your lead |
This went a bit out of hand. I was experimenting with the stuff in #45, which turned out needed implementation of
scoreamong other things.geometryback tofitscoreWith all this, I can make the sklearn grid search run successfully like this. Not sure if this is intended by sklearn of if there's a way to simplify this for a user (e.g. to avoid those set calls). @theralavineela any ideas? I am also not sure to which degree made this your PR obsolete. Sorry, a rabbit hole sucked me in.