Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Sdv dev SDV BaseMultiTableSynthesizer Sample

From Leeroopedia
Knowledge Sources
Domains Synthetic_Data, Relational_Data
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete tool for generating synthetic multi-table relational data from a fitted synthesizer, provided by the SDV library.

Description

The BaseMultiTableSynthesizer.sample method generates synthetic data for all tables using hierarchical sampling. It validates that the synthesizer is fitted, applies the scale factor, invokes the hierarchical sampler, and returns a dictionary of DataFrames.

Usage

Call this method after fitting an HMASynthesizer. It returns a dictionary mapping table names to synthetic DataFrames.

Code Reference

Source Location

  • Repository: SDV
  • File: sdv/multi_table/base.py
  • Lines: L688-741

Signature

def sample(self, scale=1.0):
    """Generate synthetic data for the entire dataset.

    Args:
        scale (float): Scale factor for output row counts.
            1.0 = same as original, >1.0 = more rows, <1.0 = fewer rows.
            Defaults to 1.0.

    Returns:
        dict[str, pd.DataFrame]: Synthetic data for all tables.
    """

Import

from sdv.multi_table import HMASynthesizer
# sample is called as: synthesizer.sample(scale=1.0)

I/O Contract

Inputs

Name Type Required Description
scale float No Scale factor for row counts (default: 1.0, must be > 0)

Outputs

Name Type Description
return value dict[str, pd.DataFrame] Synthetic data for all tables with referential integrity

Usage Examples

# After fitting
synthetic_data = synthesizer.sample(scale=1.0)

for table_name, df in synthetic_data.items():
    print(f"{table_name}: {len(df)} rows")

# Generate 2x the original data
larger_data = synthesizer.sample(scale=2.0)

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment