Closed bhyeh closed 11 months ago
3. Fixed mistake in
compute_area_estimate
fromarea_utils.py
whereexpr_2
for noncrop was also being calculated using Pcrop instead of Pnoncrop.
Thanks, @bhyeh, for catching and fixing the bug.
I just did a quick test with some data with me. LGTM.
Also, I am considering we include the test for other functions (load_ne
,..., etc.) in the area_utils.py
in the unittest_area
, i.e. total removal of integration_test_area.py
Also, I am considering we include the test for other functions (
load_ne
,..., etc.) in thearea_utils.py
in theunittest_area
, i.e. total removal of integration_test_area.py
I think it might be nice to keep separate the unittest for the specific estimation functions, and have the integration test that involves the entire end-to-end process of loading, binarizing, and etc.
running the unittests
python -m unittest unittest_area_est.ChangeAreaTest
python -m unittest unittest_area_est.CropAreaTest
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
@hannah-rae @adebowaledaniel I think this is nearly ready to be merged - just hoping for a quick lookover at the notebook changes. There, I've kept the cell outputs to give a preview of what the refactored code looks like and its outputs (the outputs are also fake data from the unit tests in case you were wondering, I'll clear them before merging).
Thanks for the notebooks improvement (especially for the single year), @bhyeh 👍🏽. @hannah-rae give you the final comment on the change area notebook.
I will update the integration test later.
FYI acknowledgments/reasons for checks failing on PR:
dataset-test
- unrelated to anything done on this branch, but KenyaCEO2019 in datasets.py
has less than 24 months of data. area-tests
- use of seaborn
module added to area_utils
in a plotting function which is not in environment. this can be resolved when the area integration test gets updated by @adebowaledaniel and decision to add seaborn
library to environment...or not. pre-commit
- flake8
error because module level import is not at top of file, but the particular import has to come after altering module path.
Added:
area_utils.py
and using Olofsson et al., 2014 "Good Practices...".Addressed/Fixed:
The following are fixed with the refactored code added:
RuntimeWarning: overflow encountered in long_scalars
that could happen previously in computing $V(P_i)$ with large pixel marginals by using NumPy anduint64
dtype.expr_2
was incorrectly calculated with the producer accuracy $P0$ for each class $c{i}$ regardless.compute_area_estimate
fromarea_utils.py
whereexpr_2
for $noncrop$ was also being calculated using $P{crop}$ instead of $P{noncrop}$.expr_1
for $c_{1}$ was incorrectly calculated using the marginal total of reference samples instead of mapped units.Notes/Comments: Items addressed here in this PR that relates to #245.
The refactored estimation code should be easily adaptable into each notebook without needing any modification to the functions.
But both notebooks were left untouched w/ this branch work.The refactored estimation code is pulled outside of notebook and works for both area and change area type confusion matrixes.
Implemented unittests for area estimation comparison with prior work that was done outside of repo using the excel tool (after correcting for mistakes 2 and 4 in excel sheet).
Not addressed.
Remaining
TODO
Items:compute_area_estimate
function that does entire end-to-end area estimate calculation from just the confusion matrix and marginal pixels andarea.area_utils.py
witharea_utils_refac.py
area_utils_refac.py
after merge