Skip to content

Commit d47c2e6

Browse files
authored
Merge pull request #31 from NGO-Algorithm-Audit/feature/quick-wins
accordeon with diagnostic results and text tweaks
2 parents 6ab354a + 7cad5f0 commit d47c2e6

File tree

4 files changed

+50
-28
lines changed

4 files changed

+50
-28
lines changed

src/assets/synthetic-data.tsx

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -256,33 +256,22 @@ def run():
256256
{'reportType': 'univariateDistributionSyntheticData'},
257257
{'reportType': 'bivariateDistributionSyntheticData'},
258258
{'reportType': 'correlationSyntheticData'},
259-
259+
{
260+
'reportType': 'table',
261+
'titleKey': 'syntheticData.diagnosticsTitle',
262+
'showIndex' : False,
263+
'data': json.dumps([
264+
{
265+
'attribute': key,
266+
'ks_stat': values['ks_stat'],
267+
'p_value': values['p_value']
268+
}
269+
for key, values in results['distribution_results'].items()
270+
])
271+
}
260272
]
261273
}))
262274
263-
# setResult(json.dumps({
264-
# 'type': 'heatmap',
265-
# 'real': real_data.corr().to_json(orient="records"),
266-
# 'synthetic': synthetic_data.corr().to_json(orient="records")
267-
# }))
268-
269-
setResult(json.dumps(
270-
{
271-
'type': 'heading',
272-
'headingKey': 'syntheticData.diagnosticsTitle'
273-
}
274-
))
275-
setResult(json.dumps({'type': 'table',
276-
'showIndex' : False,
277-
'data': json.dumps([
278-
{
279-
'attribute': key,
280-
'ks_stat': values['ks_stat'],
281-
'p_value': values['p_value']
282-
}
283-
for key, values in results['distribution_results'].items()
284-
])}))
285-
286275
setResult(json.dumps(
287276
{
288277
'type': 'heading',

src/components/DistributionReport.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import { Accordion } from './ui/accordion';
99
import { createHeatmapdata } from './createHeatmapdata';
1010
import ViolinChart from './graphs/ViolinChart';
1111
import GroupBarChart from './graphs/GroupBarChart';
12+
import SimpleTable from './SimpleTable';
1213

1314
interface DistributionReport {
1415
reportType: string;
1516
headingKey?: string;
1617
textKey?: string;
1718
params?: Record<string, string | number | boolean>;
19+
data?: string;
20+
titleKey?: string;
21+
showIndex?: boolean;
1822
}
1923
export interface DistributionReportProps {
2024
dataTypes: string;
@@ -60,6 +64,35 @@ export const DistributionReport = (
6064
</Markdown>
6165
);
6266
}
67+
68+
if (report.reportType === 'table') {
69+
if (!report.data) {
70+
return null;
71+
}
72+
if (!report.titleKey) {
73+
return null;
74+
}
75+
76+
return (
77+
<div key={indexReport} className="mb-4">
78+
<Accordion
79+
title={t(report.titleKey)}
80+
content={
81+
<div>
82+
<p>&nbsp;</p>
83+
<SimpleTable
84+
data={JSON.parse(report.data)}
85+
title={t(report.titleKey)}
86+
showIndex={
87+
report.showIndex ?? false
88+
}
89+
/>
90+
</div>
91+
}
92+
/>
93+
</div>
94+
);
95+
}
6396
if (
6497
report.reportType === 'univariateDistributionRealData'
6598
) {

src/locales/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@
139139
}
140140
},
141141
"heatmap": {
142-
"realdata": "Correlation matrix of real data",
143-
"syntheticdata": "Absolute difference in correlation matrix, i.e., |real data - synthetic data|"
142+
"realdata": "Correlation matrix of attached data",
143+
"syntheticdata": "Absolute difference in correlation matrix, i.e., |attached data - synthetic data|"
144144
},
145145
"distribution": {
146146
"distributionFor": "Distribution for",

src/locales/nl.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@
138138
}
139139
},
140140
"heatmap": {
141-
"realdata": "Correlatie matrix van echte data",
142-
"syntheticdata": "Absoluut verschil in correlation matrix, m.a.w., |echte data - synthetische data|"
141+
"realdata": "Correlatie matrix van gekoppelde data",
142+
"syntheticdata": "Absoluut verschil in correlation matrix, m.a.w., |gekoppelde data - synthetische data|"
143143
},
144144
"distribution": {
145145
"distributionFor": "Distributie voor",

0 commit comments

Comments
 (0)