William Arnold commited on
Commit ·
68fbfdf
1
Parent(s): a5d201c
Add vertical lines to score plots
Browse files- src/rbeval/dash.py +1 -1
- src/rbeval/plot/score_cdf.py +9 -19
src/rbeval/dash.py
CHANGED
|
@@ -83,7 +83,7 @@ def main():
|
|
| 83 |
for fig in plot_with_data(cdf, data, renormed)
|
| 84 |
]
|
| 85 |
for fig in figs:
|
| 86 |
-
st.altair_chart(fig.chart) # type: ignore
|
| 87 |
|
| 88 |
model_names = set(
|
| 89 |
[
|
|
|
|
| 83 |
for fig in plot_with_data(cdf, data, renormed)
|
| 84 |
]
|
| 85 |
for fig in figs:
|
| 86 |
+
st.altair_chart(fig.chart, use_container_width=True) # type: ignore
|
| 87 |
|
| 88 |
model_names = set(
|
| 89 |
[
|
src/rbeval/plot/score_cdf.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from dataclasses import dataclass, field
|
| 2 |
-
from typing import List
|
| 3 |
|
| 4 |
from numpy._typing import NDArray
|
| 5 |
from rbeval.plot.data import Eval, EvalGroup, Figure
|
|
@@ -74,19 +74,20 @@ def plot_with_data(
|
|
| 74 |
.encode(
|
| 75 |
x=alt.X("x:Q", title=cfg.xlabel),
|
| 76 |
y=alt.Y("y:Q", title=cfg.ylabel),
|
| 77 |
-
color=alt.Color("label:N", legend=alt.Legend(symbolOpacity=1.0)),
|
| 78 |
opacity=alt.condition( # type: ignore
|
| 79 |
label_selection & fs_selection,
|
| 80 |
alt.Opacity("fewshot:O"),
|
| 81 |
alt.value(0.0), # type: ignore
|
| 82 |
),
|
| 83 |
)
|
| 84 |
-
.properties(title=cfg.title(group_name, renorm)
|
| 85 |
-
.resolve_legend(color="independent")
|
| 86 |
-
.resolve_axis(y="independent", x="independent")
|
| 87 |
.add_params(fs_selection, label_selection)
|
| 88 |
.interactive()
|
| 89 |
)
|
|
|
|
|
|
|
|
|
|
| 90 |
figures.append(
|
| 91 |
Figure(name=f"{group_name} {cfg.name}", chart=chart, group=group_name)
|
| 92 |
)
|
|
@@ -99,6 +100,7 @@ class CdfPlotConfig(ABC):
|
|
| 99 |
xlabel: str
|
| 100 |
ylabel: str
|
| 101 |
name: str = ""
|
|
|
|
| 102 |
|
| 103 |
@abstractmethod
|
| 104 |
def get_cdf(self, evals: List[Eval], prob_renorm: bool) -> "CdfData":
|
|
@@ -117,6 +119,7 @@ class CdfPlotConfig(ABC):
|
|
| 117 |
|
| 118 |
class CorrectProbCdfPlot(CdfPlotConfig):
|
| 119 |
name = "Correct Prob Perf Curve"
|
|
|
|
| 120 |
|
| 121 |
def __init__(self):
|
| 122 |
self.plot_type = "corr perf plot"
|
|
@@ -129,16 +132,10 @@ class CorrectProbCdfPlot(CdfPlotConfig):
|
|
| 129 |
samples = [renormed(e)[0] for e in evals]
|
| 130 |
return CdfData.from_samples(samples)
|
| 131 |
|
| 132 |
-
def marks(self) -> alt.Chart:
|
| 133 |
-
return (
|
| 134 |
-
alt.Chart(pd.DataFrame({"x": [0.25]})) # type: ignore
|
| 135 |
-
.mark_rule()
|
| 136 |
-
.encode(x="x:Q", color=alt.value("red")) # type: ignore
|
| 137 |
-
)
|
| 138 |
-
|
| 139 |
|
| 140 |
class CorrIncorrDiffConfig(CdfPlotConfig):
|
| 141 |
name = "Corr-Incorr Gap Perf Curve"
|
|
|
|
| 142 |
|
| 143 |
def __init__(self):
|
| 144 |
self.plot_type = "corr-max(incor) perf plot"
|
|
@@ -157,10 +154,3 @@ class CorrIncorrDiffConfig(CdfPlotConfig):
|
|
| 157 |
score_arrs.append(cor_probs - inc_probs.max(axis=1))
|
| 158 |
|
| 159 |
return CdfData.from_samples(score_arrs, per_sample_weighting=True)
|
| 160 |
-
|
| 161 |
-
def marks(self) -> alt.Chart:
|
| 162 |
-
return (
|
| 163 |
-
alt.Chart(pd.DataFrame({"x": [0.5]})) # type: ignore
|
| 164 |
-
.mark_rule()
|
| 165 |
-
.encode(x="x:Q", color=alt.value("red")) # type: ignore
|
| 166 |
-
)
|
|
|
|
| 1 |
from dataclasses import dataclass, field
|
| 2 |
+
from typing import List, Optional
|
| 3 |
|
| 4 |
from numpy._typing import NDArray
|
| 5 |
from rbeval.plot.data import Eval, EvalGroup, Figure
|
|
|
|
| 74 |
.encode(
|
| 75 |
x=alt.X("x:Q", title=cfg.xlabel),
|
| 76 |
y=alt.Y("y:Q", title=cfg.ylabel),
|
| 77 |
+
color=alt.Color("label:N", legend=alt.Legend(symbolOpacity=1.0, labelLimit=1000)).scale(scheme="set1"),
|
| 78 |
opacity=alt.condition( # type: ignore
|
| 79 |
label_selection & fs_selection,
|
| 80 |
alt.Opacity("fewshot:O"),
|
| 81 |
alt.value(0.0), # type: ignore
|
| 82 |
),
|
| 83 |
)
|
| 84 |
+
.properties(title=cfg.title(group_name, renorm))
|
|
|
|
|
|
|
| 85 |
.add_params(fs_selection, label_selection)
|
| 86 |
.interactive()
|
| 87 |
)
|
| 88 |
+
if cfg.xline is not None:
|
| 89 |
+
line = alt.Chart(pd.DataFrame({'x': [cfg.xline]})).mark_rule().encode(x='x')
|
| 90 |
+
chart = chart + line # type: ignore
|
| 91 |
figures.append(
|
| 92 |
Figure(name=f"{group_name} {cfg.name}", chart=chart, group=group_name)
|
| 93 |
)
|
|
|
|
| 100 |
xlabel: str
|
| 101 |
ylabel: str
|
| 102 |
name: str = ""
|
| 103 |
+
xline: Optional[float] = None
|
| 104 |
|
| 105 |
@abstractmethod
|
| 106 |
def get_cdf(self, evals: List[Eval], prob_renorm: bool) -> "CdfData":
|
|
|
|
| 119 |
|
| 120 |
class CorrectProbCdfPlot(CdfPlotConfig):
|
| 121 |
name = "Correct Prob Perf Curve"
|
| 122 |
+
xline = 0.25
|
| 123 |
|
| 124 |
def __init__(self):
|
| 125 |
self.plot_type = "corr perf plot"
|
|
|
|
| 132 |
samples = [renormed(e)[0] for e in evals]
|
| 133 |
return CdfData.from_samples(samples)
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
class CorrIncorrDiffConfig(CdfPlotConfig):
|
| 137 |
name = "Corr-Incorr Gap Perf Curve"
|
| 138 |
+
xline = 0.0
|
| 139 |
|
| 140 |
def __init__(self):
|
| 141 |
self.plot_type = "corr-max(incor) perf plot"
|
|
|
|
| 154 |
score_arrs.append(cor_probs - inc_probs.max(axis=1))
|
| 155 |
|
| 156 |
return CdfData.from_samples(score_arrs, per_sample_weighting=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|