forked from yakew7/Fair-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofiler.html
More file actions
258 lines (243 loc) · 12.1 KB
/
Copy pathprofiler.html
File metadata and controls
258 lines (243 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fair Code - Open Dataset Profiler</title>
<meta name="description" content="Drop in any tabular CSV and get an instant demographic representation audit - missing subgroups, skewed age/sex distributions, geographic under-sampling. Runs entirely in your browser; your file never leaves your machine.">
<meta property="og:title" content="Fair Code - Open Dataset Profiler">
<meta property="og:description" content="Audit any dataset for demographic imbalance in seconds. 100% client-side - your data never leaves your browser.">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Fair Code - Open Dataset Profiler">
<meta name="twitter:description" content="Audit any CSV for demographic imbalance - instantly, privately, in your browser.">
<link rel="canonical" href="https://www.thefaircode.xyz/profiler.html">
<meta property="og:url" content="https://www.thefaircode.xyz/profiler.html">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><rect width='100' height='100' fill='%23f4f1e8'/><circle cx='50' cy='50' r='14' fill='%23a63a22'/></svg>">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Archivo:wght@400;500;600;700&family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&display=swap" rel="stylesheet">
<script>
(function () {
var saved = localStorage.getItem('fc-theme') || 'light';
document.documentElement.setAttribute('data-theme', saved);
})();
</script>
<style>
/* "The Audit Ledger" design tokens - shared with index.html / explainer.html */
:root {
--bg: #f4f1e8;
--surface: #ebe7d9;
--border: #d9d3c0;
--border2: #bdb59c;
--accent: #a63a22;
--accent3: #2f6b4f;
--text: #36321f;
--muted: #7d7459;
--white: #1d1910;
--bias-track-bg: #e2dcc9;
--warn: #7a5b17; /* grade C: darkened from the brand gold to clear 4.5:1 on --surface */
--serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
--sans: 'Archivo', 'Helvetica Neue', sans-serif;
--mono: 'IBM Plex Mono', 'SF Mono', monospace;
}
html[data-theme="dark"] {
--bg: #15130d;
--surface: #1c1912;
--border: #2e2a1f;
--border2: #443e2d;
--accent: #cf6f49;
--accent3: #79b294;
--text: #cfc7b0;
--muted: #8d8367;
--white: #f1e9d4;
--bias-track-bg: #242013;
--warn: #d4ac4a;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: var(--sans);
background: var(--bg);
color: var(--text);
-webkit-font-smoothing: antialiased;
transition: background 0.3s, color 0.3s;
}
a { color: inherit; }
::selection { background: var(--accent); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only {
position: absolute; width: 1px; height: 1px;
padding: 0; margin: -1px; overflow: hidden;
clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
* {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.001ms !important;
scroll-behavior: auto !important;
}
}
</style>
<link rel="stylesheet" href="assets/profiler.css">
<script>
window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
</script>
<script defer src="/_vercel/insights/script.js"></script>
<script>
window.si = window.si || function () { (window.siq = window.siq || []).push(arguments); };
</script>
<script defer src="/_vercel/speed-insights/script.js"></script>
<script defer src="https://cloud.umami.is/script.js" data-website-id="84e0aebf-44e1-466e-b2c6-62f75e1c36c7"></script>
</head>
<body class="profiler-page">
<main class="profiler-shell">
<div class="profiler-topbar">
<a class="profiler-back" href="index.html">← Back to Fair Code</a>
<div class="profiler-topbar-actions">
<a class="profiler-source" href="https://github.com/yakew7/Fair-Code" target="_blank" rel="noopener noreferrer">View source on GitHub</a>
<button class="profiler-theme-toggle" id="themeToggle" aria-label="Toggle theme">☀</button>
</div>
</div>
<section class="profiler-hero">
<div class="profiler-kicker">Research Tools</div>
<h1 class="profiler-headline">Open Dataset Profiler</h1>
<p class="profiler-lede">
Drop in any tabular CSV - health records, hiring data, loan applications - and get an
instant <strong>demographic representation audit</strong>: under-represented or missing
subgroups, skewed age and sex distributions, geographic under-sampling, and intersectional
gaps.
</p>
<p class="profiler-privacy">
<span class="lock" aria-hidden="true">🔒</span> Your file never leaves your browser. All analysis runs locally
on this page - nothing is uploaded.
</p>
</section>
<section class="dropzone" id="dropzone" tabindex="0" role="button"
aria-label="Upload a CSV or TSV file, or click to browse"
aria-describedby="dropzoneHint">
<input type="file" id="fileInput" accept=".csv,.tsv,text/csv,text/tab-separated-values" hidden>
<div class="dropzone-inner">
<div class="dropzone-icon" aria-hidden="true">⊕</div>
<p class="dropzone-title">Drop a CSV or TSV here, or <span class="link">browse</span></p>
<p class="dropzone-hint" id="dropzoneHint">Comma- or tab-separated values, with a header row. (Excel files:
use <code>faircode profile data.xlsx</code> from the CLI.)</p>
<button class="sample-btn" id="sampleBtn" type="button">Try it with a sample dataset</button>
</div>
</section>
<p class="profiler-error" id="error" role="alert" hidden></p>
<p class="sr-only" id="resultsAnnouncer" aria-live="polite" aria-atomic="true"></p>
<section class="results" id="results" hidden>
<div class="score-card">
<div class="score-ring" id="scoreRing">
<span class="score-num" id="scoreNum">–</span>
<span class="score-grade" id="scoreGrade"></span>
</div>
<div class="score-meta">
<h2 id="scoreFileName">Representation score</h2>
<p id="scoreSummary" class="score-summary"></p>
<p class="score-note">A balance-only score (0–100). Missing data, imbalance ratios and
intersectional gaps are listed as flags below, not folded into the number.</p>
</div>
</div>
<div class="results-actions">
<button class="action-btn" id="downloadHtmlBtn" type="button">⬇ Download report (HTML)</button>
<button class="action-btn" id="copyJsonBtn" type="button">⧉ Copy as JSON</button>
<button class="action-btn" id="referenceBtn" type="button">⚖ Score vs reference…</button>
<button class="action-btn" id="referenceClearBtn" type="button" hidden>✕ Clear reference</button>
<input type="file" id="referenceInput" accept=".csv,.tsv,text/csv,text/tab-separated-values" hidden>
<span class="reference-status" id="referenceStatus"></span>
</div>
<div class="flags-block" id="flagsBlock" hidden>
<h3><span aria-hidden="true">⚑</span> Flags <span class="count" id="flagCount"></span></h3>
<ul id="flagsList"></ul>
</div>
<details class="mapping-block" id="mappingBlock">
<summary class="mapping-summary">
<span class="section-title" style="margin:0">Column mapping</span>
<span class="mapping-hint">auto-detection missed a column? map it here</span>
</summary>
<p class="section-note">Detection keys off column names, so an oddly-named column
(<code>gndr</code>, <code>patient_region_code</code>) can be missed or mistyped. Override any
column below and the audit re-runs instantly — nothing leaves your browser.</p>
<div class="mapping-list" id="mappingList"></div>
</details>
<h3 class="section-title">Detected demographic dimensions</h3>
<div class="dimensions" id="dimensions"></div>
<div class="intersections-block" id="intersectionsBlock" hidden>
<h3 class="section-title">Intersectional gaps</h3>
<div class="cross-controls" id="crossControls">
<label>Cross
<select class="cross-select" id="crossA" aria-label="First intersection dimension"></select>
</label>
<span aria-hidden="true">×</span>
<label>
<select class="cross-select" id="crossB" aria-label="Second intersection dimension"></select>
</label>
</div>
<p class="section-note" id="intersectionNote"></p>
<div id="intersections"></div>
</div>
</section>
<!-- ── Compare two datasets: representation drift ─────────────────── -->
<section class="compare-block" aria-labelledby="compareHeading">
<h2 class="section-title" id="compareHeading">Compare two datasets — representation drift</h2>
<p class="section-note">
Profile a baseline against a later snapshot — training vs. production, last quarter vs. this
one — to see how each demographic dimension's representation shifted. Drift is measured with
the Population Stability Index (PSI). Both files stay in your browser.
</p>
<div class="compare-drops">
<div class="mini-drop" id="dropA" tabindex="0" role="button"
aria-label="Upload baseline dataset A (CSV or TSV)">
<input type="file" id="fileA" accept=".csv,.tsv,text/csv,text/tab-separated-values" hidden>
<span class="mini-drop-tag">A · Baseline</span>
<span class="mini-drop-name" id="nameA">Drop CSV/TSV, or <span class="link">browse</span></span>
</div>
<div class="mini-drop" id="dropB" tabindex="0" role="button"
aria-label="Upload current dataset B (CSV or TSV)">
<input type="file" id="fileB" accept=".csv,.tsv,text/csv,text/tab-separated-values" hidden>
<span class="mini-drop-tag">B · Current</span>
<span class="mini-drop-name" id="nameB">Drop CSV/TSV, or <span class="link">browse</span></span>
</div>
</div>
<div class="compare-actions">
<button class="sample-btn" id="compareSampleBtn" type="button">Try with sample drift data</button>
</div>
<p class="profiler-error" id="compareError" role="alert" hidden></p>
<p class="sr-only" id="compareAnnouncer" aria-live="polite" aria-atomic="true"></p>
<section class="compare-results" id="compareResults" hidden></section>
</section>
<footer class="profiler-foot">
<p>This is the web counterpart of the <code>faircode</code> CLI. Same analysis, same numbers -
run <code>faircode profile data.csv</code> locally for terminal, JSON, and HTML reports.
The Profiler is <strong>diagnostic</strong>: it audits a dataset's representation; it does not
train or fix models. See the
<a href="https://github.com/yakew7/Fair-Code">six bias audits</a> for the model side.</p>
</footer>
</main>
<script src="assets/profiler-engine.js"></script>
<script src="assets/profiler-ui.js"></script>
<script src="assets/profiler-compare.js"></script>
<script>
(function () {
var toggle = document.getElementById('themeToggle');
var html = document.documentElement;
function sync() {
var cur = html.getAttribute('data-theme') || 'light';
toggle.textContent = cur === 'light' ? '☾' : '☀';
toggle.setAttribute('aria-label', cur === 'light' ? 'Switch to dark mode' : 'Switch to light mode');
}
sync();
toggle.addEventListener('click', function () {
var next = (html.getAttribute('data-theme') || 'light') === 'dark' ? 'light' : 'dark';
html.setAttribute('data-theme', next);
localStorage.setItem('fc-theme', next);
sync();
});
})();
</script>
</body>
</html>