Skip to content
Snippets Groups Projects
Commit 9ab23560 authored by v.gramlich1's avatar v.gramlich1
Browse files

Add gilbert skill score to PlotContingency

parent ba46ed22
Branches
No related tags found
1 merge request!302Draft: Resolve "Class-based Oversampling technique"
Pipeline #77512 passed
......@@ -33,7 +33,8 @@ class PlotContingency(AbstractPlotClass):
def __init__(self, station_names, file_path, comp_path, file_name, plot_folder: str = ".", model_name: str = "nn",
model_plot_name: str = "nn", obs_name: str = "obs", comp_names: str = "IntelliO3",
plot_names=["contingency_threat_score", "contingency_hit_rate", "contingency_false_alarm_rate",
plot_names=["contingency_gilbert_skill_score", "contingency_threat_score", "contingency_hit_rate",
"contingency_false_alarm_rate",
"contingency_bias", "contingency_all_scores", "contingency_table"]):
super().__init__(plot_folder, plot_names[0])
......@@ -50,10 +51,12 @@ class PlotContingency(AbstractPlotClass):
self._plot_names = plot_names
self._min_threshold, self._max_threshold = self._min_max_threshold()
contingency_array = self._calculate_contingencies()
self._scores = ["ts", "h", "f", "b"]
self._scores = ["gss", "ts", "h", "f", "b"]
score_array = self._calculate_all_scores(contingency_array)
self._plot_counter = 0
self._plot(score_array, "gss")
self._save()
self._plot(score_array, "ts")
self._save()
self._plot(score_array, "h")
......@@ -213,6 +216,14 @@ class PlotContingency(AbstractPlotClass):
false_above = contingency[1]
false_below = contingency[2]
true_below = contingency[3]
if score == "gss":
frequency_above_threshold = (true_above + false_below)/(true_above + false_above + false_below + true_below)
forecasts_above_threshold = true_above + false_above
chance_hits = frequency_above_threshold*forecasts_above_threshold
if (true_above + false_above + false_below - chance_hits) == 0:
score_value = 1
else:
score_value = (true_above - chance_hits)/(true_above + false_above + false_below - chance_hits)
if score == "ts":
if (true_above + false_above + false_below) == 0:
score_value = 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment