Skip to content

Commit 410152d

Browse files
committed
table with demo data info (translatable)
1 parent a56d169 commit 410152d

File tree

5 files changed

+86
-4
lines changed

5 files changed

+86
-4
lines changed

src/assets/synthetic-data.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,41 @@ def run():
137137
'type': 'text',
138138
'key': 'syntheticData.demo.description'
139139
}))
140+
141+
demoData = {
142+
"syntheticData.demo.data.column.Variable_name": ["syntheticData.demo.data.sex", "syntheticData.demo.data.race1", "syntheticData.demo.data.ugpa", "syntheticData.demo.data.bar"],
143+
"syntheticData.demo.data.column.Description": [
144+
"syntheticData.demo.data.column.Description.gender_of_students",
145+
"syntheticData.demo.data.column.Description.race_of_students",
146+
"syntheticData.demo.data.column.Description.undergraduate_GPA_student",
147+
"syntheticData.demo.data.column.Description.Ground_truth_label"
148+
],
149+
"syntheticData.demo.data.column.Values": [
150+
"syntheticData.demo.data.column.Values.sex",
151+
"syntheticData.demo.data.column.Values.race",
152+
"syntheticData.demo.data.column.Values.ugpa",
153+
"syntheticData.demo.data.column.Values.bar"
154+
]
155+
}
156+
157+
# Create the DataFrame
158+
dfDemoData = pd.DataFrame(demoData)
159+
160+
# Display the DataFrame
161+
print(dfDemoData)
162+
163+
setResult(json.dumps({
164+
'type': 'table',
165+
'showIndex': False,
166+
'translate': True,
167+
'data': dfDemoData.to_json(orient="records")
168+
}))
169+
170+
setResult(json.dumps({
171+
'type': 'text',
172+
'key': 'syntheticData.demo.post.description'
173+
}))
174+
140175
else:
141176
admissions_df.reset_index(drop=True, inplace=True)
142177
admissions_sub = admissions_df

src/components/SimpleTable.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ export default function SimpleTable({
1313
title,
1414
data,
1515
showIndex,
16+
translate,
1617
}: {
1718
showIndex: boolean;
1819
title?: string;
1920
data: Record<string, string | number>[];
21+
translate?: boolean;
2022
}) {
2123
const { t } = useTranslation();
2224
// limit data to the first 100 rows.
@@ -31,7 +33,7 @@ export default function SimpleTable({
3133
{showIndex && <TableHead></TableHead>}
3234
{Object.keys(data[0]).map(key => (
3335
<TableHead key={key} className="text-black">
34-
{key}
36+
{translate ? t(key) : key}
3537
</TableHead>
3638
))}
3739
</TableRow>
@@ -41,7 +43,11 @@ export default function SimpleTable({
4143
<TableRow key={i}>
4244
{showIndex && <TableCell>{i}</TableCell>}
4345
{Object.values(row).map((value, i) => (
44-
<TableCell key={i}>{value}</TableCell>
46+
<TableCell key={i}>
47+
{translate && typeof value !== 'number'
48+
? t(value)
49+
: value}
50+
</TableCell>
4551
))}
4652
</TableRow>
4753
))}

src/components/componentMapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default function ComponentMapper({
5757
data={JSON.parse(resultItem.data)}
5858
title={t(resultItem.title)}
5959
showIndex={resultItem.showIndex ?? false}
60+
translate={resultItem.translate ?? false}
6061
/>
6162
);
6263

src/locales/en.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,27 @@
5959
"syntheticData": {
6060
"demo": {
6161
"heading": "Information about demo dataset",
62-
"description": "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 of student, i.e., asian, black, hispanic, white, other;\n- ugpa: undergraduate GPA of student (average course grades), 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 is used to generate the synthetic data. CART generally produces higher quality synthetic datasets, but might not work well on datasets with categorical variables with 20+ categories. Use Gaussian Copula in those cases.\n \n&nbsp;&nbsp;\n\n*The original paper can be found [here](https://files.eric.ed.gov/fulltext/ED469370.pdf)\n \n&nbsp;&nbsp;\n"
62+
"description": "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",
63+
"post.description": "The CART method is used to generate the synthetic data. CART generally produces higher quality synthetic datasets, but might not work well on datasets with categorical variables with 20+ categories. Use Gaussian Copula in those cases.\n \n&nbsp;&nbsp;\n\n*The original paper can be found [here](https://files.eric.ed.gov/fulltext/ED469370.pdf)\n \n&nbsp;&nbsp;\n",
64+
"data.column.Variable_name": "Variable name",
65+
"data.sex": "sex",
66+
"data.race1": "race1",
67+
"data.ugpa": "ugpa",
68+
"data.bar": "bar",
69+
70+
"data.column.Description": "Description",
71+
72+
"data.column.Description.gender_of_students": "gender of students",
73+
"data.column.Description.race_of_students": "race of students",
74+
"data.column.Description.undergraduate_GPA_student": "undergraduate GPA of student (average course grades)",
75+
"data.column.Description.Ground_truth_label": "Ground truth label indicating whether or not the student passed the bar",
76+
77+
"data.column.Values": "Values",
78+
79+
"data.column.Values.sex": "1 (male), 2 (female)",
80+
"data.column.Values.race": "asian, black, hispanic, white, other",
81+
"data.column.Values.ugpa": "1-4",
82+
"data.column.Values.bar": "passed 1st time, passed 2nd time, failed, non-graduated"
6383
},
6484
"exportToPDF": "Download evaluation report as pdf",
6585
"exportToJSON": "Download synthetic data as json",

src/locales/nl.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,27 @@
5959
"syntheticData": {
6060
"demo": {
6161
"heading": "Informatie over demodataset",
62-
"description": "Een subset van de [Law School Admission Bar](https://www.kaggle.com/datasets/danofer/law-school-admissions-bar-passage)* dataset wordt gebruikt als demo. Synthetische data worden gegenereerd voor de volgende kolommen:\n \n&nbsp;&nbsp;\n\n- sex: geslacht van de student, zijnde 1 (man), 2 (vrouw);\n- race1: etniciteit van de student, 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."
62+
"description": "Een subset van de [Law School Admission Bar](https://www.kaggle.com/datasets/danofer/law-school-admissions-bar-passage)* dataset wordt gebruikt als demo. Synthetische data worden gegenereerd voor de volgende kolommen:\n \n&nbsp;&nbsp;\n\n",
63+
"post.description": "De 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.",
64+
"data.column.Variable_name": "Variabele name",
65+
"data.sex": "sex",
66+
"data.race1": "race1",
67+
"data.ugpa": "ugpa",
68+
"data.bar": "bar",
69+
70+
"data.column.Description": "Omschrijving",
71+
72+
"data.column.Description.gender_of_students": "geslacht van de student",
73+
"data.column.Description.race_of_students": "etniciteit van de student",
74+
"data.column.Description.undergraduate_GPA_student": "het GPA van de student tijdens de undergraduate-opleiding",
75+
"data.column.Description.Ground_truth_label": "Waarheidslabel dat aangeeft of de student is geslaagd voor de bar",
76+
77+
"data.column.Values": "Waardes",
78+
79+
"data.column.Values.sex": "1 (man), 2 (vrouw)",
80+
"data.column.Values.race": "aziatisch, zwart, hispanic, wit, anders",
81+
"data.column.Values.ugpa": "1-4",
82+
"data.column.Values.bar": "geslaagd 1e keer, geslaagd 2e keer, gezakt, niet-afgestudeerd"
6383
},
6484
"exportToPDF": "Download evulatie rapport als pdf",
6585
"exportToJSON": "Download synthetische data als json",

0 commit comments

Comments
 (0)