-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add start of local partial moran statistics #279
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #279 +/- ##
=======================================
+ Coverage 81.3% 82.2% +0.8%
=======================================
Files 24 25 +1
Lines 3332 3518 +186
=======================================
+ Hits 2710 2891 +181
- Misses 622 627 +5
|
now that the paper has hit the annals, I need to get this merged. I've resumed stubbing the tests out, and they should be simple to finalize. I'm hopeful that we can get this released in the next ESDA iteration. I think that, after writing another two class in this frame, it would help to do a similar RFC on an api for ESDA-style interfaces that we can agree upon for the future. I think we need to start developing a more consistent interface, with attributes that have less specificity to the implementation of the class (p_sim vs. p_norm; I vs. associations_ vs. Gi, etc.) I hope to have this RFC written for the development meeting next week. |
esda/moran_local_mv.py
Outdated
""" | ||
self._mvquads = mvquads | ||
y = np.asarray(y).reshape(-1, 1) | ||
W.transform = "r" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you ensure support of Graph? This still assumes W only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I think I've done this with the following check:
if hasattr(W, "to_W"):
W = W.to_W()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of esda is Graph-native now, so there's no conversion happening. If we can keep it that way, I'd be happier but understand that it may be a larger undertaking. It is up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should now be done.
One thing of note... if we were to swap w.sparse * x
for w.sparse @ x
in libpysal.weights.spatial_lag.lag_spatial()
, then all instances of lag_spatial
would work on Graph, too, while preserving backwards compatibility...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets do that
Not sure why the CI is failing on the |
OK, it looks like the |
the issue is that multiple workers are trying to donwload and save the same file at the same time. We need to pull the data ahead of time to make that work as we do in lib https://github.com/pysal/libpysal/blob/bef1e81aa35c9372e91a142e9fa5c8c0c44c55ee/.github/workflows/unittests.yml#L64-L76 |
I think that's one useful solution! I think I would rather do this as a
Using the module-level fixture, this passes now. |
Yeah, that is one option. I am not a big fan of it as tests with a ton of fixtures are pain to debug if you want to re-run those in ipython or a notebook but it is one way of solving this. |
OK! I'm fine with that, too. I like fixtures, since they can encapsulate both the parametrize step and can compose/depend correctly across parallel jobs. So, fine to keep what's in |
esda/moran_local_mv.py
Outdated
""" | ||
self._mvquads = mvquads | ||
y = np.asarray(y).reshape(-1, 1) | ||
W.transform = "r" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets do that
I'm fine with either, I just find working with fixtures a bit opaque occasionally and a long sequence of them is super pain to replicate in a notebook. |
OK, this should be ready to review in full/merge. The example notebook is complete. This commits the estimators in the same convention as the existing |
Tests were all passing in 29b231, and new failures are in unrelated code in |
Incompatibility of shapely with numpy 2.1 released yesterday. |
I'm looking foward to the discussion. One question is how closely the plan is to track scikit-learn conventions, as the implementation in moran_local_mv.py does not follow the "parameters with trailing underscore A point for discussion at the dev meeting. This is looking really nice! Footnotes |
I've updated the API to follow that resource (I think?). Only configuration options are set in the init. When I mentioned using this PR as a prototype for a new spatial statistics API, I meant exactly this! One thing I'd like feedback here is how much data to cache. Here, for example, in the Generally,
Also, not quite sure how to handle the fact that you have one statistic for the global but many for the local? I would like to have one name for both, but if feels wrong to use the plural for the global. I could see using the singular ( |
This adds my partial and auxiliary-regressive local Moran statistics forthcoming in the annals. This needs