Skip to main content
ByKürşat Kaya
Given a real table, sample new rows that follow the same statistical patterns. Tabular data is everywhere: spreadsheets, customer records, financial logs, medical registries. Yet getting a usable table for a demo or prototype is often blocked by privacy concerns and regulations. Synthetic data works around that: artificial rows that preserve the statistical patterns of the real table without exposing individual records. Common tools include scikit-learn’s make_* functions, Faker for rule-based generation, and GAN-based methods like CTGAN or TabGAN. These are powerful but often complex to set up. TabPFN is a foundation model specialised for tabular data, and its unsupervised tools let us generate a look-alike table without training a GAN or building a simulation. In this notebook we take an existing dataset (scikit-learn’s Breast Cancer table) as the source, fit TabPFN’s unsupervised model on it, and sample new rows that share its column distributions and correlations. The result is a standalone synthetic table that can stand in for the real one (for a demo, a test fixture, or to extend the training set) which we then compare against the original with table-evaluator. You can use this approach to:
  • Realistic demo data to share with customers or collaborators without exposing real records.
  • QA and pipeline tests with plausible rows before going live on real data.
  • Fast prototyping when access to the real dataset is restricted.

Setup

Installing TabPFN, its extensions, and table-evaluator. The unsupervised synthetic-data helpers live in tabpfn_extensions, and table-evaluator provides the visual fidelity checks we use at the end.

Imports and Data

Loading the Breast Cancer dataset as our safe, realistic table. We use scikit-learn’s Breast Cancer dataset, a classic, non-sensitive table that stands in for whatever proprietary data you would like to synthesise. We keep a train/test split so the synthetic table can later be compared against real data the model never saw.

Building the Unsupervised Model

Wrapping a classifier and a regressor into TabPFNUnsupervisedModel. The synthetic-data experiment expects a TabPFNUnsupervisedModel, which pairs a TabPFNClassifier (for discrete columns) with a TabPFNRegressor (for continuous columns). Together they let TabPFN model each column conditional on the others and sample new rows from that joint distribution.

Generating the Synthetic Table

Running the experiment to produce look-alike rows. GenerateSyntheticDataExperiment handles the sampling loop. temp controls diversity: higher values give more varied rows, lower values stay closer to the training data. n_samples sets how many rows we want out. Here we ask for twice as many rows as the training split, over all 30 features. Inputs come in as tensors, and the resulting synthetic table is written to synthetic.csv for the evaluation step.
Generating the Synthetic Table

Comparing Real vs. Synthetic

Checking fidelity with TableEvaluator. A synthetic table is only useful if it behaves like the real thing. TableEvaluator compares the two side by side and reports on distribution overlap, correlation structure, and low-dimensional geometry. We call the three plots we care about directly (distributions, correlation difference, PCA) instead of visual_evaluation, which produces a much larger figure grid.

Distributions

Do the synthetic columns look like the real ones? The per-feature histograms show how closely each synthetic column tracks the real distribution. A close overlap means the marginals have been preserved.
Distributions

Correlations

Are the relationships between features still there? TabPFN samples each column conditional on the others, so we care about more than just marginals. The correlation-difference heatmap highlights where the synthetic table’s feature-to-feature relationships depart from the real table. Small values mean the joint structure held up.
Correlations

PCA Projection

Do the two tables share the same low-dimensional geometry? Projecting real and synthetic rows onto the first two principal components gives a quick visual check: overlapping clouds mean the synthetic rows live in the same subspace as the real ones.
PCA Projection