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 PARSynthesizer Sample

From Leeroopedia
Knowledge Sources
Domains Time_Series, Data_Generation
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete tool for generating synthetic sequential data from a fitted PARSynthesizer, provided by the SDV library.

Description

The PARSynthesizer.sample method generates synthetic sequences. It samples context rows from the internal GaussianCopulaSynthesizer, assigns sequence keys, then generates temporal data using the PARModel.

Usage

Call this method after fitting a PARSynthesizer. Specify the number of sequences to generate.

Code Reference

Source Location

  • Repository: SDV
  • File: sdv/sequential/par.py
  • Lines: L624-650

Signature

def sample(self, num_sequences, sequence_length=None):
    """Sample new sequences.

    Args:
        num_sequences (int): Number of sequences to sample.
        sequence_length (int or None): Fixed length per sequence.
            None = variable length. Defaults to None.

    Returns:
        pandas.DataFrame: Synthetic sequential data.
    """

Import

from sdv.sequential import PARSynthesizer
# sample is called as: synthesizer.sample(num_sequences=10)

I/O Contract

Inputs

Name Type Required Description
num_sequences int Yes Number of sequences to generate
sequence_length int or None No Fixed length per sequence (None = variable)

Outputs

Name Type Description
return value pd.DataFrame Synthetic sequential data with sequence keys

Usage Examples

# Generate 10 sequences with variable length
synthetic_data = synthesizer.sample(num_sequences=10)
print(f"Generated {synthetic_data[metadata.get_column_names(sdtype='id')[0]].nunique()} sequences")

# Generate with fixed length
fixed_data = synthesizer.sample(num_sequences=5, sequence_length=50)

Related Pages

Implements Principle

Requires Environment

Page Connections

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