-
Notifications
You must be signed in to change notification settings - Fork 31
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
Confusion matrix in terms of map area proportions instead of sample size #381
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…into stderr-fix
.get("crop") | ||
.getInfo() | ||
) | ||
|
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.
Here's an alternative to getting the crop/non-crop proportion without the need for two reduceRegion calls.
It also may be more "accurate" since the proportions are computed using area vs pixel count.
geom = aoi.geometry()
area = geom.area()
crop_proportion = binary_image \
.multiply(ee.Image.pixelArea()) # Multiplies each pixel by its area
.divide(area) # Divides each pixel by the total area
.reduceRegion(
reducer=ee.Reducer.sum(),
geometry=geom,
scale=self.resolution,
maxPixels=1e12,
bestEffort=True # Should reduce scale if computation times out
).get("crop").getInfo()
w_j = np.array([1-crop_proportion, crop_proportion])
return w_j
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 be multiplied by area
to get a_j
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.
Never mind I see you need the exact amount of pixels for the producer variance estimator 🤦
if precision + recall == 0: | ||
return 0 | ||
f1_score = 2 * (precision * recall) / (precision + recall) | ||
return f1_score |
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.
Thanks for adding this!
for more information, see https://pre-commit.ci
…into stderr-fix
…into stderr-fix
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…into stderr-fix
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 looks excellent! Looks like worldcover got a bit of a boost from these area weights. Thank you for updating the template notebook and the descriptions in each notebook.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Currently, our intercomparison and other metrics are being computed based on the confusion matrix expressed in terms of sample size. However, the recommendation in Stehman & Foody 2019 is to compute metrics from the confusion matrix expressed in terms of map area proportions of each class (which is what we do for area estimation in
src/area_utils.py
see lines 563-567 in that file).This PR adds a new function to compute the mapped area for each class and use these totals to compute the "area matrix". There are a few issues to be addressed still:
maps