Open ahuang11 opened 4 years ago
I don’t understand what your question is.
Why can't I use it for more than just two categories?
On Tue, Sep 22, 2020, 5:09 PM Aaron Spring notifications@github.com wrote:
I don’t understand what your question is.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/raybellwaves/xskillscore/issues/187#issuecomment-697008871, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU7FFSG7HL4C6WZSUT4OR3SHEOC7ANCNFSM4RWJGLKQ .
The current implementation of threat score requires that the data is dichotomous (see https://www.cawcr.gov.au/projects/verification/#Methods_for_dichotomous_forecasts). An extension to multi-category would certainly be welcome if you want to open a PR.
@ahuang11 you may also be interested in https://github.com/raybellwaves/xskillscore/issues/138. May be worth dipping your toe in there before having a crack at multi-category
I haven't looked too closely at the code, but https://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html seems to be easy way to support multi categories.
although I guess the code already supports multi-category; just need to update the functions to calculate similar to below: https://stackoverflow.com/questions/50666091/true-positive-rate-and-false-positive-rate-tpr-fpr-for-multi-class-data-in-py
@dichotomous_only
def threat_score(self, yes_category=2):
"""Returns the threat score(s) for dichotomous contingency data.
.. math::
TS = \\frac{hits}{hits + misses + \\mathrm{false~alarms}}
Parameters
----------
yes_category : value, optional
The category coordinate value of the category corresponding to 'yes'
Returns
-------
xarray.Dataset or xarray.DataArray
An array containing the threat score(s)
References
----------
https://www.cawcr.gov.au/projects/verification/#Contingency_table
"""
return self.hits(yes_category) / (
self.hits(yes_category)
+ self.misses(yes_category)
+ self.false_alarms(yes_category)
)
moved to https://github.com/xarray-contrib/xskillscore/issues/284 leaving open
If I'm not mistaken, I think threat scores can be non-dichotomous? Is this decorator used only because it hasn't been implemented yet or am I mistaken?