API: do not compute performance metrics, return arrays for users #32
Merged
martinfleis merged 5 commits intomainfrom Dec 15, 2025
Merged
API: do not compute performance metrics, return arrays for users #32martinfleis merged 5 commits intomainfrom
martinfleis merged 5 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the API to remove automatic computation of performance metrics and instead return raw arrays for users to compute their own metrics. The change shifts responsibility from the library to the user, providing more flexibility and reducing computational overhead when metrics aren't needed.
Key Changes:
- Removed the
measure_performanceparameter from all model classes - Replaced computed metric attributes (e.g.,
focal_score_,pooled_score_,local_score_) with raw data arrays (e.g.,y_pooled_,pred_pooled_,left_out_y_,left_out_proba_) - Added new
local_metric()method to BaseClassifier for computing custom local performance metrics - Updated BandwidthSearch to handle metrics differently, computing only required metrics on-demand
Reviewed changes
Copilot reviewed 9 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| gwlearn/base.py | Removed measure_performance parameter and automatic metric computation from base classes; added local_metric() method for custom metric computation; replaced computed metrics with raw prediction/target arrays |
| gwlearn/linear_model.py | Removed measure_performance from GWLogisticRegression and GWLinearRegression; replaced computed pooled/local metrics with raw y_pooled_ and pred_pooled_ arrays; updated docstrings to reflect new attributes |
| gwlearn/ensemble.py | Removed measure_performance from ensemble classifiers; replaced OOB metric computations with raw oob_y_pooled_ and oob_pred_pooled_ arrays |
| gwlearn/search.py | Updated to compute metrics on-demand rather than relying on model's measure_performance; added special handling for log_loss calculation |
| gwlearn/tests/test_base.py | Removed tests for automatic metric computation; updated assertions to check raw prediction arrays instead of computed metrics |
| gwlearn/tests/test_linear_model.py | Removed tests for pooled and local performance metrics that are no longer computed automatically |
| gwlearn/tests/test_ensemble.py | Removed tests for OOB metric attributes; updated to verify raw OOB data arrays instead |
| gwlearn/tests/test_search.py | Simplified metric tracking tests to focus on prediction_rate only |
| docs/source/mgwr_comparison.ipynb | Updated notebook output reflecting removal of measure_performance parameter from model repr |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.