Skip to content

Commit ef057e1

Browse files
authored
Merge pull request #23 from NGO-Algorithm-Audit/feature/charts-in-accordeon-and-content
Feature/charts in accordeon and content
2 parents a49cafa + 0e2a6c1 commit ef057e1

File tree

7 files changed

+310
-97
lines changed

7 files changed

+310
-97
lines changed

src/assets/synthetic-data.tsx

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ def run():
129129
{'type': 'heading', 'data': sdgMethod}
130130
))
131131
if isDemo:
132-
setResult(json.dumps(
133-
{'type': 'heading', 'data': '''Demo'''}
134-
))
135-
setResult(json.dumps(
136-
{'type': 'text', 'data': '''A demo dataset is loaded below. We will now generate synthetic data on the columns: 'sex', 'race1', 'ugpa', 'bar'. We will be using the Gaussian Copula method and evaluate the distribution and correlation differences between the real and synthetic data.'''}
137-
))
132+
setResult(json.dumps({
133+
'type': 'heading',
134+
'headingKey': 'syntheticData.demo.heading'
135+
}))
136+
setResult(json.dumps({
137+
'type': 'text',
138+
'key': 'syntheticData.demo.description'
139+
}))
138140
139141
setResult(json.dumps(
140142
{'type': 'data-set-preview', 'data': ''}
@@ -147,6 +149,27 @@ def run():
147149
dtypes_dict['sex'] = 'category'
148150
real_data['sex'] = real_data['sex'].map({1: 'male', 2: 'female'})
149151
152+
setResult(json.dumps({
153+
'type': 'heading',
154+
'headingKey': 'syntheticData.columnsInDataset'
155+
}))
156+
dataInfo = []
157+
for column in real_data.columns:
158+
dataInfo.append({
159+
'key': column,
160+
'value': dtypes_dict[column]
161+
})
162+
163+
setResult(json.dumps({
164+
'type': 'list',
165+
'list': dataInfo
166+
}))
167+
168+
setResult(json.dumps({
169+
'type': 'text',
170+
'key': 'syntheticData.columnsInDatasetInfo'
171+
}))
172+
150173
cloned_real_data = real_data.copy()
151174
label_encoders = {}
152175
for column in real_data.select_dtypes(include=['object']).columns:
@@ -215,9 +238,24 @@ def run():
215238
# combined_data_encoded = pd.concat((df_encoded.assign(realOrSynthetic='real_encoded'), synth_df.assign(realOrSynthetic='synthetic')), keys=['real_encoded','synthetic'], names=['Data'])
216239
217240
# setResult(json.dumps({'type': 'distribution', 'real': real_data.to_json(orient="records"), 'synthetic': synthetic_data.to_json(orient="records"), 'dataTypes': json.dumps(dtypes_dict), 'combined_data' : combined_data.to_json(orient="records")}))
218-
setResult(json.dumps({'type': 'distribution', 'real': cloned_real_data.to_json(orient="records"), 'synthetic': synth_df_decoded.to_json(orient="records"), 'dataTypes': json.dumps(dtypes_dict), 'combined_data' : combined_data.to_json(orient="records")}))
219-
220-
setResult(json.dumps({'type': 'heatmap', 'real': real_data.corr().to_json(orient="records"), 'synthetic': synthetic_data.corr().to_json(orient="records")}))
241+
setResult(json.dumps({
242+
'type': 'distribution',
243+
'real': cloned_real_data.to_json(orient="records"),
244+
'synthetic': synth_df_decoded.to_json(orient="records"),
245+
'dataTypes': json.dumps(dtypes_dict),
246+
'combined_data' : combined_data.to_json(orient="records"),
247+
'realCorrelations': real_data.corr().to_json(orient="records"),
248+
'syntheticCorrelations': synthetic_data.corr().to_json(orient="records"),
249+
'reports' : [
250+
'univariate', 'distribution', 'correlation'
251+
]
252+
}))
253+
254+
# setResult(json.dumps({
255+
# 'type': 'heatmap',
256+
# 'real': real_data.corr().to_json(orient="records"),
257+
# 'synthetic': synthetic_data.corr().to_json(orient="records")
258+
# }))
221259
222260
return
223261

src/components/componentMapper.tsx

Lines changed: 221 additions & 78 deletions
Large diffs are not rendered by default.

src/components/graphs/CountBarChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const CountBarChart = ({ column, realData }: CountBarChartProps) => {
105105
.attr('text-anchor', 'middle')
106106
.style('font-size', '12px')
107107
.style('font-weight', 'bold')
108-
.text(`${t('distribution.countFor')} ${column}`);
108+
.text(`${t('distribution.distributionFor')} ${column}`);
109109
}, [containerWidth, column, realData]);
110110

111111
useEffect(() => {

src/components/ui/accordion.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ AccordionContent.displayName = AccordionPrimitive.Content.displayName;
5858

5959
export interface AccordionProps {
6060
title: string;
61-
content: string;
61+
content: React.ReactNode;
6262
}
6363

6464
export const Accordion = (props: AccordionProps) => (
@@ -68,17 +68,25 @@ export const Accordion = (props: AccordionProps) => (
6868
<AccordionItem value="item-1">
6969
<AccordionTrigger>{props.title}</AccordionTrigger>
7070
<AccordionContent>
71-
<Markdown className="mt-2 text-gray-800 markdown px-3 whitespace-pre-wrap">
72-
{props.content}
73-
</Markdown>
71+
{typeof props.content === 'string' ? (
72+
<Markdown className="mt-2 text-gray-800 markdown px-3 whitespace-pre-wrap">
73+
{props.content}
74+
</Markdown>
75+
) : (
76+
props.content
77+
)}
7478
</AccordionContent>
7579
</AccordionItem>
7680
</AccordionPrimitive.Root>
7781
</div>
7882
<div className="hidden showonprint">
79-
<Markdown className="text-gray-800 markdown">
80-
{props.content}
81-
</Markdown>
83+
{typeof props.content === 'string' ? (
84+
<Markdown className="text-gray-800 markdown">
85+
{props.content}
86+
</Markdown>
87+
) : (
88+
props.content
89+
)}
8290
</div>
8391
</>
8492
);

src/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
@tailwind components;
33
@tailwind utilities;
44

5+
.content-list,
56
.markdown {
67
p a {
78
@apply text-blue-500 underline;
89
}
10+
11+
ul {
12+
@apply list-disc list-inside;
13+
}
914
}

src/locales/en.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
}
5858
},
5959
"syntheticData": {
60+
"demo": {
61+
"heading": "Information about demo dataset",
62+
"description": "**UI text** A subset of the [Law School Admission Bar*](https://www.kaggle.com/datasets/danofer/law-school-admissions-bar-passage) dataset is used as a demo. Synthetic data will be generated for the following columns:\n \n&nbsp;&nbsp;\n- sex: student gender, i.e. 1 (male), 2 (female)\n- race1: race, i.e. asian, black, hispanic, white, other\n- ugpa: The student's undergraduate GPA, continous variable;\n- bar: Ground truth label indicating whether or not the student passed the bar, i.e. passed 1st time, passed 2nd time, failed, non-graduated\n \n&nbsp;&nbsp;\n\nThe CART method will be used evaluate the distribution and correlation differences between the real and synthetic data.\n \n&nbsp;&nbsp;\n\n*The original paper can be found [here](https://files.eric.ed.gov/fulltext/ED469370.pdf)."
63+
},
6064
"exportToPDF": "Download evaluation report as PDF",
6165
"exportToJSON": "Download synthetic data as JSON",
6266
"exportToCSV": "Download synthetic data as CSV",
@@ -84,8 +88,14 @@
8488
"demoCard": {
8589
"title": "Try it out!",
8690
"description": "Do you not have a dataset at hand? No worries use our demo data set."
87-
}
91+
},
92+
"columnsInDataset": "Detected column data-types in dataset",
93+
"columnsInDatasetInfo": "If detected data types are incorrect, please change this locally in the dataset before uploading it again.",
94+
"univariateCharts": "Univariate distributions of the uploaded dataset",
95+
"synthVsReal": "Synthetic vs Real data",
96+
"heatmapCorrelation": "Heatmap correlation"
8897
},
98+
8999
"biasAnalysis": {
90100
"demo": {
91101
"heading": "Information about demo dataset",

src/locales/nl.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
}
5858
},
5959
"syntheticData": {
60+
"demo": {
61+
"heading": "Informatie over demodataset",
62+
"description": "**UI-tekst** Een subset van de [Law School Admission Bar*](https://www.kaggle.com/datasets/danofer/law-school-admissions-bar-passage) dataset wordt gebruikt als demo. Er zullen synthetische gegevens worden gegenereerd voor de volgende kolommen:\n \n&nbsp;&nbsp;\n\n- sex: geslacht van de student, d.w.z. 1 (man), 2 (vrouw)\n- race1: etniciteit, d.w.z. aziatisch, zwart, hispanic, wit, anders\n- ugpa: Het GPA van de student tijdens de undergraduate-opleiding, continue variabele;\n- bar: Waarheidslabel dat aangeeft of de student is geslaagd voor de bar, d.w.z. geslaagd 1e keer, geslaagd 2e keer, gezakt, niet-afgestudeerd\n \n&nbsp;&nbsp;\n\nDe CART-methode zal worden gebruikt om de verschillen in distributie en correlatie tussen de echte en synthetische gegevens te evalueren.\n \n&nbsp;&nbsp;\n\n*Het oorspronkelijke artikel is [hier](https://files.eric.ed.gov/fulltext/ED469370.pdf) te vinden."
63+
},
6064
"exportToPDF": "Download evulatie rapport als PDF",
6165
"exportToJSON": "Download synthetische data als JSON",
6266
"exportToCSV": "Download synthetische data als CSV",
@@ -84,7 +88,12 @@
8488
"demoCard": {
8589
"title": "Probeer het uit!",
8690
"description": "Heeft u geen dataset bij de hand? Geen zorgen, gebruik onze demodataset."
87-
}
91+
},
92+
"columnsInDataset": "Gedetecteerde kolom data-types in de dataset",
93+
"columnsInDatasetInfo": "Als de gedetecteerd data types niet correct zijn, pas dit dan lokaal aan in de dataset voordat u deze opnieuw uploadt.",
94+
"univariateCharts": "Univariate distributies van de geuploade dataset",
95+
"synthVsReal": "Synthetic vs Real data",
96+
"heatmapCorrelation": "Heatmap correlatie"
8897
},
8998
"biasAnalysis": {
9099
"demo": {

0 commit comments

Comments
 (0)