Skip to content

Utility: can it do the job?

Train one model on synthetic rows and one on real rows, test both on rows neither saw, and read the ratio. Then see why more synthetic rows don't add information.

Applied ~12 min11 steps

What runs in CodeSplash

You will be able to

  • Explain train on synthetic, test on real, and read the utility ratio
  • Predict when a generator's loss of structure will hurt a model
  • Explain why extra synthetic rows don't add evidence

Read first

01

The test that matters for modeling

Read

Fidelity asks whether a table looks right. If you plan to train a model, there's a more direct test: does a model trained on it work on real data?

That's train on synthetic, test on realTrain on synthetic, test on realTrains one model on synthetic rows and one on real rows, then tests both on real rows neither saw.. The app trains the same learner (LightGBM) twice, once on the synthetic rows and once on the real training rows. It tests both on the holdout, real rows neither model saw.

utility=score of the model trained on synthetic rowsscore of the model trained on real rows\text{utility} = \frac{\text{score of the model trained on synthetic rows}}{\text{score of the model trained on real rows}}
02

Can high fidelity hide low utility?

Predict

Predict first

Every column matches well, and so do the pairwise correlations. Could a model trained on this table still do poorly on real rows?

No: faithful data trains good modelsYes: it can lose the one pattern the model needsOnly if privacy is low
Reveal

Yes. Column and pair checks can miss a pattern that only shows when three things combine, such as an effect of age that exists in one region only. If the generator drops that, a model trained on its rows can't learn it, and the fidelity scores never mention it.

03

What an interaction looks like

Explore

An interactionInteractionWhen the effect of one predictor depends on the level of another. means the effect of one variable depends on another.

DExplorable · Interactions and simple slopes

When the effect of x depends on a moderator, where is it actually different from zero?

What is the slope of x at this moderator value?

0.0
How sure?
0.50
120
0.0

Centering: with a mean far from zero, the coefficient on x describes a moderator value no one has.

1.0
no effectJ–NJ–N

Where the band excludes zero, the slope of x is significant at that moderator value. Johnson–Neyman (J–N) marks the boundaries.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Raise the true interaction, and watch the slope of xx change with the moderator. A Gaussian copula has no way to store this: it keeps one correlation for each pair, whatever the other columns are doing. Sequential trees can keep it, since each column is drawn from a tree on the columns before it.

If interactions matter for your model, that's a reason to try trees first.

04

Read the ratio

Read

Reading utility takes both numbers. A ratio can look fine when the real-data model is itself poor, so check the score on real rows first.

LightRelative utility
GoodAt least 90%
CautionAt least 75%
PoorBelow that

For Augment training data, the verdict needs both utility and fidelity: a poor light on either one gives Not useful for augmentation yet.

05

Measure it

In the app

In the studio, open Scorecard and choose a column under Utility target. Then press Score again.

The Utility section shows the score when trained on real rows, the score when trained on synthetic rows, and the relative utility. This needs a holdout, because the test rows have to be ones the generator never saw.

Try two generators with the same target. Do they differ by more than you'd expect from a rerun with another seed?

06

More rows, same information

Predict

Predict first

You fit a generator to 258 rows and draw 500. Do you know more about penguins than you did?

Yes: the standard error shrinks with more rowsNo: every row comes from the same fitted modelOnly if fidelity is high
Reveal

No. Everything in the new rows came from the fitted model, which came from the original rows. A formula will happily report a smaller standard error, because it believes it has more independent observations. That precision isn't real.

07

See the false precision

Explore

A standard error shrinks with n\sqrt{n}, and the formula can't tell where the rows came from.

AExplorable · Standard error against n

How much more data does it take to halve the uncertainty of a mean?

If you quadruple the sample size, the spread of sample means becomes…

How sure?
2.0
10
Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Quadruple nn and watch the error halve. That's right for new, independent data. For synthetic rows the shrinkage is an illusion, as you can draw as many as you like.

So use synthetic rows to fill out a training set, or to test software. For standard errors and p-values, go back to the real data.

08

When might augmenting help?

Reflect

Adding synthetic rows can help a model in specific cases, such as a small training set with a flexible learner, or a rare class. It can also hurt, by teaching the generator's mistakes.

Think of a model you've trained. What would you compare to find out? Make sure that your answer includes a test set of real rows that the generator never saw.

09

Check your understanding

Checkpoint

Check yourself

A model trained on real rows scores an AUC of 0.80 on the holdout. Trained on synthetic rows, it scores 0.72. What is the relative utility, as a decimal?

Show the answer

Answer: 0.9

0.72 / 0.80 = 0.90, which is the edge of the good band.

Check yourself

Why are both models tested on the holdout, and not on synthetic rows?

Show the answer

Answer: a

A model tested on data from the same generator can score well by learning that generator's quirks.

Check yourself

An analyst pads 200 real rows with 2,000 synthetic ones, runs a t test on all of them, and gets p < .001. What's wrong?

Show the answer

Answer: a

The extra rows hold no new information about the population. Run the test on the 200 real rows.

10

Compute it yourself

In the app

Here is the idea with a logistic model on numeric columns. The app uses LightGBM, so its numbers will differ.

Python
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

cols, target = ["age", "visits", "tenure_months"], "churned"
train, holdout, synth = (pd.read_csv(f).dropna(subset=cols + [target]) for f in ["train.csv", "holdout.csv", "synthetic.csv"])

def score(frame):
    model = make_pipeline(StandardScaler(), LogisticRegression()).fit(frame[cols], frame[target])
    return roc_auc_score(holdout[target], model.predict_proba(holdout[cols])[:, 1])

real, syn = score(train), score(synth)
print(f"real {real:.3f}, synthetic {syn:.3f}, relative utility {syn / real:.2f}")
R
cols <- c("age", "visits", "tenure_months")
target <- "churned"
read_rows <- function(f) {
  d <- na.omit(read.csv(f)[, c(cols, target)])
  d[[target]] <- d[[target]] %in% c(TRUE, "TRUE", "True", "true", 1)
  d
}
train <- read_rows("train.csv")
holdout <- read_rows("holdout.csv")
synth <- read_rows("synthetic.csv")

auc <- function(y, s) {
  r <- rank(s)
  n1 <- sum(y)
  n0 <- sum(!y)
  (sum(r[y]) - n1 * (n1 + 1) / 2) / (n1 * n0)
}

score <- function(frame) {
  fit <- glm(reformulate(cols, target), binomial, frame)
  auc(holdout[[target]], predict(fit, holdout))
}

real <- score(train)
syn <- score(synth)
cat(sprintf("real %.3f, synthetic %.3f, relative utility %.2f\n", real, syn, syn / real))
11

Recap

Recap
  • Utility compares a model trained on synthetic rows with one trained on real rows, both tested on unseen real rows.
  • High fidelity can hide low utility when a generator loses an interaction.
  • Extra synthetic rows carry no new information, so don't let them shrink a standard error.
  • Compare with and without augmentation on real test rows before you rely on it.

Concepts in this lesson