Skip to content

Commit 68d3cf5

Browse files
authored
Merge pull request #93 from NGO-Algorithm-Audit/feature/sdg-tweaks-9jun
Feature/sdg tweaks 9jun
2 parents 698ea45 + 9dae748 commit 68d3cf5

File tree

8 files changed

+76
-37
lines changed

8 files changed

+76
-37
lines changed

src/assets/synthetic-data.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,13 @@ def run():
264264
'reportType': 'table',
265265
'titleKey': 'syntheticData.handlingMissingDataTableTitle',
266266
'showIndex' : False,
267-
'data': missingness_dict_df.to_json(orient="records"),
267+
'data': missingness_dict_df.to_json(orient="records"),
268+
'noTableBelowTable': True
268269
},
269270
{
270271
'reportType': 'text',
271-
'textKey': 'syntheticData.missingData'
272+
'textKey': 'syntheticData.missingData',
273+
'noHTML': True
272274
},
273275
{
274276
'reportType': 'heading',
@@ -341,12 +343,20 @@ def run():
341343
'headingKey': 'syntheticData.outputDataTitle'
342344
}))
343345
346+
setResult(json.dumps({
347+
'type': 'text',
348+
'key': 'syntheticData.outputDataDescription'
349+
}))
350+
344351
setResult(json.dumps({
345352
'type': 'table',
346353
'showIndex': True,
347354
'data': synthetic_data.head().to_json(orient="records")
348355
}))
349356
357+
setResult(json.dumps({
358+
'type': 'export-button',
359+
}))
350360
351361
setResult(json.dumps({
352362
'type': 'heading',

src/components/DistributionReport.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ interface DistributionReport {
7373
showIndex?: boolean;
7474
preContent?: string;
7575
postContent?: string;
76+
noTableBelowTable?: boolean;
77+
noHTML?: boolean;
7678
}
7779
export interface DistributionReportProps {
7880
dataTypes: string;
@@ -124,6 +126,7 @@ export const DistributionReport = (
124126
<MarkdownWithTooltips
125127
key={indexReport}
126128
className="-mt-2 text-gray-800 markdown"
129+
noHTML={report.noHTML ?? false}
127130
>
128131
{t(report.textKey, report.params)}
129132
</MarkdownWithTooltips>
@@ -179,6 +182,9 @@ export const DistributionReport = (
179182
showIndex={
180183
report.showIndex ?? false
181184
}
185+
noTableBelowTable={
186+
report.noTableBelowTable
187+
}
182188
/>
183189
{report.postContent &&
184190
postContent.map(

src/components/MarkdownWithTooltips.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import rehypeRaw from 'rehype-raw';
99
interface MarkdownWithTooltipsProps {
1010
children: string;
1111
className?: string;
12+
noHTML?: boolean;
1213
}
1314

1415
interface CustomElementData extends ElementData {
@@ -24,12 +25,16 @@ interface CustomElement extends Element {
2425
export function MarkdownWithTooltips({
2526
children,
2627
className,
28+
noHTML,
2729
}: MarkdownWithTooltipsProps) {
30+
const rehypePlugins = noHTML
31+
? [rehypeInfoTooltip]
32+
: [rehypeRaw, rehypeInfoTooltip];
2833
return (
2934
<Markdown
3035
className={className}
3136
remarkPlugins={[remarkInfoTooltip, remarkGfm]}
32-
rehypePlugins={[rehypeRaw, rehypeInfoTooltip]}
37+
rehypePlugins={rehypePlugins}
3338
components={{
3439
// @ts-expect-error - math is a custom components
3540
TooltipWrapper,

src/components/SimpleTable.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ export default function SimpleTable({
1414
data,
1515
showIndex,
1616
translate,
17+
noTableBelowTable,
1718
}: {
1819
showIndex: boolean;
1920
title?: string;
2021
data: Record<string, string | number>[];
2122
translate?: boolean;
23+
noTableBelowTable?: boolean;
2224
}) {
2325
const { t } = useTranslation();
2426
// limit data to the first 100 rows.
@@ -27,7 +29,9 @@ export default function SimpleTable({
2729
return (
2830
<div className={`bg-white border border-gray-200 ${title && 'mb-4'}`}>
2931
<Table className={`text-xs ${title && 'mb-4'}`}>
30-
{title && <TableCaption>{t(title)}</TableCaption>}
32+
{!noTableBelowTable && title && (
33+
<TableCaption>{t(title)}</TableCaption>
34+
)}
3135
<TableHeader>
3236
<TableRow className="bg-aaLight">
3337
{showIndex && <TableHead></TableHead>}

src/components/SyntheticDataSettings.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
TooltipContent,
2121
} from './ui/touch-tooltip';
2222
import Markdown from 'react-markdown';
23+
import { IconInfoTooltip } from './ui/info-icon-tooltip';
2324

2425
const createFormSchema = (t: (key: string) => string) =>
2526
z.object({
@@ -133,7 +134,16 @@ export default function SyntheticDataSettings({
133134
<legend className="-ml-1 px-1 text-sm font-medium">
134135
{t('syntheticData.form.fieldset.sourceDataset')}
135136
</legend>
136-
<div className="grid gap-3">
137+
<div className="relative grid gap-3 select-none">
138+
<div className="flex flex-row items-center gap-1 absolute -top-[10px] leading-0 left-4 px-1 bg-white text-sm font-medium">
139+
{t('syntheticData.form.fieldset.dataSet')}
140+
141+
<IconInfoTooltip
142+
tooltipText={t(
143+
'syntheticData.form.fieldset.dataSetTooltip'
144+
)}
145+
/>
146+
</div>
137147
<FormField
138148
control={form.control}
139149
name="file"

src/locales/en.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ export const en = {
132132
},
133133
fieldset: {
134134
sourceDataset: 'Input',
135+
dataSet: 'Dataset',
136+
dataSetTooltip: `Preprocess your data such that:
137+
- missing values are removed or replaced;
138+
- all columns (except your outcome label column) should have the same datatypes, e.g., numerical or categorical;
139+
- the outcome label column is numerical`,
135140
sdgMethod: {
136141
title: 'Method',
137142
cart: 'CART',
@@ -231,17 +236,17 @@ For classification (when the target is categorical):
231236
disclosureProtectionTitle: 'Privacy metrics',
232237
disclosureProtectionDescription: `The disclosure protection metric measures the proportion of synthetic data points that closely resemble real data points (within a predefined threshold), posing a risk of traceability to personal data. A low 'risk\_rate' and a high 'disclosure\_protection\_rate' indicate effective protection against the unintentional exposure of personal data.`,
233238
outputDataTitle: '5. Download synthetic data and evaluation report',
239+
outputDataDescription: 'Preview of generated synthetic data',
234240
moreInfoTitle: '6. More information',
235241
meanSquaredError:
236-
'Average squared difference between predicted and actual values, quantifying the accuracy of a model’s predictions by penalizing larger errors more heavily',
242+
'Average squared difference between predicted and actual values, quantifying the accuracy of a model’s predictions by penalizing larger errors more heavily',
237243
meanAbsoluteError:
238-
'Average magnitude of the errors between predicted and actual values, providing a straightforward assessment of model accuracy without emphasizing large errors',
239-
R2:
240-
'Quantifies how well a model’s predictions match the actual data by measuring the proportion of variance in the target variable explained by the model',
244+
'Average magnitude of the errors between predicted and actual values, providing a straightforward assessment of model accuracy without emphasizing large errors',
245+
R2: 'Quantifies how well a model’s predictions match the actual data by measuring the proportion of variance in the target variable explained by the model',
241246
accuracyScore:
242-
'Measures the proportion of correctly predicted instances out of the total instances, providing an overall assessment of a model’s performance in classification tasks',
247+
'Measures the proportion of correctly predicted instances out of the total instances, providing an overall assessment of a model’s performance in classification tasks',
243248
weightedF1Score:
244-
'Harmonic mean of precision and recall, calculated for each class and weighted by the class’s support (number of true instances), providing a balanced performance measure for imbalanced datasets',
249+
'Harmonic mean of precision and recall, calculated for each class and weighted by the class’s support (number of true instances), providing a balanced performance measure for imbalanced datasets',
245250
correlationDifference:
246251
'Correlation difference: {{correlationDifference}}',
247252
univariateText:

src/locales/nl.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ export const nl = {
132132
},
133133
fieldset: {
134134
sourceDataset: 'Input',
135+
dataSet: 'Dataset',
136+
dataSetTooltip: `Bereid je data voor zodat:
137+
- missende waarden zijn verwijderd of vervangen;
138+
- alle kolommen (behalve de uitkomstlabel-kolom) dezelfde datatypes hebben, numeriek of categorisch;
139+
- de uitkomstlabel-kolom numeriek is`,
135140
sdgMethod: {
136141
title: 'Methode',
137142
cart: 'CART',
@@ -190,17 +195,17 @@ export const nl = {
190195
disclosureProtectionTitle: 'Privacy metrieken',
191196
disclosureProtectionDescription: `De onthullings beschermings metriek meet het aandeel synthetische datapunten die te veel lijkt op echte datapunten (binnen een vooraf gedefinieerde drempelwaarde), wat een risico op herleidbaarheid naar persoonsgegevens vormt. Een lage 'risk_rate' en hoge 'disclosure_protection_rate' duidt op een goede bescherming tegen het onbedoeld prijsgeven van persoonsgegevens.`,
192197
outputDataTitle: '5. Download synthetische data en evaluatierapport',
198+
outputDataDescription: 'Preview van gegenereerde synthetische data',
193199
moreInfoTitle: '6. Meer informatie',
194200
meanSquaredError:
195-
'Gemiddeld kwadraatverschil tussen voorspelde en werkelijke waarden, dat de nauwkeurigheid van de voorspellingen van een model kwantificeert door grotere fouten zwaarder te bestraffen',
201+
'Gemiddeld kwadraatverschil tussen voorspelde en werkelijke waarden, dat de nauwkeurigheid van de voorspellingen van een model kwantificeert door grotere fouten zwaarder te bestraffen',
196202
meanAbsoluteError:
197-
'Gemiddelde grootte van de fouten tussen voorspelde en werkelijke waarden, die een eenvoudige beoordeling van de nauwkeurigheid van het model biedt zonder de nadruk te leggen op grote fouten',
198-
R2:
199-
'Kwantificeert hoe goed de voorspellingen van een model overeenkomen met de werkelijke gegevens door het aandeel van de variantie in de doelvariabele te meten dat door het model wordt verklaard',
203+
'Gemiddelde grootte van de fouten tussen voorspelde en werkelijke waarden, die een eenvoudige beoordeling van de nauwkeurigheid van het model biedt zonder de nadruk te leggen op grote fouten',
204+
R2: 'Kwantificeert hoe goed de voorspellingen van een model overeenkomen met de werkelijke gegevens door het aandeel van de variantie in de doelvariabele te meten dat door het model wordt verklaard',
200205
accuracyScore:
201-
'Meet het aandeel correct voorspelde gevallen ten opzichte van het totaal, en geeft zo een algemene beoordeling van de prestaties van het classificatiemodel',
206+
'Meet het aandeel correct voorspelde gevallen ten opzichte van het totaal, en geeft zo een algemene beoordeling van de prestaties van het classificatiemodel',
202207
weightedF1Score:
203-
'Het harmonisch gemiddelde van precisie en recall, berekend per klasse en gewogen naar het aantal echte gevallen per klasse, wat een metriek biedt voor datasets met ongelijke klassenverdeling',
208+
'Het harmonisch gemiddelde van precisie en recall, berekend per klasse en gewogen naar het aantal echte gevallen per klasse, wat een metriek biedt voor datasets met ongelijke klassenverdeling',
204209
correlationDifference: 'Correlatie verschil: {{correlationDifference}}',
205210
moreInfo:
206211
'&nbsp;&nbsp;\n \n \n \nWil je meer weten over synthetische data?\n \n \n \n- [python-synthpop op Github](https://github.com/NGO-Algorithm-Audit/python-synthpop)\n- [local-first web app op Github](https://github.com/NGO-Algorithm-Audit/local-first-web-tool/tree/main)\n- [Synthetische Data: wat, waarom en hoe?](https://royalsociety.org/-/media/policy/projects/privacy-enhancing-technologies/Synthetic_Data_Survey-24.pdf)\n- [Kennis Netwerk Synthetische Data](https://online.rijksinnovatiecommunity.nl/groups/399-kennisnetwerk-synthetischedata/welcome) (Nederlandse organisaties)\n- [Synthetische data portaal van DUO](https://duo.nl/open_onderwijsdata/footer/synthetische-data.jsp)\n- [CART: synthpop resources](https://synthpop.org.uk/resources.html)\n- [Gaussian Copula - Synthetic Data Vault](https://docs.sdv.dev/sdv)',

src/routes/SyntheticData.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,22 @@ export default function SyntheticDataGeneration() {
161161
loading && 'overflow-hidden'
162162
)}
163163
>
164-
{initialised && data.data.length > 0 && result.length > 0 && (
165-
<ExportButton
166-
buttonAlign="right"
167-
clusterInfo={clusterInfo}
164+
{result.length > 0 ? (
165+
<ComponentMapper
166+
items={result}
168167
data={data}
169-
handleExport={handleExport}
170-
reactToPrintFn={reactToPrintFn}
168+
exportButton={
169+
<div className="flex flex-row gap-2 hideonprint justify-start">
170+
<ExportButton
171+
buttonAlign={'left'}
172+
clusterInfo={clusterInfo}
173+
reactToPrintFn={reactToPrintFn}
174+
data={data}
175+
handleExport={handleExport}
176+
/>
177+
</div>
178+
}
171179
/>
172-
)}
173-
174-
{result.length > 0 ? (
175-
<ComponentMapper items={result} data={data} />
176180
) : loading ? (
177181
<LoadingState
178182
loadingMessageKey={loadingMessage}
@@ -189,16 +193,6 @@ export default function SyntheticDataGeneration() {
189193
<div className="flex-1" />
190194
</>
191195
)}
192-
193-
{initialised && data.data.length > 0 && result.length > 0 && (
194-
<ExportButton
195-
buttonAlign="center"
196-
clusterInfo={clusterInfo}
197-
data={data}
198-
handleExport={handleExport}
199-
reactToPrintFn={reactToPrintFn}
200-
/>
201-
)}
202196
</div>
203197
</main>
204198
);

0 commit comments

Comments
 (0)