Maharshi Gor
commited on
Commit
·
7df57c5
1
Parent(s):
f064c62
Fixed plotting issue
Browse files
src/components/quizbowl/plotting.py
CHANGED
@@ -169,7 +169,8 @@ def create_tossup_confidence_pyplot(
|
|
169 |
logprobs = [o["logprob"] for o in run_outputs if o["logprob"] is not None]
|
170 |
y_prob = [0] + [np.exp(v) for v in logprobs]
|
171 |
|
172 |
-
|
|
|
173 |
ax.plot(x, y_conf, "o-", color="#4996de", label="Confidence")
|
174 |
for o in run_outputs:
|
175 |
if not o["buzz"]:
|
@@ -178,9 +179,10 @@ def create_tossup_confidence_pyplot(
|
|
178 |
conf = o["confidence"]
|
179 |
i = o["token_position"]
|
180 |
ax.plot(i, conf, "o", color=color, markerfacecolor="none", markersize=12, markeredgewidth=2.5)
|
181 |
-
if o["logprob"] is not None:
|
182 |
prob = np.exp(o["logprob"])
|
183 |
-
|
|
|
184 |
if i > len(tokens):
|
185 |
print(f"1-indexed token index {i} is out of bounds for n_tokens: {len(tokens)}")
|
186 |
ax.annotate(f"{tokens[i - 1]}", (i, conf), textcoords="offset points", xytext=(0, 10), ha="center")
|
|
|
169 |
logprobs = [o["logprob"] for o in run_outputs if o["logprob"] is not None]
|
170 |
y_prob = [0] + [np.exp(v) for v in logprobs]
|
171 |
|
172 |
+
if prob_threshold is not None:
|
173 |
+
ax.plot(x, y_prob, "o-", color="#f2b150", label="Probability")
|
174 |
ax.plot(x, y_conf, "o-", color="#4996de", label="Confidence")
|
175 |
for o in run_outputs:
|
176 |
if not o["buzz"]:
|
|
|
179 |
conf = o["confidence"]
|
180 |
i = o["token_position"]
|
181 |
ax.plot(i, conf, "o", color=color, markerfacecolor="none", markersize=12, markeredgewidth=2.5)
|
182 |
+
if o["logprob"] is not None and prob_threshold is not None:
|
183 |
prob = np.exp(o["logprob"])
|
184 |
+
if prob > prob_threshold:
|
185 |
+
ax.plot(i, prob, "o", color=color, markerfacecolor="none", markersize=12, markeredgewidth=2.5)
|
186 |
if i > len(tokens):
|
187 |
print(f"1-indexed token index {i} is out of bounds for n_tokens: {len(tokens)}")
|
188 |
ax.annotate(f"{tokens[i - 1]}", (i, conf), textcoords="offset points", xytext=(0, 10), ha="center")
|