Skip to content

Commit 85df38b

Browse files
authored
Merge pull request #37 from NGO-Algorithm-Audit/feature/bivariate-cat-vs-cat(real_vs_synth)-tweaks
Feature/bivariate cat vs cat(real vs synth) tweaks
2 parents 4c31d63 + d28b09e commit 85df38b

File tree

2 files changed

+54
-66
lines changed

2 files changed

+54
-66
lines changed

src/components/DistributionReport.tsx

Lines changed: 53 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ export const DistributionReport = (
208208
return (
209209
<div key={column + column2}>
210210
<GroupBarChart
211-
yAxisLabel={column}
211+
yAxisLabel={t(
212+
'distribution.frequency'
213+
)}
212214
data={histogramData}
213215
title={`${column} vs ${column2}`}
214216
/>
@@ -257,24 +259,7 @@ export const DistributionReport = (
257259
return columnNames.map(
258260
(column2, indexcolumn2) => {
259261
const dataType2 = dataTypes[column2];
260-
if (
261-
//column === column2 ||
262-
indexcolumn1 >= indexcolumn2
263-
) {
264-
if (indexcolumn1 != indexcolumn2) {
265-
console.log(
266-
'skipped columns',
267-
column,
268-
column2,
269-
indexcolumn1,
270-
indexcolumn2,
271-
indexcolumn1 >=
272-
indexcolumn2,
273-
dataType,
274-
dataType2
275-
);
276-
}
277-
262+
if (indexcolumn1 >= indexcolumn2) {
278263
return null;
279264
}
280265

@@ -330,48 +315,55 @@ export const DistributionReport = (
330315
);
331316

332317
return (
333-
<div className="flex flex-row w-full overflow-auto gap-4">
334-
{categories.map(item => (
335-
<div
336-
key={item}
337-
className="flex flex-col"
338-
>
339-
<GroupBarChart
340-
yAxisLabel={
341-
'count'
342-
}
343-
title={`${column} = ${item}`}
344-
data={categories2.map(
345-
item2 => ({
346-
// count : number of times where item2 appears in the data for category2 and rows where category1 = item
347-
name: `${item2}`,
348-
values: [
349-
{
350-
name: 'real',
351-
value: countCategory2ForCategory1(
352-
realData,
353-
item,
354-
item2,
355-
column,
356-
column2
357-
),
358-
},
359-
{
360-
name: 'synth',
361-
value: countCategory2ForCategory1(
362-
syntheticData,
363-
item,
364-
item2,
365-
column,
366-
column2
367-
),
368-
},
369-
],
370-
})
371-
)}
372-
/>
373-
</div>
374-
))}
318+
<div>
319+
<h2 className="text-center font-bold mt-2 text-[12px]">
320+
{column} vs {column2}
321+
</h2>
322+
<div className="flex flex-row w-full overflow-auto gap-4">
323+
{categories.map(
324+
item => (
325+
<div
326+
key={item}
327+
className="flex flex-col"
328+
>
329+
<GroupBarChart
330+
yAxisLabel={t(
331+
'distribution.frequency'
332+
)}
333+
title={`${column} = ${item}`}
334+
data={categories2.map(
335+
item2 => ({
336+
// count : number of times where item2 appears in the data for category2 and rows where category1 = item
337+
name: `${item2}`,
338+
values: [
339+
{
340+
name: 'real',
341+
value: countCategory2ForCategory1(
342+
realData,
343+
item,
344+
item2,
345+
column,
346+
column2
347+
),
348+
},
349+
{
350+
name: 'synth',
351+
value: countCategory2ForCategory1(
352+
syntheticData,
353+
item,
354+
item2,
355+
column,
356+
column2
357+
),
358+
},
359+
],
360+
})
361+
)}
362+
/>
363+
</div>
364+
)
365+
)}
366+
</div>
375367
</div>
376368
);
377369
}

src/components/graphs/ViolinChart.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,7 @@ const ViolinChart = ({
318318
.attr('text-anchor', 'middle')
319319
.style('font-size', '12px')
320320
.style('font-weight', 'bold')
321-
.text(
322-
`${t('distribution.distributionOf')} ${numericColumn} ${t(
323-
'distribution.by'
324-
)} ${categoricalColumn}`
325-
);
321+
.text(`${numericColumn} vs ${categoricalColumn}`);
326322

327323
// Add y-axis label
328324
svg.append('text')

0 commit comments

Comments
 (0)