Update index.html
Browse files- index.html +29 -32
index.html
CHANGED
@@ -143,84 +143,82 @@
|
|
143 |
<section class="section">
|
144 |
<div class="container is-max-desktop">
|
145 |
<div class="columns is-centered">
|
146 |
-
<!-- Table and Filters Section -->
|
147 |
<div class="column">
|
148 |
<div class="content">
|
149 |
<h2 class="title is-3">Filtered Dataset Table</h2>
|
150 |
<p>
|
151 |
-
Use the filters below to
|
152 |
</p>
|
153 |
<!-- Filters -->
|
154 |
<div class="filters">
|
155 |
<label for="task">Task:</label>
|
156 |
<select id="task" onchange="updateTable()">
|
157 |
<option value="binary_classification">Binary Classification</option>
|
158 |
-
<!-- Add more task options if needed -->
|
159 |
</select>
|
160 |
<label for="stage">Stage:</label>
|
161 |
<select id="stage" onchange="updateTable()">
|
162 |
<option value="preprocessing">Preprocessing</option>
|
163 |
-
<!-- Add more stage options if needed -->
|
164 |
</select>
|
165 |
</div>
|
166 |
-
<!--/ Filters -->
|
167 |
|
168 |
<!-- Table -->
|
169 |
<table id="datasetTable" class="table is-striped">
|
170 |
<thead>
|
171 |
-
<tr id="tableHeader">
|
172 |
-
<!-- Table headers will be dynamically populated -->
|
173 |
-
</tr>
|
174 |
</thead>
|
175 |
-
<tbody id="tableBody">
|
176 |
-
<!-- Table rows will be dynamically populated -->
|
177 |
-
</tbody>
|
178 |
</table>
|
179 |
-
<!--/ Table -->
|
180 |
</div>
|
181 |
</div>
|
182 |
</div>
|
183 |
</div>
|
184 |
</section>
|
185 |
|
|
|
186 |
<script>
|
187 |
async function fetchDataset(task, stage) {
|
188 |
-
// Create URL based on the selected task and stage
|
189 |
const datasetURL = `https://huggingface.co/datasets/holistic-ai/bias_mitigation_benchmark/resolve/main/benchmark_${task}_${stage}.csv`;
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
198 |
|
199 |
async function updateTable() {
|
200 |
const task = document.getElementById('task').value;
|
201 |
const stage = document.getElementById('stage').value;
|
202 |
-
|
203 |
-
// Fetch dataset based on current filter values
|
204 |
const dataset = await fetchDataset(task, stage);
|
205 |
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
const tableHeader = document.getElementById('tableHeader');
|
208 |
-
tableHeader.innerHTML =
|
209 |
-
|
210 |
-
headers.forEach(column => {
|
211 |
const th = document.createElement('th');
|
212 |
-
th.textContent =
|
213 |
tableHeader.appendChild(th);
|
214 |
});
|
215 |
|
216 |
-
// Populate table rows
|
217 |
const tableBody = document.getElementById('tableBody');
|
218 |
-
tableBody.innerHTML =
|
219 |
dataset.forEach(row => {
|
220 |
const tr = document.createElement('tr');
|
221 |
-
headers.forEach(
|
222 |
const td = document.createElement('td');
|
223 |
-
td.textContent = row[
|
224 |
tr.appendChild(td);
|
225 |
});
|
226 |
tableBody.appendChild(tr);
|
@@ -228,7 +226,6 @@
|
|
228 |
}
|
229 |
</script>
|
230 |
|
231 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
|
232 |
|
233 |
|
234 |
|
|
|
143 |
<section class="section">
|
144 |
<div class="container is-max-desktop">
|
145 |
<div class="columns is-centered">
|
|
|
146 |
<div class="column">
|
147 |
<div class="content">
|
148 |
<h2 class="title is-3">Filtered Dataset Table</h2>
|
149 |
<p>
|
150 |
+
Use the filters below to load the dataset based on task and stage.
|
151 |
</p>
|
152 |
<!-- Filters -->
|
153 |
<div class="filters">
|
154 |
<label for="task">Task:</label>
|
155 |
<select id="task" onchange="updateTable()">
|
156 |
<option value="binary_classification">Binary Classification</option>
|
|
|
157 |
</select>
|
158 |
<label for="stage">Stage:</label>
|
159 |
<select id="stage" onchange="updateTable()">
|
160 |
<option value="preprocessing">Preprocessing</option>
|
|
|
161 |
</select>
|
162 |
</div>
|
|
|
163 |
|
164 |
<!-- Table -->
|
165 |
<table id="datasetTable" class="table is-striped">
|
166 |
<thead>
|
167 |
+
<tr id="tableHeader"></tr>
|
|
|
|
|
168 |
</thead>
|
169 |
+
<tbody id="tableBody"></tbody>
|
|
|
|
|
170 |
</table>
|
|
|
171 |
</div>
|
172 |
</div>
|
173 |
</div>
|
174 |
</div>
|
175 |
</section>
|
176 |
|
177 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
|
178 |
<script>
|
179 |
async function fetchDataset(task, stage) {
|
|
|
180 |
const datasetURL = `https://huggingface.co/datasets/holistic-ai/bias_mitigation_benchmark/resolve/main/benchmark_${task}_${stage}.csv`;
|
181 |
+
try {
|
182 |
+
const response = await fetch(datasetURL);
|
183 |
+
if (!response.ok) {
|
184 |
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
185 |
+
}
|
186 |
+
const text = await response.text();
|
187 |
+
return Papa.parse(text, { header: true }).data;
|
188 |
+
} catch (error) {
|
189 |
+
console.error("Failed to fetch dataset:", error);
|
190 |
+
alert("Failed to load dataset. Please check the console for details.");
|
191 |
+
return [];
|
192 |
+
}
|
193 |
}
|
194 |
|
195 |
async function updateTable() {
|
196 |
const task = document.getElementById('task').value;
|
197 |
const stage = document.getElementById('stage').value;
|
|
|
|
|
198 |
const dataset = await fetchDataset(task, stage);
|
199 |
|
200 |
+
if (dataset.length === 0) {
|
201 |
+
document.getElementById('tableHeader').innerHTML = "<th>No data available</th>";
|
202 |
+
document.getElementById('tableBody').innerHTML = "<tr><td>No data</td></tr>";
|
203 |
+
return;
|
204 |
+
}
|
205 |
+
|
206 |
+
const headers = Object.keys(dataset[0]);
|
207 |
const tableHeader = document.getElementById('tableHeader');
|
208 |
+
tableHeader.innerHTML = ""; // Clear existing headers
|
209 |
+
headers.forEach(header => {
|
|
|
210 |
const th = document.createElement('th');
|
211 |
+
th.textContent = header;
|
212 |
tableHeader.appendChild(th);
|
213 |
});
|
214 |
|
|
|
215 |
const tableBody = document.getElementById('tableBody');
|
216 |
+
tableBody.innerHTML = ""; // Clear existing rows
|
217 |
dataset.forEach(row => {
|
218 |
const tr = document.createElement('tr');
|
219 |
+
headers.forEach(header => {
|
220 |
const td = document.createElement('td');
|
221 |
+
td.textContent = row[header];
|
222 |
tr.appendChild(td);
|
223 |
});
|
224 |
tableBody.appendChild(tr);
|
|
|
226 |
}
|
227 |
</script>
|
228 |
|
|
|
229 |
|
230 |
|
231 |
|