Skip to content

Commit d5a0f3b

Browse files
committed
Merge remote-tracking branch 'origin/feature/fixes-11-jun-ubdt' into JFP_edits
2 parents 70f904e + cf03f87 commit d5a0f3b

File tree

8 files changed

+29
-22
lines changed

8 files changed

+29
-22
lines changed

src/assets/bias-detection-python-code.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ def run():
332332
'iterations': localIterations,
333333
'minClusterSize': localClusterSize,
334334
'performanceMetric': bias_score,
335-
'dataType': dataTypeText
335+
'dataType': dataTypeText,
336+
'higherIsBetter': 'biasAnalysis.higherIsBetter' if higherIsBetter else 'biasAnalysis.lowerIsBetter'
336337
}
337338
}))
338339
setResult(json.dumps({
@@ -375,7 +376,12 @@ def run():
375376
'defaultIndex': 0,
376377
'labelKey': 'biasAnalysis.clusterinResults.label',
377378
'valueKey' : 'biasAnalysis.clusterinResults.valueText',
378-
'values': biasInClusters
379+
'values': biasInClusters,
380+
'params': {
381+
'numZeroes': int(numZeros),
382+
'totalRecords': int(totalRecords),
383+
'clusterCount': clusterCount
384+
}
379385
}))
380386
setResult(json.dumps({
381387
'type': 'text',
@@ -402,8 +408,6 @@ def run():
402408
403409
404410
decoded_X_test["cluster_label"] = y_test
405-
406-
# ----
407411
408412
if localDataType == 'numeric':
409413
test_df["cluster_label"] = y_test
@@ -443,10 +447,6 @@ def run():
443447
print("The most biased cluster has a significantly higher average bias metric than the rest of the dataset.")
444448
else:
445449
print("No significant difference in average bias metric between the most biased cluster and the rest of the dataset.")
446-
# setResult(json.dumps({
447-
# 'type': 'heading',
448-
# 'headingKey': 'biasAnalysis.nodifference.heading',
449-
# }))
450450
451451
setResult(json.dumps({
452452
'type': 'heading',
@@ -482,12 +482,7 @@ def run():
482482
charts = []
483483
484484
for i, var in enumerate(variables):
485-
486-
#setResult(json.dumps({
487-
# 'type': 'heading',
488-
# 'headingKey': 'biasAnalysis.distribution.heading',
489-
# 'params': {'variable': var}
490-
#}))
485+
491486
print(f"means: {var}")
492487
print(overall_means[var])
493488
print(means[var])

src/components/BiasSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default function BiasSettings({
7676
resolver: zodResolver(FormSchema),
7777
defaultValues: {
7878
dataType: 'numeric',
79-
whichPerformanceMetricValueIsBetter: 'higher',
79+
whichPerformanceMetricValueIsBetter: 'lower',
8080
},
8181
});
8282
const [iter, setIter] = useState([10]);

src/components/componentMapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ export default function ComponentMapper({
267267
defaultIndex: resultItem.defaultIndex,
268268
labelKey: resultItem.labelKey,
269269
valueKey: resultItem.valueKey,
270+
params: resultItem.params || {},
270271
}}
271272
/>
272273
</ErrorBoundary>

src/components/composed-components/ClusterCategoriesDistributionAccordeonContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const ClusterCategoriesDistributionAccordeonContent = ({
8080
chart.selectFilterGroup ===
8181
defaultCategory) ||
8282
!chart.selectFilterGroup ? (
83-
<div className="hideonprint">
83+
<div className="hideonprint w-full">
8484
<h5
8585
key={index}
8686
className="text-gray-800 font-semibold"
@@ -107,7 +107,7 @@ const ClusterCategoriesDistributionAccordeonContent = ({
107107
/>
108108
</div>
109109
) : null}
110-
<div className="hidden showonprint">
110+
<div className="hidden showonprint overflow-x-hidden">
111111
<h5
112112
key={index}
113113
className="text-gray-800 font-semibold"

src/components/composed-components/ClusterNumericalVariableDistributionAccordeonContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const ClusterNumericalVariableDistributionAccordeonContent = ({
7171
chart.selectFilterGroup ===
7272
defaultCategory) ||
7373
!chart.selectFilterGroup ? (
74-
<div className="hideonprint">
74+
<div className="hideonprint w-full">
7575
<h5
7676
key={chartIndex}
7777
className="text-gray-800 font-semibold"
@@ -91,7 +91,7 @@ const ClusterNumericalVariableDistributionAccordeonContent = ({
9191
/>
9292
</div>
9393
) : null}
94-
<div className="hidden showonprint">
94+
<div className="hidden showonprint overflow-x-hidden">
9595
<h5
9696
key={`SingleBarChart-print-${chartIndex}`}
9797
className="text-gray-800 font-semibold"

src/components/composed-components/TextValueSelect.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const TextValueSelect = ({
1111
defaultIndex: number;
1212
labelKey: string;
1313
valueKey: string;
14+
params: Record<string, string>;
1415
};
1516
}) => {
1617
const [selectedIndex, setSelectedIndex] = useState<number | null>();
@@ -39,6 +40,7 @@ const TextValueSelect = ({
3940
<div>
4041
<label className="text-sm font-semibold">
4142
{t(data.valueKey, {
43+
...data.params,
4244
index: selectedIndex ?? data.defaultIndex,
4345
value,
4446
})}

src/locales/en.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ export const en = {
181181
gaussianCopulaModelTitle: '3. Method: Gaussian Copula model',
182182
cartModelDescription:
183183
'The CART (Classification and Regression Trees) method generates synthetic data by learning patterns from real data through a decision tree that splits data into homogeneous groups based on feature values. It predicts averages for numerical data and assigns the most common category for categorical data, using these predictions to create new synthetic points.\n \n {{samples}} synthetic data points are generated.',
184-
evaluationOfGeneratedDataTitle: '4. Evaluation of generated synthetic data',
184+
evaluationOfGeneratedDataTitle:
185+
'4. Evaluation of generated synthetic data',
185186
distributionsTitle: '4.1 Distributions',
186187
diagnosticsReportTitle: '4.2. Diagnostic report',
187188
diagnosticsTitle: 'Diagnostic Results',
@@ -303,6 +304,8 @@ A two-sided t-test is performed to accept or reject <i class="font-serif">H</i><
303304
In this example, we analyze which group is most adversely affected by the risk prediction algorithm. We do this by applying the clustering algorithm on the dataset previewed below. The column "is_recid" indicates whether a defendant reoffended or not (1: yes, 0: no). The "score_text" column indicates whether a defendant was predicted to reoffend (1: yes, 0: no). The column "false_positive" (FP) represents cases where a defendant was predicted to reoffended by the algorithm, but didn't do so (1: FP, 0: no FP). A preview of the data can be found below. The column "false_positive" is used as the bias variable.
304305
`,
305306
},
307+
higherIsBetter: 'Higher value of bias variable is better',
308+
lowerIsBetter: 'Lower value of bias variable is better',
306309
parameters: {
307310
heading: '2. Hyperparameters selected for clustering',
308311
iterations: 'Number of iterations: {{value}}',
@@ -313,6 +316,7 @@ In this example, we analyze which group is most adversely affected by the risk p
313316
- Minimal cluster size: {{minClusterSize}}
314317
- Bias variable: {{performanceMetric}}
315318
- Data type: {{dataType}}
319+
- Bias variable interpretation: $t({{higherIsBetter}}) is better
316320
`,
317321
},
318322
distributionOfFeaturesAcrossClustersAccordeonTitle:
@@ -366,7 +370,8 @@ In this example, we analyze which group is most adversely affected by the risk p
366370
- Number of clusters detected: {{clusterCount}}
367371
`,
368372
label: 'Choose cluster to show number of datapoints for',
369-
valueText: 'Number of datapoints in cluster {{index}}: {{value}}',
373+
valueText:
374+
'Number of datapoints in cluster {{index}}: {{value}} / {{totalRecords}}',
370375
},
371376
higherAverage: `The most deviating cluster has statistically significant different bias variable than the rest of the dataset.`,
372377
noSignificance: `No statistically significant difference in bias variable between the most biased cluster and the rest of the dataset.`,

src/locales/nl.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ Er wordt een tweezijdige t-toets uitgevoerd om <i class="font-serif">H</i><sub>0
304304
{tooltip:biasAnalysis.p_valueTooltip}p-waarde{/tooltip} : {{p_val}}
305305
`,
306306
p_valueTooltip: `p-waarde tooltip`,
307+
higherIsBetter: 'Hogere waarde van bias variabele is beter',
308+
lowerIsBetter: 'Lagere waarde van bias variabele is beter',
307309
parameters: {
308310
heading: '2. Geselecteerde hyperparameters',
309311
iterations: 'Aantal iteraties: {{value}}',
@@ -316,6 +318,7 @@ Er wordt een tweezijdige t-toets uitgevoerd om <i class="font-serif">H</i><sub>0
316318
- Minimale clustergrootte: {{minClusterSize}}
317319
- Bias variabele: {{performanceMetric}}
318320
- Gegevenstype: {{dataType}}
321+
- Interpretatie van bias variabele: $t({{higherIsBetter}}) is better
319322
`,
320323
},
321324
distribution: {
@@ -365,7 +368,8 @@ Er wordt een tweezijdige t-toets uitgevoerd om <i class="font-serif">H</i><sub>0
365368
- Aantal gevonden clusters: {{clusterCount}}
366369
`,
367370
label: 'Kies cluster om het aantal datapunten voor weer te geven',
368-
valueText: 'Aantal datapunten in cluster {{index}}: {{value}}',
371+
valueText:
372+
'Aantal datapunten in cluster {{index}}: {{value}} / {{totalRecords}}',
369373
},
370374
higherAverage: `Het meest afwijkende cluster heeft statistisch significant andere bias variabele dan de rest van de dataset.`,
371375
noSignificance: `Het meest afwijkende cluster heeft statistisch significant geen andere bias variabele dan de rest van de dataset.`,

0 commit comments

Comments
 (0)