| calibrate_closeness | R Documentation |
Finds the value of closeness (see generate()) for which synthetic data
reach a target value of a distance metric. The metric is evaluated on a
grid of closeness values with common random numbers, the grid interval
containing the target is located, and the solution is refined by
bisection, followed by a final linear interpolation step. Metric values
are themselves estimates, so the achieved value varies somewhat with the
random seed.
Available metrics (all computed against data, which should be the data
the synthesizer was fitted on):
"auc" – cross-validated discriminator AUC (discriminator_auc());
0.5 means indistinguishable, larger values mean more distant;
"dcr" – median distance to the closest real record relative to the
real-to-real nearest-neighbour distance (dcr()); larger means further
from real records;
"pmse" – pMSE ratio (pmse()) with the quadratic propensity model;
"marginal" – mean marginal distance (KS / TVD,
marginal_metrics());
a function function(real, synthetic) returning a single number,
for any other criterion, e.g. a disclosure-risk measure from
disclosure_risk().
calibrate_closeness(
object,
data,
target,
metric = c("auc", "dcr", "pmse", "marginal"),
n = NULL,
grid = seq(0, 1, by = 0.1),
refine = 4L,
max_rows = 2000L,
seed = 1,
...
)
object |
A fitted |
data |
The real data the synthesizer was fitted on. |
target |
Target value of the metric. |
metric |
One of |
n |
Number of synthetic records generated per evaluation (default:
size of |
grid |
Closeness values evaluated first. |
refine |
Number of bisection steps after the grid search. |
max_rows |
Maximum rows used by the metric computations. |
seed |
Random seed (the same seed is used at every closeness value). |
... |
Passed to |
An object of class sp_calibration with elements closeness
(the calibrated value), achieved (metric value at that closeness),
target, metric and path (all evaluations). It has print() and
plot() methods.
fit <- fit_synthesizer(iris)
cal <- calibrate_closeness(fit, iris, target = 0.75, metric = "auc",
grid = seq(0, 1, 0.25), refine = 2)
cal
syn <- generate(fit, closeness = cal$closeness, seed = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.