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 BaseSynthesizer Save Load

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

Overview

Concrete tools for saving and loading fitted single-table synthesizers to/from disk, provided by the SDV library.

Description

BaseSynthesizer.save serializes the entire synthesizer to a file using cloudpickle. BaseSynthesizer.load deserializes from a file, validates the synthesizer type, checks version compatibility, and returns the restored instance.

Usage

Call save on a fitted synthesizer to persist it. Call load as a class method to restore.

Code Reference

Source Location

  • Repository: SDV
  • File: sdv/single_table/base.py
  • Lines: L712-775

Signature

def save(self, filepath):
    """Save this model instance to the given path using cloudpickle.

    Args:
        filepath (str): Path where the synthesizer will be serialized.
    """

@classmethod
def load(cls, filepath):
    """Load a single-table synthesizer from a given path.

    Args:
        filepath (str): Filepath of saved synthesizer.

    Returns:
        SingleTableSynthesizer: The loaded synthesizer.
    """

Import

from sdv.single_table import GaussianCopulaSynthesizer
# save: synthesizer.save('model.pkl')
# load: synthesizer = GaussianCopulaSynthesizer.load('model.pkl')

I/O Contract

Inputs (save)

Name Type Required Description
filepath str Yes Path for serialized file

Inputs (load)

Name Type Required Description
filepath str Yes Path to saved synthesizer file

Outputs

Name Type Description
save returns None Writes .pkl file to filepath
load returns BaseSynthesizer Restored synthesizer instance

Usage Examples

# Save after fitting
synthesizer.save('my_synthesizer.pkl')

# Load later
from sdv.single_table import GaussianCopulaSynthesizer
loaded = GaussianCopulaSynthesizer.load('my_synthesizer.pkl')
new_data = loaded.sample(num_rows=100)

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

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