Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

API: try to make sure that API for metrics is not confusing#30

Merged
martinfleis merged 3 commits intomainfrom
api-clarity
Dec 11, 2025
Merged

API: try to make sure that API for metrics is not confusing#30
martinfleis merged 3 commits intomainfrom
api-clarity

Conversation

@martinfleis
Copy link
Member

An attempt to mitigate the confusion of how is score and other metrics copmuted.

We have 3 ways:

  • based on focal prediction. That takes values from pred_, which themselves are a result of a prediction of the focal value using the single local model built around that focal point.
  • based on pooled data from local models. We pull all y, pred arrays from local models, contatenate them, and measure performance. should be more robust to weird focals. In case of RF, this is based on out-of-bag samples only.
  • local scores. this is reported per model.

The only question is how to make aliases for score_ and similar. mgwr is technically using what we call focal but one could also get the prediction using the predict method, which uses the enseble of local models, not a single one. That would be the most robust way of evaluating the performance but also quite costly. So I'll make sure this is properly documented and users can do that themselves if they wish.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the API for metrics in gwlearn by introducing clearer naming conventions that distinguish between three types of metrics: focal prediction (from single local models), pooled data from local models, and local scores per model. The main changes rename metric attributes to use explicit prefixes (focal_, pooled_, local_) to reduce confusion about how metrics are computed.

  • Metric attributes renamed from generic names (e.g., score_) to prefixed versions (e.g., focal_score_, pooled_oob_score_, local_score_)
  • Test files updated to reference the new metric names
  • Configuration updates to pixi workspace and dependencies

Reviewed changes

Copilot reviewed 9 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pyproject.toml Updates pixi configuration from [tool.pixi.project] to [tool.pixi.workspace] and adds osmnx/pandana dependencies
gwlearn/tests/test_search.py Updates custom metrics references to use focal_ prefix
gwlearn/tests/test_linear_model.py Updates test assertions for renamed local_pooled_* metrics to local_*
gwlearn/tests/test_ensemble.py Updates test assertions for renamed oob_* metrics to pooled_oob_*
gwlearn/tests/test_base.py Updates test assertions to use new focal_ prefixed metric names
gwlearn/linear_model.py Updates docstrings and implementation to consistently use focal_, pooled_, and local_ prefixes
gwlearn/ensemble.py Updates docstrings and implementation for OOB metrics to use pooled_oob_ and local_oob_ prefixes
gwlearn/base.py Updates implementation to use focal_ prefix for metrics and documents the naming convention
docs/source/mgwr_comparison.ipynb Notebook execution output updates (sklearn HTML representation changes)
.gitignore Adds docs/source/cache/ to ignored paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@martinfleis martinfleis merged commit c5a3203 into main Dec 11, 2025
9 checks passed
@martinfleis martinfleis deleted the api-clarity branch December 11, 2025 15:09
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.

1 participant