Skip to content
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

[ENH][DOC] local join count and LOSH statistics #139

Closed
wants to merge 4 commits into from
Closed

[ENH][DOC] local join count and LOSH statistics #139

wants to merge 4 commits into from

Conversation

jeffcsauer
Copy link
Collaborator

Purpose of PR

This PR addresses bullet point 1, 5, and 6 of #61. Specifically, this PR adds four new functions to estimate:

  • Local spatial heteroskedasticity (function name: losh)
  • Local join counts - univariate (function name: Local_Join_Count)
  • Local join counts - bivariate (function name: Local_Join_Count_BV)
  • Local join counts - multivariate (function name: Local_Join_Count_MV)

Each function is written in the form of a scikit-learn style estimator. PEP8 formatting has been applied to all of the functions, although a handful of lines are left long due to readability.

Documentation

Two notebooks are included in the PR. Each notebook briefly reviews the core math of the statistic and explains how a user might deploy the statistic in a geospatial workflow. The included examples match those found in R spdep::LOSH and spdep::LOSH.cs as well as the GeoDa Local Join Counts tutorial.

All functions include docstrings and doctests that use built-in PySAL example datasets.

Tests

I have added in four .py test files that execute successfully on my fork. These new tests follow the lead of the existing tests, specifically test_moran.py for the LOSH function and test_join_counts.py for the local join count functions.

Notes for PR consideration

  • Local join count functions are currently using the default n_jobs=1 to avoid issues fixed in potential merges. Users may enter values other than 1.
  • One doctest dataset, commpop, appears to have a dead link at the moment. Having trouble loading this as a libpysal.example. Once this dataset is working the doctest can be updated. Currently hosting it on a personal Github link.

@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2020

Codecov Report

Merging #139 into master will increase coverage by 1.88%.
The diff coverage is 95.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #139      +/-   ##
==========================================
+ Coverage   77.61%   79.49%   +1.88%     
==========================================
  Files          25       33       +8     
  Lines        3274     3584     +310     
==========================================
+ Hits         2541     2849     +308     
- Misses        733      735       +2     
Impacted Files Coverage Δ
esda/losh.py 90.24% <90.24%> (ø)
esda/tests/test_ljc.py 91.30% <91.30%> (ø)
esda/tests/test_ljc_mv.py 92.00% <92.00%> (ø)
esda/tests/test_losh.py 92.00% <92.00%> (ø)
esda/tests/test_ljc_bv.py 92.30% <92.30%> (ø)
esda/local_join_count_bv.py 97.33% <97.33%> (ø)
esda/local_join_count.py 100.00% <100.00%> (ø)
esda/local_join_count_mv.py 100.00% <100.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e660983...2eb0d37. Read the comment docs.

@ljwolf ljwolf requested review from ljwolf and sjsrey August 28, 2020 16:08
esda/local_join_count.py Outdated Show resolved Hide resolved
Copy link
Member

@ljwolf ljwolf left a comment

Choose a reason for hiding this comment

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

👏 this is amazing @jeffcsauer! well done! extremely minor API changes that mesh with the sklearn developer guide, but jeez, these are awesome!

esda/local_join_count_bv.py Outdated Show resolved Hide resolved
esda/losh.py Outdated Show resolved Hide resolved
esda/losh.py Outdated Show resolved Hide resolved
@ljwolf
Copy link
Member

ljwolf commented Jan 20, 2021

This has been superseded by #145

@ljwolf ljwolf closed this Jan 20, 2021
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