Skip to content

Commit c2ac08e

Browse files
committed
confidence filter, css refactoring
1 parent 8a7f6d9 commit c2ac08e

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

src/App.jsx

+36-16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import './App.css';
66
function App() {
77
const [dataset, setDataset] = useState("classic_new");
88
const [searchPattern, setSearchPattern] = useState(null);
9+
const [maxConfidence, setMaxConfidence] = useState(1);
910
const [categories, setCategories] = useState([]);
1011
const [data, setData] = useState([]);
1112
const [siderVisible, setSiderVisible] = useState(false);
@@ -21,6 +22,15 @@ function App() {
2122
data = data.filter((item) => item.question.toLowerCase().includes(searchPattern) || item.generated_query.toLowerCase().includes(searchPattern));
2223
}
2324

25+
if (maxConfidence) {
26+
// check if the min of all rank_1_probs is less than maxConfidence
27+
data = data.filter((item) => {
28+
return item.logprobs.reduce((acc, item) => {
29+
return Math.min(acc, item.rank_1_prob);
30+
}, 1) <= maxConfidence;
31+
});
32+
}
33+
2434
const cats = [];
2535
data.forEach((item) => {
2636
if (!cats.includes(item.query_category)) {
@@ -53,17 +63,12 @@ function App() {
5363

5464
useEffect(() => {
5565
getData(dataset);
56-
}, [dataset, searchPattern]);
66+
}, [dataset, searchPattern, maxConfidence]);
5767

5868
return (
5969
<div className="App">
6070
<h1>Eval Visualizer</h1>
61-
<div style={{
62-
display: "flex",
63-
justifyContent: "space-between",
64-
alignItems: "center",
65-
padding: 10,
66-
}}>
71+
<div className="flex flex-padded">
6772
<div id="options">
6873
<h3>Eval Type</h3>
6974
<select
@@ -89,16 +94,36 @@ function App() {
8994
style={{ width: 200 }}
9095
value={searchPattern}
9196
onChange={(ev) => {
92-
setSearchPattern(ev.target.value);
97+
setSearchPattern(ev.target.value.toLowerCase());
9398
}}
9499
/>
95100
</div>
101+
102+
<div id="slider-confidence">
103+
<h3>Min Top Prob Threshold</h3>
104+
<input
105+
type="range"
106+
min={0}
107+
max={1}
108+
step={0.01}
109+
value={maxConfidence}
110+
style={{ width: 200 }}
111+
onChange={(ev) => {
112+
setMaxConfidence(parseFloat(ev.target.value));
113+
}}
114+
/>
115+
<span>{maxConfidence}</span>
116+
</div>
96117
</div>
97118

98119
<div id="summary-statistics">
99120
<h3>Summary Statistics</h3>
100-
<p>Number of records: {data.length}</p>
101-
<p>Total Correct: {data.filter((item) => item.correct === 1).length} ({100*(data.filter((item) => item.correct === 1).length/data.length)})%</p>
121+
<div className="flex flex-padded">
122+
<p><b>Number of records</b>: {data.length}</p>
123+
<p><b>Total Correct</b>: {data.filter((item) => item.correct === 1).length} ({100*(data.filter((item) => item.correct === 1).length/data.length).toFixed(3)})%</p>
124+
<p><b>Total Incorrect</b>: {data.filter((item) => item.correct === 0).length} ({100*(data.filter((item) => item.correct === 0).length/data.length).toFixed(3)})%</p>
125+
</div>
126+
102127
</div>
103128
<div id="charts">
104129
{categories.map((category) => {
@@ -114,12 +139,7 @@ function App() {
114139
</h4>
115140
<div
116141
key={category}
117-
style={{
118-
display: "flex",
119-
flexWrap: "wrap",
120-
width: "100%",
121-
maxWidth: 600,
122-
}}
142+
className="flex"
123143
>
124144
{data.filter((item) => item.query_category === category)
125145
.sort((item) => item.correct === 1 ? -1 : 1)

0 commit comments

Comments
 (0)