Spaces:
Runtime error
Runtime error
fix to nan patches in coloring of reliability diagram
Browse files- local_app.py +8 -6
local_app.py
CHANGED
@@ -98,11 +98,13 @@ def reliability_plot(results):
|
|
98 |
# DEV: nicer would be to plot like a polygon
|
99 |
# see: https://github.com/markus93/fit-on-the-test/blob/main/Experiments_Synthetic/binnings.py
|
100 |
|
101 |
-
def over_under_confidence(
|
102 |
colors = []
|
103 |
-
for j, bin in enumerate(
|
104 |
-
perfect =
|
105 |
-
|
|
|
|
|
106 |
|
107 |
bin_color = (
|
108 |
"limegreen"
|
@@ -123,10 +125,10 @@ def reliability_plot(results):
|
|
123 |
weights=np.nan_to_num(results["p_bar"][:-1], copy=True, nan=0),
|
124 |
bins=bins_with_left_edge,
|
125 |
)
|
126 |
-
colors = over_under_confidence(
|
127 |
for b in range(len(B)):
|
128 |
patches[b].set_facecolor(colors[b]) # color based on over/underconfidence
|
129 |
-
|
130 |
ax1handles = [
|
131 |
mpatches.Patch(color="orangered", label="Overconfident"),
|
132 |
mpatches.Patch(color="limegreen", label="Perfect", linestyle="dotted"),
|
|
|
98 |
# DEV: nicer would be to plot like a polygon
|
99 |
# see: https://github.com/markus93/fit-on-the-test/blob/main/Experiments_Synthetic/binnings.py
|
100 |
|
101 |
+
def over_under_confidence(bins, patches):
|
102 |
colors = []
|
103 |
+
for j, bin in enumerate(bins):
|
104 |
+
perfect = bin
|
105 |
+
if j == len(patches):
|
106 |
+
j = len(patches) -1
|
107 |
+
empirical = patches[j].get_height()
|
108 |
|
109 |
bin_color = (
|
110 |
"limegreen"
|
|
|
125 |
weights=np.nan_to_num(results["p_bar"][:-1], copy=True, nan=0),
|
126 |
bins=bins_with_left_edge,
|
127 |
)
|
128 |
+
colors = over_under_confidence(bins, patches)
|
129 |
for b in range(len(B)):
|
130 |
patches[b].set_facecolor(colors[b]) # color based on over/underconfidence
|
131 |
+
|
132 |
ax1handles = [
|
133 |
mpatches.Patch(color="orangered", label="Overconfident"),
|
134 |
mpatches.Patch(color="limegreen", label="Perfect", linestyle="dotted"),
|