Skip to content

Commit 455aedd

Browse files
committed
add samples slider
1 parent 36d7091 commit 455aedd

File tree

7 files changed

+38
-5
lines changed

7 files changed

+38
-5
lines changed

src/assets/synthetic-data.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ from js import setResult
4444
from js import dataType
4545
from js import isDemo
4646
from js import sdgMethod
47+
from js import samples
4748
4849
INIT_STEP = 'init'
4950
PROCESSOR_STEP = 'processor'
@@ -577,15 +578,15 @@ def run():
577578
spop = Synthpop(method='cart')
578579
579580
spop.fit(real_data, dtypes=dtypes_dict)
580-
synthetic_data = spop.generate(k=1000)
581+
synthetic_data = spop.generate(k=samples)
581582
582583
if (sdgMethod == 'gc'):
583584
# Initialize synthesizer and fit it to the data
584585
synthesizer = GaussianCopulaSynthesizer()
585586
synthesizer.fit(real_data)
586587
587588
# Generate synthetic data
588-
synthetic_data = synthesizer.sample(1000)
589+
synthetic_data = synthesizer.sample(samples)
589590
590591
# Output some results
591592
print("Original Data (first 5 rows):", real_data.head())

src/components/SyntheticDataSettings.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Papa from 'papaparse';
1111
import { SyntheticDataParameters } from './synthetic-data-interfaces/BiasDetectionParameters';
1212
import { useTranslation } from 'react-i18next';
1313
import { RadioGroup, RadioGroupItem } from './ui/radio-group';
14+
import { Slider } from './ui/slider';
15+
import { Label } from './ui/label';
1416

1517
const createFormSchema = (t: (key: string) => string) =>
1618
z.object({
@@ -42,6 +44,8 @@ export default function BiasSettings({
4244
sdgMethod: 'gc',
4345
},
4446
});
47+
48+
const [outputSamples, setOutputSamples] = useState([1000]);
4549
const [dataKey, setDataKey] = useState<string>(new Date().toISOString());
4650
const [data, setData] = useState<{
4751
data: Record<string, string>[];
@@ -84,6 +88,7 @@ export default function BiasSettings({
8488
dataType: 'numeric',
8589
isDemo: false,
8690
sdgMethod: data.sdgMethod,
91+
samples: outputSamples[0],
8792
});
8893
};
8994

@@ -148,6 +153,21 @@ export default function BiasSettings({
148153
)}
149154
/>
150155
</div>
156+
157+
<div className="grid gap-3">
158+
<Label htmlFor="samples">
159+
{t('syntheticData.form.fieldset.samples')} (
160+
{outputSamples})
161+
</Label>
162+
<Slider
163+
id="samples"
164+
defaultValue={outputSamples}
165+
max={5000}
166+
step={10}
167+
onValueChange={value => setOutputSamples(value)}
168+
className="cursor-pointer"
169+
/>
170+
</div>
151171
</fieldset>
152172

153173
<div className="flex flex-row ml-auto gap-2">

src/components/synthetic-data-interfaces/BiasDetectionParameters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export interface SyntheticDataParameters {
22
dataType: string;
33
isDemo: boolean;
44
sdgMethod: string;
5+
samples: number;
56
}

src/components/synthetic-data-interfaces/cluster-export.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export interface SyntheticDataInfo {
22
dataType: string;
33
isDemo: boolean;
44
sdgMethod: string;
5+
samples: number;
56
}

src/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"title": "Method",
6464
"cart": "cart",
6565
"gc": "Gaussian Copula"
66-
}
66+
},
67+
"samples": "Number of samples"
6768
},
6869
"actions": {
6970
"tryItOut": "Try it out",

src/locales/nl.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"title": "Methode",
6464
"cart": "cart",
6565
"gc": "Gaussian Copula"
66-
}
66+
},
67+
"samples": "Aantal samples"
6768
},
6869
"actions": {
6970
"tryItOut": "Uitproberen",

src/routes/SyntheticData.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default function SyntheticDataGeneration() {
6565
dataType: 'numeric',
6666
isDemo: false,
6767
sdgMethod: 'gc',
68+
samples: 1000,
6869
});
6970

7071
const onFileLoad: csvReader['onChange'] = (
@@ -89,14 +90,20 @@ export default function SyntheticDataGeneration() {
8990
sendData(data.stringified);
9091
}
9192
if (data.demo) {
92-
onRun({ dataType: 'numeric', isDemo: true, sdgMethod: 'cart' });
93+
onRun({
94+
dataType: 'numeric',
95+
isDemo: true,
96+
sdgMethod: 'cart',
97+
samples: 1000,
98+
});
9399
}
94100
}, [initialised, data]);
95101

96102
const onRun = (props: {
97103
dataType: string;
98104
isDemo: boolean;
99105
sdgMethod: string;
106+
samples: number;
100107
}) => {
101108
runPython({
102109
type: 'start',
@@ -105,6 +112,7 @@ export default function SyntheticDataGeneration() {
105112
dataType: props.dataType,
106113
isDemo: props.isDemo,
107114
sdgMethod: props.sdgMethod,
115+
samples: props.samples,
108116
},
109117
},
110118
});

0 commit comments

Comments
 (0)